Replace gcc with llvm-gcc

I truly get the bytecode file for each souce file,but can I use
llvm-link to link them into a whole-program one automatically through
some scripts?

Just set llvm-ld as the default ld .
Such as LD = llvm-ld in makefile, if it's not working, then there is no solution

罗勇刚(Yonggang Luo) wrote:

Just set llvm-ld as the default ld .
Such as LD = llvm-ld in makefile, if it's not working, then there is no solution
  

Some Makefiles use the C compiler (e.g., gcc or llvm-gcc) as the
linker. For such Makefiles, the above will not work because llvm-gcc
runs ld. What you need is a linker that can link LLVM bitcode files
together.

If that is the case, then an alternative is to use the LLVM plugin for
the gold linker (http://llvm.org/docs/GoldPlugin.html). If gold is your
system linker (or you can make llvm-gcc use it instead of ld), then (I
believe) you can get the Makefiles to transparently link LLVM bitcode
files together into a single bitcode file.

The above is for Linux. On Mac OS X, I think the linker with Xcode can
link bitcode files together, but I'm not sure.

Please note that I haven't tried this myself yet; it's one of the things
I will try the next time I need to create a single bitcode file for an
executable.

-- John T.

It is called CCLD/CXXLD for automake generated makefiles.

Best regards,
--Edwin