[cfe-dev] Building clang from source and header/library search paths
hans at chromium.org
Tue Dec 17 15:35:24 PST 2013
On Tue, Dec 17, 2013 at 3:24 PM, Edward Diener
<eldlistmailingz at tropicsoft.com> wrote:
> When clang is built on a Linux distro from the latest source as
> described by http://clang.llvm.org/get_started.html how are the default
> header and library search paths determined ?
I don't know exactly how it works, but the code that tries to find the
headers and libraries is in lib/Driver/ToolChains.cpp. It's entirely
possible that it gets things wrong on some systems.
> On a particular Linux distro, using gcc 4.7.2, there is an older clang
> distribution package installed ( 3.2 ) and it finds the header and
> libraries in the gcc distribution without any problems. Yet if I build
> the latest clang as described in the URL above successfully, that latest
> version does not find the header and libraries in the gcc distribution
> at all. So I am trying to understand why this is happening.
> In the URL above I do see the explanation:
> "If you intend to use Clang's C++ support, you may need to tell it how
> to find your C++ standard library headers. In general, Clang will detect
> the best version of libstdc++ headers available and use them - it will
> look both for system installations of libstdc++ as well as installations
> adjacent to Clang itself. If your configuration fits neither of these
> scenarios, you can use the --with-gcc-toolchain configure option to tell
> Clang where the gcc containing the desired libstdc++ is installed."
> but I do not understand either how to determine what clang is detecting
> or how to tell it to, via the "-with-gcc-toolchain" configuration
> option, where to find the correct headers and libraries.
One way to debug this is to run clang on a file with the -v option. It
should first spit out some lines such as:
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.6.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
And later on, it should print out where it's actually trying to search
ignoring nonexistent directory
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
I'm not sure how the --with-gcc-toolchain configuration option is
hooked up, though.
More information about the cfe-dev