LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 19297 - New clang 3.4 build can't find includes
Summary: New clang 3.4 build can't find includes
Status: RESOLVED FIXED
Alias: None
Product: Packaging
Classification: Unclassified
Component: deb packages (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Sylvestre Ledru
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-31 20:29 PDT by Vincent
Modified: 2014-04-27 01:18 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent 2014-03-31 20:29:33 PDT
I'm running Clang from inside a Docker instance running Ubuntu 12.04. Here's a tiny test case that shows the problem:

root@eacf7e43c75a:~# cat test.c
# include_next <limits.h>

In file included from test.c:1:
/usr/include/limits.h:125:16: fatal error: 'limits.h' file not found
# include_next <limits.h>
               ^
1 warning and 1 error generated.

root@eacf7e43c75a:~# clang -v
Ubuntu clang version 3.4.1-1~exp1 (branches/release_34) (based on LLVM 3.4.1)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8

However, I have a docker instance I built a couple months ago that's almost entirely the same, except for what I think is a version bump in clang-3.4:

(the following snippet is from the old image, which handles the test case fine)

root@7c57e7415f1d:~# clang -v
Ubuntu clang version 3.4-1~exp1 (branches/release_34) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8

Did something change in how clang looks for include files?
Comment 1 Vincent 2014-03-31 20:37:41 PDT
Upon further digging, I believe this is due to clang expecting:

/usr/bin/../lib/clang/3.4.1/include

unfortunately, only

/usr/bin/../lib/clang/3.4/include

exists
Comment 2 Vincent 2014-03-31 20:46:11 PDT
Even worse, there appears to be a circular symlink loop in the /usr/lib/clang directory. I'd be very grateful for adult supervision!

root@9983b8ac1abe:/usr/lib/clang# ls -al
total 12
drwxr-xr-x  3 root root 4096 Apr  1 00:02 .
drwxr-xr-x 54 root root 4096 Apr  1 00:02 ..
drwxr-xr-x  2 root root 4096 Apr  1 00:02 3.4
lrwxrwxrwx  1 root root    3 Mar 30 00:28 3.4.0 -> 3.4
root@9983b8ac1abe:/usr/lib/clang# ls -al 3.4/
total 8
drwxr-xr-x 2 root root 4096 Apr  1 00:02 .
drwxr-xr-x 3 root root 4096 Apr  1 00:02 ..
lrwxrwxrwx 1 root root   38 Mar 30 00:28 include -> ../../llvm-3.4/lib/clang/3.4.0/include
lrwxrwxrwx 1 root root   34 Mar 30 00:28 lib -> ../../llvm-3.4/lib/clang/3.4.0/lib
root@9983b8ac1abe:/usr/lib/clang#
Comment 3 Richard Smith 2014-03-31 21:40:50 PDT
Where did you get your Clang 3.4.1 package from?
Comment 4 Vincent 2014-04-01 01:04:15 PDT
(In reply to comment #3)
> Where did you get your Clang 3.4.1 package from?

From the usual apt-get repo:

deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.4 main
deb-src http://llvm.org/apt/precise/ llvm-toolchain-precise-3.4 main

apt-get install -y clang-3.4 llvm-3.4
Comment 5 Vincent 2014-04-01 01:20:39 PDT
Ah, my mistake. The links aren't circular - they're just wrong or missing.

/usr/lib/clang/3.4.1 is not present

/usr/lib/clang/3.4.0 is present but contains
  include -> /usr/lib/llvm-3.4/lib/clang/3.4.0/include, which is not present. 

There is only /usr/lib/llvm-3.4/lib/clang/3.4 and /usr/lib/llvm-3.4/lib/clang/3.4.1, which contains the proper headers

Symlinking that appears to let my build succeed.

There is however, another wrinkle: /usr/lib/llvm-3.4/lib/clang/3.4/lib appears to be empty. On my "good" installation, this directory contains "linux"
Comment 6 halayli 2014-04-14 12:41:39 PDT
Is there an official workaround for this bug or should we just symlink until the bug is resolved?
Comment 7 Vincent 2014-04-14 12:50:06 PDT
I've been symlinking. I haven't got any sort of official response to the bug yet.
Comment 8 Tom Stellard 2014-04-14 14:26:22 PDT
(In reply to comment #7)
> I've been symlinking. I haven't got any sort of official response to the bug
> yet.

Can you try this patch:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140303/100882.html
Comment 9 Vincent 2014-04-16 04:11:45 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > I've been symlinking. I haven't got any sort of official response to the bug
> > yet.
> 
> Can you try this patch:
> http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140303/100882.
> html

Tom, I'm not a very sophisticated user. Is there a doc I can follow about how to compile clang from source with a specified patch?
Comment 10 Sylvestre Ledru 2014-04-27 01:18:37 PDT
that should be fixed now.