[cfe-dev] Extracting the include tree from a source file
broeksema at kde.org
Thu Nov 18 13:21:50 CST 2010
Nico Weber wrote:
> Hm, this _might_ be because clang comes with a few standard headers,
> see clang/lib/Headers. Maybe clang adds these to the search path
> somehow. Adding a gentoo-specific include path is the correct fix in
> this case.
Yes it is because clang needs this standard headers installed in
/usr/lib/clang/2.8/include (on linux of course, don't know about other
platforms). From libs/Driver/Driver.cpp: (line 76 and further in 2.8)
// Compute the path to the resource directory.
P.eraseComponent(); // Remove /bin from foo/bin
ResourceDir = P.str();
I don't really understand why. Moreover, I don't understand why
AddGnuCPlusPlusIncludePaths in InitHeaderSearch.cpp is implemented as is.
For example take:
"x86_64-pc-linux-gnu", "32", "", triple);
The directory above (i.e. /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/)
also contains the headers which are in /usr/lib/clang/2.8/include. So I
wondered why AddGnuCPlusPlusIncludePaths, doesn't add this path too so that
the clang include directory is not required.
This might be Gentoo specific, meaning that for other distros the current
code *does* find the standard headers and therefore doesn't need the clang
include path. If so, please tell me. In that case for the Gentoo adding a
, System, true, false, false );
would remove the need for custom apps to add the clang include dir.
More information about the cfe-dev