X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FGoldPlugin.rst;h=6328934b37b344e37a879bf4fdee02a4df392ba4;hb=809b9552596f116e12d48fa2b3e67907f87c1962;hp=722a9a1bb06f61c1c46321b762da43984fcbe024;hpb=2ba4bd97d1aedf50c424c45ee327abddbf34dd12;p=oota-llvm.git diff --git a/docs/GoldPlugin.rst b/docs/GoldPlugin.rst index 722a9a1bb06..6328934b37b 100644 --- a/docs/GoldPlugin.rst +++ b/docs/GoldPlugin.rst @@ -1,5 +1,3 @@ -.. _gold-plugin: - ==================== The LLVM gold plugin ==================== @@ -32,30 +30,25 @@ by running ``/usr/bin/ld -plugin``. If it complains "missing argument" then you have plugin support. If not, such as an "unknown option" error then you will either need to build gold or install a version with plugin support. -* To build gold with plugin support: +* Download, configure and build gold with plugin support: .. code-block:: bash - $ mkdir binutils - $ cd binutils - $ cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login - {enter "anoncvs" as the password} - $ cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils + $ git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils $ mkdir build $ cd build - $ ../src/configure --enable-gold --enable-plugins + $ ../binutils/configure --enable-gold --enable-plugins --disable-werror $ make all-gold - That should leave you with ``binutils/build/gold/ld-new`` which supports - the ``-plugin`` option. It also built would have - ``binutils/build/binutils/ar`` and ``nm-new`` which support plugins but - don't have a visible -plugin option, instead relying on the gold plugin - being present in ``../lib/bfd-plugins`` relative to where the binaries - are placed. + That should leave you with ``build/gold/ld-new`` which supports + the ``-plugin`` option. Running ``make`` will additionally build + ``build/binutils/ar`` and ``nm-new`` binaries supporting plugins. -* Build the LLVMgold plugin: Configure LLVM with - ``--with-binutils-include=/path/to/binutils/src/include`` and run - ``make``. +* Build the LLVMgold plugin. If building with autotools, run configure with + ``--with-binutils-include=/path/to/binutils/include`` and run ``make``. + If building with CMake, run cmake with + ``-DLLVM_BINUTILS_INCDIR=/path/to/binutils/include``. The correct include + path will contain the file ``plugin-api.h``. Usage ===== @@ -68,17 +61,16 @@ look for the line where it runs ``collect2``. Replace that with ready to switch to using gold, backup your existing ``/usr/bin/ld`` then replace it with ``ld-new``. -You can produce bitcode files from ``clang`` using ``-emit-llvm`` or -``-flto``, or the ``-O4`` flag which is synonymous with ``-O3 -flto``. - -Any of these flags will also cause ``clang`` to look for the gold plugin in +You should produce bitcode files from ``clang`` with the option +``-flto``. This flag 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 own gold, be -sure to install the ``ar`` and ``nm-new`` you built to ``/usr/bin``. +``ar`` and ``nm`` also accept the ``-plugin`` option and it's possible to +to install ``LLVMgold.so`` to ``/usr/lib/bfd-plugins`` for a seamless setup. +If you built your own gold, be sure to install the ``ar`` and ``nm-new`` you +built to ``/usr/bin``. Example of link time optimization @@ -155,7 +147,6 @@ everything is in place for an easy to use LTO build of autotooled projects: 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 - export CFLAGS="-O4" * Or you can just set your path: @@ -165,7 +156,6 @@ everything is in place for an easy to use LTO build of autotooled projects: export CC="clang -flto" export CXX="clang++ -flto" export RANLIB=/bin/true - export CFLAGS="-O4" * Configure and build the project as usual: .. code-block:: bash