Clang 3.4 --with-gcc-toolchain question

Good day,
I would like to ask about the behavior of ‘–with-gcc-toolchain’ configuration option.
I am currently trying out clang 3.4 with gcc 4.7 and for this, I used the centos devtools repo.
GCC 4.7 is installed into /opt/centos/devtoolset-1.0/.
I configured clang 3.4 like below:
CC=/opt/centos/devtoolset-1.0/root/usr/bin/gcc CXX=/opt/centos/devtoolset-1.0/root/usr/bin/g++ --with-gcc-toolchain=/opt/centos/devtoolset-1.0/root/usr/

Make is ok but when I try clang-check it doesn’t seem to find ‘iostream’.
I thought with the option --with-gcc-toolchain, clang and its tools will automatically be pointed the gcc 4.7 directories.
Perhaps I am missing something here or my assumptions are flawed. Can someone share some insights?.

Using the -v option on clang-check, the “Selected GCC installation:” is blank and the list of include directories don’t include the 4.7 directories.
Explicitly specifying the include directories (-I option) in the clang-check invocation will work but is there another workaround?
I would prefer to resolve such issues in the ‘environment setup’ aspect and not during ‘application usage’.

Thank you very much,
David

David,

On my machine, gcc 4.7 is installed in /usr/local/tools/gcc-4.7.3

I configure from a build directory:
$ mkdir build && cd build
$ …/llvm/configure --with-gcc-toolchain=/usr/local/tools/gcc-4.7.3 --with-extra-ld-options=-Wl,-rpath,/usr/local/tools/gcc-4.7.3/lib/ --enable-optimized

The GCCInsatllationDetector in clang/lib/Driver/ToolChains.h looks for crtbegin.o files in places like: /usr/local/tools/gcc-4.7.3/lib/gcc//<major.minor.patch>/crtbegin.o In my case, that is: /usr/local/tools/gcc-4.7.3/lib/gcc/x86_64-unknown-linux-gnu/4.7.3/crtbegin.o But there are a bunch of formats for this kind of stuff. See Generic_GCC::GCCInstallationDetector::init in clang/lib/Driver/ToolChains.cpp (and the things that it calls). Cheers, Jon

Good day Jon,

Thank you for the suggestion.
I rebuilt my llvm/clang with the additional ‘–with-extra-ld-options’ option but clang was still unable to find my gcc.
Perhaps the devtoolset-gcc-4.7 was installed in an unusual location and explicitly adding the path is the only way?

One thing I tried was to modify clang/lib/Frontend/InitHeaderSearch.cpp.
I got the idea from an old thread:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-April/021039.html
But still not ok. It was this thread that made me assume that the --with-gcc-toolchain option was enough.
Looking for something else to go on, I tried to add some paths in the file you mentioned, Toolchains.cpp.
Maybe there were some mistakes in my mod since the result was still not ok. I will try again later.

There is another angle I have yet to try which is the procedure provided here:
http://llvm.org/docs/GettingStarted.html#getting-a-modern-host-c-toolchain
Currently, I have problems compiling gcc 4.8.2 so I can’t say yet what will be the result.

Will try other versions.

Thank you very much for the support.

Best regards,
David

Good day to all,
Just an update, building clang with a gcc built from source seemed to work fine. (‘-v’ option shows the correct gcc location).
Still not sure why my previous clang configuration/setup using a gcc installed from the devtools repo won’t work.
If someone would have some insights on possible causes, please feel free to share.
For now I will go with this setup.
Thank you all,
David