Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 327575 - clang++ doesn't find gcc-4.4.4's include files
Summary: clang++ doesn't find gcc-4.4.4's include files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Bernard Cafarelli
URL: http://llvm.org/bugs/show_bug.cgi?id=...
Whiteboard:
Keywords:
Depends on:
Blocks: 341891
  Show dependency tree
 
Reported: 2010-07-09 08:23 UTC by Helmut Jarausch
Modified: 2010-10-20 11:56 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helmut Jarausch 2010-07-09 08:23:27 UTC
clang++ doesn't even compile a hello world program :
 fatal error: 'iostream' file not found

Using the -v command line switch shows that it searches
/usr/lib/gcc/x86_64-pc-linux-gnu/$VVV/include/g++-v4/x86_64-pc-linux-gnu/
where $VVV goes up to 4.4.3 but I have installed 4.4.4

This is with clang-9999

clang should probably select the headers of the currently selected (gcc-config)
gcc version.


Reproducible: Always
Comment 1 Markos Chandras (RETIRED) gentoo-dev 2010-07-10 23:25:37 UTC
there is not clang++ on tree
Comment 2 Danny Robson 2010-07-11 05:14:11 UTC
there is no explicit clang++ in the tree, but it forms part of the sys-devel/clang package (though remains somewhat experimental IIRC).
I can report the same symptoms as Helmut here using =sys-devel/clang-2.7
Comment 3 Bernard Cafarelli gentoo-dev 2010-07-13 12:49:29 UTC
Yes, I saw the problem when testing 4.5.0

in 2.7, clang has a set of hardcoded paths for current distributions/compilers (including a few for Gentoo, but of course not the new ones)

The workaround for now will be to add the paths to currently installed gcc when merging clang, and log that rebuilding clang may be needed when installing a new gcc

I hope next version will have a more dynamic way to look for these...
Comment 4 Bernard Cafarelli gentoo-dev 2010-07-20 09:35:14 UTC
Ok, clang-2.7-r1 is in tree (and -9999 updated), which finds the current gcc version headers
Sadly the path is added at compilation time (for this version) so any gcc version change/update will require a clang remerge. From upstream bug let's hope later versions of clang will find at runtime

Thanks for the report!
Comment 5 Mamadou Babaei 2010-07-22 03:13:22 UTC
Hi Folks,

I have the same issue and I'm on ~x86.

(In reply to comment #4)
> Ok, clang-2.7-r1 is in tree (and -9999 updated), which finds the current gcc
> version headers
> Sadly the path is added at compilation time (for this version) so any gcc
> version change/update will require a clang remerge. From upstream bug let's
> hope later versions of clang will find at runtime
> 
> Thanks for the report!
> 

Could you please tell me how to add these paths in compilation time??
(I know to set variables in emerge command like:
# var="value" emerge sys-devel/clang
but which variables you're setting??)

This is my gcc search path:

#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4/i686-pc-linux-gnu
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4/backward
 /usr/local/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include-fixed
 /usr/include
End of search list.

Any help will be appreciated.
Comment 6 Matt Michalowski 2010-07-22 04:09:46 UTC
On my machines, "gcc-config -X" returns:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4 (for gcc-4.4.4-r1)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.5/include/g++-v4 (for gcc-4.3.5)

So I had to change:
CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=$(gcc-config -X| cut -d: -f1)/include/g++-v4"

to simply:
CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=$(gcc-config -X| cut -d: -f1)"

for this to work for me.
Comment 7 Danny Robson 2010-07-22 04:38:50 UTC
(In reply to comment #5)
> Could you please tell me how to add these paths in compilation time??
> (I know to set variables in emerge command like:
> # var="value" emerge sys-devel/clang
> but which variables you're setting??)

You shouldn't have to set any variables when merging the new ebuild. I haven't tested on a large application yet, but as mentioned previously simply re-syncing portage, and re-emerging clang let me compile a couple of trivial pieces of code laying about here. Works for me.
Comment 8 Mamadou Babaei 2010-07-22 09:11:56 UTC
Ah !! It works.
Thanks! I think I found a solution.

http://comments.gmane.org/gmane.comp.compilers.clang.devel/7774


I did this and it's simply works :)


cd /usr/portage/distfiles/
tar xvzf llvm-2.7.tgz -C ~/Desktop/
tar xvzf clang-2.7.tgz -C ~/Desktop/llvm-2.7/tools/
cd ~/Desktop/llvm-2.7/
mv tools/clang-2.7/ tools/clang/

nano tools/clang/lib/Frontend/InitHeaderSearch.cpp
########
    // Gentoo gcc 4.4.4
    AddGnuCPlusPlusIncludePaths(
      "/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include/g++-v4",
      "i686-pc-linux-gnu", "", "", triple);
########

mkdir ./build && cd ./build
cmake ../

sudo make install
Comment 9 Bernard Cafarelli gentoo-dev 2010-07-22 09:33:56 UTC
Thanks for the x86 output of gcc-config, I'll change the cxx-include-root variable to something that should work on all

Re #8, yes that is the other way to do it, I find it a bit messier as clang++ will go over a bunch of non-existing directories when looking for headers (the InitHeaderSearch.cpp size gets scary)
Comment 10 Mark Wood 2010-07-24 01:15:28 UTC
While not fully related to the bug. I should note that clang C++ support is best built against llvm-gcc (trunk if possible)

Could you please add the following include:

/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/

I'm not sure what the stable version (of llvm-gcc) uses for inlude.

Thanks.
Comment 11 Mark Wood 2010-07-24 21:36:48 UTC
(In reply to comment #10)
> While not fully related to the bug. I should note that clang C++ support is
> best built against llvm-gcc (trunk if possible)
> 
> Could you please add the following include:
> 
> /usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/
> 
> I'm not sure what the stable version (of llvm-gcc) uses for inlude.
> 
> Thanks.
> 

Patched into mainline clang. No longer needed :)
Comment 12 Mark Wood 2010-07-25 15:53:05 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > While not fully related to the bug. I should note that clang C++ support is
> > best built against llvm-gcc (trunk if possible)
> > 
> > Could you please add the following include:
> > 
> > /usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/
> > 
> > I'm not sure what the stable version (of llvm-gcc) uses for inlude.
> > 
> > Thanks.
> > 
> 
> Patched into mainline clang. No longer needed :)
> 

Your patch for finding the current gcc headers ignores that I use llvm-gcc (and do not have gcc installed). It may be worth adding an "llvm-gcc" flag that will use the llvm-gcc headers instaed.
Comment 13 Bernard Cafarelli gentoo-dev 2010-07-27 13:06:48 UTC
OK, clang-2.7-r2 is in tree now, with a new USE flag, system-cxx-headers.
Enabling it will use active gcc headers and should work on both x86 and amd64, disabling it will let clang++ behave as before, searching through its hardcoded paths (which include llvm-gcc in -9999).

This should work for everyone :) thanks all
Comment 14 Guillaume Chatelet 2010-10-17 17:22:58 UTC
(In reply to comment #13)
I tried to build Boost.Thread with clang and it looks like clang can't find
#include <cxxabi.h>
in file ($BOOST_ROOT)/boost/exception/detail/type_info.hpp:18

After checking on my system, this file is located in
/usr/lib/gcc/i686-pc-linux-gnu/4.4.4/include

The directory is not present in clang executable.
Comment 15 Bernard Cafarelli gentoo-dev 2010-10-20 11:50:00 UTC
(In reply to comment #14)
Let's open a new bug, this one was about clang not even building "Hello world" C++ program without the system-cxx-headers USE flag