[cfe-dev] Cleaning up the clang::driver::toolchains::Linux mess?

James Molloy james.molloy at arm.com
Wed Jun 15 00:07:51 PDT 2011


Hi Anders,

> and call that “not relying on GCC”.  Not relying on GCC would mean that
> I
> don’t need to have any parts of GCC installed to use clang.  That might
> be
> possible in the bare-metal case, but it doesn’t make sense to talk
> about
> that in the Linux case until clang has its own replacements for
> crtbegin.o, crtend.o, libgcc.a, libgcc_s.so, and knows how to find
> crt1.o,
> crti.o, crtn.o, libc.so without backtracking from GCC’s internal paths.

Because of Linux's heavy reliance on GCC anyway (coupled with compilerrt's lack of maturity), this does indeed make sense for Linux.

But the default "Unknown" case, used for baremetal cross-compilation still uses this method also instead of either doing what the *BSDs do which is find as/ld, or even better trying to find an as/ld with the program prefix clang was invoked with (for example "i686-pc-clang" would look for "i686-pc-as").

James

> -----Original Message-----
> From: Anders Kaseorg [mailto:andersk at mit.edu]
> Sent: 14 June 2011 19:09
> To: James Molloy
> Cc: Rafael Espindola; cfe-dev at cs.uiuc.edu
> Subject: RE: [cfe-dev] Cleaning up the clang::driver::toolchains::Linux
> mess?
> 
> On Tue, 14 Jun 2011, James Molloy wrote:
> > (but LLVM/Clang is meant to be a GCC replacement - it shouldn't rely
> on
> > it!).
> 
> I do hope there was a better motivation for r118382 than that.  One
> can’t
> just switch from running
> 
> gcc -o foo foo.o
> 
> to running
> 
> "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker
> /lib64/ld-linux-x86-64.so.2 -o foo
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../crt1.o
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../crti.o
> /usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o
> -L/usr/lib/gcc/x86_64-linux-gnu/4.6
> -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib64 -L/lib/../lib64
> -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. foo.o
> -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
> --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../crtn.o
> 
> and call that “not relying on GCC”.  Not relying on GCC would mean that
> I
> don’t need to have any parts of GCC installed to use clang.  That might
> be
> possible in the bare-metal case, but it doesn’t make sense to talk
> about
> that in the Linux case until clang has its own replacements for
> crtbegin.o, crtend.o, libgcc.a, libgcc_s.so, and knows how to find
> crt1.o,
> crti.o, crtn.o, libc.so without backtracking from GCC’s internal paths.
> 
> Anders








More information about the cfe-dev mailing list