diff --git a/docs/GoldPlugin.html b/docs/GoldPlugin.html index 375dd3c8ca7..2c08bd031b7 100644 --- a/docs/GoldPlugin.html +++ b/docs/GoldPlugin.html @@ -89,11 +89,11 @@ placed. -emit-llvm or -flto, or the -O4 flag which is synonymous with -O3 -flto.

-

Clang has a -use-gold-plugin option which looks for the - gold plugin in the same directories as it looks for cc1 and passes - the -plugin option to ld. It will not look for an alternate - linker, which is why you need gold to be the installed system linker in your - path.

+

Any of these flags will also cause clang to look for the + gold plugin in the lib directory under its prefix and pass the + -plugin option to ld. It will not look for an alternate + linker, which is why you need gold to be the installed system linker in + your path.

If you want ar and nm to work seamlessly as well, install LLVMgold.so to /usr/lib/bfd-plugins. If you built your @@ -141,10 +141,10 @@ void foo4(void) { } --- command lines --- -$ clang -flto a.c -c -o a.o # <-- a.o is LLVM bitcode file -$ ar q a.a a.o # <-- a.a is an archive with LLVM bitcode -$ clang b.c -c -o b.o # <-- b.o is native object file -$ clang -use-gold-plugin a.a b.o -o main # <-- link with LLVMgold plugin +$ clang -flto a.c -c -o a.o # <-- a.o is LLVM bitcode file +$ ar q a.a a.o # <-- a.a is an archive with LLVM bitcode +$ clang b.c -c -o b.o # <-- b.o is native object file +$ clang -flto a.a b.o -o main # <-- link with LLVMgold plugin

Gold informs the plugin that foo3 is never referenced outside the IR, @@ -171,13 +171,12 @@ $ clang -use-gold-plugin a.a b.o -o main # <-- link with LLVMgold plugin

  • Follow the instructions on how to build LLVMgold.so.
  • Install the newly built binutils to $PREFIX
  • Copy Release/lib/LLVMgold.so to - $PREFIX/libexec/gcc/x86_64-unknown-linux-gnu/4.2.1/ and $PREFIX/lib/bfd-plugins/
  • Set environment variables ($PREFIX is where you installed clang and binutils):
    -export CC="$PREFIX/bin/clang -use-gold-plugin"
    -export CXX="$PREFIX/bin/clang++ -use-gold-plugin"
    +export CC="$PREFIX/bin/clang -flto"
    +export CXX="$PREFIX/bin/clang++ -flto"
     export AR="$PREFIX/bin/ar"
     export NM="$PREFIX/bin/nm"
     export RANLIB=/bin/true #ranlib is not needed, and doesn't support .bc files in .a
    @@ -187,8 +186,8 @@ export CFLAGS="-O4"
          
  • Or you can just set your path:
     export PATH="$PREFIX/bin:$PATH"
    -export CC="clang -use-gold-plugin"
    -export CXX="clang++ -use-gold-plugin"
    +export CC="clang -flto"
    +export CXX="clang++ -flto"
     export RANLIB=/bin/true
     export CFLAGS="-O4"