LWN.net Logo

LFCS 2012: LLVM and Linux

LFCS 2012: LLVM and Linux

Posted May 1, 2012 14:53 UTC (Tue) by jwakely (subscriber, #60262)
In reply to: LFCS 2012: LLVM and Linux by kmccarty
Parent article: LFCS 2012: LLVM and Linux

Issue 2 is that if one has installed a version of GCC in /usr/local, it seems to be impossible to build Clang such that by default it will use that GCC version's object files (crtbegin.o, etc.) and libstdc++ headers without actually hacking the portions of the Clang source code where these paths are defined. Perhaps this has improved since the version of Clang I'm at (SVN trunk from Sept. 30, 2011)
Yes, it changed. At one time you needed to hack the source. Then you needed to use --with-cxx-include-root and --with-cxx-include-arch at configure-time, now you just use --with-gcc-toolchain and it does the right thing. It took a while getting there though.


(Log in to post comments)

LFCS 2012: LLVM and Linux

Posted May 1, 2012 22:29 UTC (Tue) by kmccarty (subscriber, #12085) [Link]

Yes, it changed. At one time you needed to hack the source. Then you needed to use --with-cxx-include-root and --with-cxx-include-arch at configure-time, now you just use --with-gcc-toolchain and it does the right thing. It took a while getting there though.

Thanks much for the update, this appears to work as advertised. I guess it is only available in SVN trunk, though, not in the 3.0 release?

I can get rid of my local Clang patches except for a couple lines to disable adding the --no-add-needed linker option when "IsRedhat(Distro)" returns true. (I'm not sure whether this distro autodetection is still enabled when GCC_INSTALL_PREFIX is pre-#define'd, but I didn't want to chance having to do yet another rebuild.)

I was even able to remove a bunch of -isystem flags pointing at GCC headers from the Clang-invoking wrapper scripts I have. I can't say that the relevant parts of Clang source code got very much prettier, though ;-)

LFCS 2012: LLVM and Linux

Posted May 2, 2012 9:00 UTC (Wed) by jwakely (subscriber, #60262) [Link]

> I guess it is only available in SVN trunk, though, not in the 3.0 release?

Dunno, sorry, I only use trunk

LFCS 2012: LLVM and Linux

Posted May 2, 2012 16:04 UTC (Wed) by kmccarty (subscriber, #12085) [Link]

(Replying to myself)

I was even able to remove a bunch of -isystem flags pointing at GCC headers from the Clang-invoking wrapper scripts I have.

Sadly I spoke too soon -- Clang compiled with --with-gcc-toolchain is not finding omp.h, which is under the GCC installation at <gccroot>/lib/gcc/x86_64-unknown-linux-gnu/4.2.4/include together with a few other things like float.h, varargs.h and limits.h. Ought I to file a bug?

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds