[llvm-dev] [llvm-toolchain v3.8.1] LTO: Linking clang hangs with ld.gold and LLVMgold.so plugin

Sedat Dilek via llvm-dev llvm-dev at lists.llvm.org
Sun Jul 24 02:35:32 PDT 2016


BTW, I use here...

[ build_llvm-toolchain.sh ]
...
# CMake binutils binaries and linker options (here: GNU/ld or
alternatively GNU/gold from selfmade binutils v2.26.1)
# NOTE: Build the LLVMgold-plugin where $BINUTILS_INC_DIR contains
plugin-api.h file
BINUTILS_BIN_DIR="/opt/binutils/bin"
BINUTILS_INC_DIR="/opt/binutils/include"
...
# Use selfmade GNU/gold as linker
LINKER_GOLD="$BINUTILS_BIN_DIR/ld.gold"
LINKER="$LINKER_GOLD"
LINKER_CMAKE_OPTS="-DCMAKE_LINKER=$LINKER -DGOLD_EXECUTABLE=$LINKER_GOLD"
LINKER_CMAKE_OPTS="$LINKER_CMAKE_OPTS -DLLVM_BINUTILS_INCDIR=$BINUTILS_INC_DIR"
...

Unfortunately, I see that the system-wide linker is used even I have
explitly set "-DCMAKE_LINKER=$LINKER".
Checking the settings look good.

$ cd llvm-build/
$ cmake ../llvm -LA | egrep -i 'binutils|gold'
CMAKE_LINKER:FILEPATH=/opt/binutils/bin/ld.gold
GOLD_EXECUTABLE:FILEPATH=/opt/binutils/bin/ld.gold
LLVM_BINUTILS_INCDIR:PATH=/opt/binutils/include
LLVM_TOOL_GOLD_BUILD:BOOL=ON

This is no problem here as I have...

$ LC_ALL=C ls -l /usr/bin/ld /opt/binutils/bin/ld
lrwxrwxrwx 1 root root  7 Jul 23 13:35 /opt/binutils/bin/ld -> ld.gold*
lrwxrwxrwx 1 root root 20 Jul 23 13:42 /usr/bin/ld -> /opt/binutils/bin/ld*

I will place my selfmade ld.gold to /usr/bin/ and rename the original one.

# cd /usr/bin/
# mv ld.gold ld.gold-2.22
# mv /opt/binutils/bin/ld.gold /usr/bin/ld.gold-2.26.1
# rm -v -f ld
# ln -sf ld.gold-2.26.1 ld

My LLVMgold-plugin is embedded like this...

$ LC_ALL=C ll /usr/lib/bfd-plugins/LLVMgold.so
lrwxrwxrwx 1 root root 25 Jul 23 16:13
/usr/lib/bfd-plugins/LLVMgold.so -> /opt/llvm/lib/LLVMgold.so

Anyone can tell me why my explicitly setting $LINKER does not work as expected?

- sed@ -
-------------- next part --------------
root      9796  100 32.4 1360208 1273204 tty1  R    10:21   9:07 /usr/bin/ld -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bin/llvm-c-test /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../.. -L/opt/llvm/bin/../lib -L/lib -L/usr/lib -plugin /opt/llvm/bin/../lib/LLVMgold.so -plugin-opt=mcpu=x86-64 -plugin-opt=O3 -allow-shlib-undefined -O3 --gc-sections tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/calc.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/disassemble.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/helpers.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/include-all.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/main.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/module.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/metadata.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/object.c.o tools/llvm-c-test/CMakeFiles/llvm-c-test.dir/targets.c.o lib/libLLVMX86CodeGen.a lib/libLLVMX86AsmPrinter.a lib/libLLVMX86AsmParser.a lib/libLLVMX86Desc.a lib/libLLVMX86Info.a lib/libLLVMX86Disassembler.a lib/libLLVMBitReader.a lib/libLLVMCore.a lib/libLLVMMCDisassembler.a lib/libLLVMObject.a lib/libLLVMTarget.a lib/libLLVMAsmPrinter.a lib/libLLVMSelectionDAG.a lib/libLLVMCodeGen.a lib/libLLVMTarget.a lib/libLLVMBitWriter.a lib/libLLVMInstrumentation.a lib/libLLVMProfileData.a lib/libLLVMScalarOpts.a lib/libLLVMInstCombine.a lib/libLLVMTransformUtils.a lib/libLLVMAnalysis.a lib/libLLVMX86AsmPrinter.a lib/libLLVMX86Utils.a lib/libLLVMObject.a lib/libLLVMBitReader.a lib/libLLVMCore.a lib/libLLVMMCParser.a lib/libLLVMX86Info.a lib/libLLVMMC.a lib/libLLVMSupport.a -lrt -ldl -ltinfo -lpthread -lz -lm -rpath $ORIGIN/../lib -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crtn.o
-------------- next part --------------
root      9848 99.6  7.7 438832 303356 tty1    R    10:32   1:11 /usr/bin/ld -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bin/llvm-cxxdump /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../.. -L/opt/llvm/bin/../lib -L/lib -L/usr/lib -plugin /opt/llvm/bin/../lib/LLVMgold.so -plugin-opt=mcpu=x86-64 -plugin-opt=O3 -allow-shlib-undefined -O3 --gc-sections tools/llvm-cxxdump/CMakeFiles/llvm-cxxdump.dir/llvm-cxxdump.cpp.o tools/llvm-cxxdump/CMakeFiles/llvm-cxxdump.dir/Error.cpp.o lib/libLLVMX86CodeGen.a lib/libLLVMX86AsmPrinter.a lib/libLLVMX86AsmParser.a lib/libLLVMX86Desc.a lib/libLLVMX86Info.a lib/libLLVMX86Disassembler.a lib/libLLVMObject.a lib/libLLVMSupport.a lib/libLLVMAsmPrinter.a lib/libLLVMSelectionDAG.a lib/libLLVMCodeGen.a lib/libLLVMBitWriter.a lib/libLLVMInstrumentation.a lib/libLLVMProfileData.a lib/libLLVMScalarOpts.a lib/libLLVMInstCombine.a lib/libLLVMTransformUtils.a lib/libLLVMTarget.a lib/libLLVMAnalysis.a lib/libLLVMX86AsmPrinter.a lib/libLLVMX86Utils.a lib/libLLVMObject.a lib/libLLVMBitReader.a lib/libLLVMCore.a lib/libLLVMMCParser.a lib/libLLVMX86Info.a lib/libLLVMMCDisassembler.a lib/libLLVMMC.a lib/libLLVMSupport.a -lrt -ldl -ltinfo -lpthread -lz -lm -rpath $ORIGIN/../lib -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crtn.o
-------------- next part --------------
root      9862  102  5.9 288236 232612 tty1    R    10:33   0:12 /usr/bin/ld -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bin/llvm-diff /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../.. -L/opt/llvm/bin/../lib -L/lib -L/usr/lib -plugin /opt/llvm/bin/../lib/LLVMgold.so -plugin-opt=mcpu=x86-64 -plugin-opt=O3 -allow-shlib-undefined -O3 --gc-sections tools/llvm-diff/CMakeFiles/llvm-diff.dir/llvm-diff.cpp.o tools/llvm-diff/CMakeFiles/llvm-diff.dir/DiffConsumer.cpp.o tools/llvm-diff/CMakeFiles/llvm-diff.dir/DiffLog.cpp.o tools/llvm-diff/CMakeFiles/llvm-diff.dir/DifferenceEngine.cpp.o lib/libLLVMCore.a lib/libLLVMIRReader.a lib/libLLVMSupport.a lib/libLLVMAsmParser.a lib/libLLVMBitReader.a lib/libLLVMCore.a lib/libLLVMSupport.a -lrt -ldl -ltinfo -lpthread -lz -lm -rpath $ORIGIN/../lib -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crtn.o


More information about the llvm-dev mailing list