Skip to content

Instantly share code, notes, and snippets.

@rkitover
Created April 9, 2016 00:20
Show Gist options
  • Select an option

  • Save rkitover/552e0ad79714b1e7b182ed8c2823445b to your computer and use it in GitHub Desktop.

Select an option

Save rkitover/552e0ad79714b1e7b182ed8c2823445b to your computer and use it in GitHub Desktop.
llvm won't link
[ 89%] Built target not
[ 89%] Built target yaml-bench
[ 89%] Built target gtest
[ 89%] Built target gtest_main
[ 89%] Built target LTO_exports
[ 90%] Linking CXX shared library ../../lib/libLTO.so
../../lib/libLLVMScalarOpts.a: could not read symbols: Memory exhausted
collect2: error: ld returned 1 exit status
*** Error 1 in . (tools/lto/CMakeFiles/LTO.dir/build.make:255 'lib/libLTO.so')
*** Error 1 in . (CMakeFiles/Makefile2:12494 'tools/lto/CMakeFiles/LTO.dir/all')
*** Error 1 in /home/rkitover/src/llvm/build (Makefile:150 'all')
@budongbai

Copy link
Copy Markdown

Have you solved this problem?

@0cherry

0cherry commented Nov 28, 2016

Copy link
Copy Markdown

Have you solved this problem?

@stayfoo

stayfoo commented Jun 7, 2017

Copy link
Copy Markdown

[ 65%] Built target RTAsanTest.x86_64-inline
[ 65%] Built target RTXray.x86_64
[ 65%] Built target LTO_exports
[ 65%] Linking CXX shared library ../../lib/libLTO.so
collect2: fatal error: ld terminated with signal 9 [已杀死]
compilation terminated.
tools/lto/CMakeFiles/LTO.dir/build.make:282: recipe for target 'lib/libLTO.so.5.0.0svn' failed
make[2]: *** [lib/libLTO.so.5.0.0svn] Error 1
make[2]: *** Deleting file 'lib/libLTO.so.5.0.0svn'
CMakeFiles/Makefile2:21294: recipe for target 'tools/lto/CMakeFiles/LTO.dir/all' failed
make[1]: *** [tools/lto/CMakeFiles/LTO.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

@ChaoPeng13

Copy link
Copy Markdown

I had the same problem.
Have you solved this problem?

@m-happy

m-happy commented Aug 19, 2019

Copy link
Copy Markdown

I'm facing the same problem.
Please answer this.

@jubnzv

jubnzv commented Sep 14, 2019

Copy link
Copy Markdown

I solved this problem by adding -DCMAKE_BUILD_TYPE=Release and -DLLVM_USE_LINKER=gold cmake options as described here. My final build commands looks like:

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build && cd build
cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release
ninja

@Edward-L

Copy link
Copy Markdown

I also encountered this problem. I solved this problem by adjusting the memory of the virtual machine. In my compilation, this libLTO.so will occupy at least 7 g of memory when linking, and will fail if it is not enough. So please check your memory situation.

@abdpp

abdpp commented May 30, 2020

Copy link
Copy Markdown

Hello,

Not sure if somebody could help here on priority !
I am unable to build the LLVm 10.0.0 with GCC 9.3.0 version.
On running or executing the "make -j6" command it throws an error at 24%
The last few errors are pasted as below :

      |                                                     ^
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp: In member function ‘void {anonymous}::NeonEmitter::runFP16(llvm::raw_ostream&)’:
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp:2566:33: error: ‘less_ptr’ is not a member of ‘llvm’; did you mean ‘less_first’?
 2566 |   llvm::stable_sort(Defs, llvm::less_ptr<Intrinsic>());
      |                                 ^~~~~~~~
      |                                 less_first
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp:2566:51: error: expected primary-expression before ‘>’ token
 2566 |   llvm::stable_sort(Defs, llvm::less_ptr<Intrinsic>());
      |                                                   ^
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp:2566:53: error: expected primary-expression before ‘)’ token
 2566 |   llvm::stable_sort(Defs, llvm::less_ptr<Intrinsic>());
      |                                                     ^
make[2]: *** [tools/clang/utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/NeonEmitter.cpp.o] Error 1
make[1]: *** [tools/clang/utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 24%] Building CXX object projects/compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_utils.cpp.o
[ 24%] Building CXX object projects/compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_x86_64.cpp.o
[ 24%] Building CXX object tools/llvm-cxxfilt/CMakeFiles/llvm-cxxfilt.dir/llvm-cxxfilt.cpp.o
[ 24%] Built target RTGwpAsanTest.x86_64
[ 24%] Building ASM object projects/compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_trampoline_x86_64.S.o
[ 24%] Building CXX object projects/compiler-rt/lib/xray/CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profiling_flags.cpp.o
[ 24%] Built target RTXrayPROFILING.x86_64
[ 24%] Built target RTXray.x86_64
[ 24%] Linking CXX executable ../../bin/llvm-cxxfilt
[ 24%] Built target llvm-cxxfilt
[ 24%] Linking CXX executable ../../bin/llvm-config
[ 24%] Built target llvm-config
make: *** [all] Error 2

@sabetAI

sabetAI commented Oct 11, 2020

Copy link
Copy Markdown

Same problem, and still no solution?

@greco-roamin

Copy link
Copy Markdown

adding -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=gold worked for me. thanks @jubnzv

@shifz

shifz commented Nov 29, 2020

Copy link
Copy Markdown

I also encountered this problem. I solved this problem by adjusting the memory of the virtual machine. In my compilation, this libLTO.so will occupy at least 7 g of memory when linking, and will fail if it is not enough. So please check your memory situation.

This one works for me. The default memory setting for my virtual machine is 4GB. It worked after I increased the memory size to 16GB.

@Devyani1305

Copy link
Copy Markdown

I am doing : cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../
I am getting this error:
[ 86%] Linking CXX executable ../../../../bin/clang
/usr/bin/ld.gold: error: cannot find -lLLVMExtensions
collect2: error: ld returned 1 exit status
tools/clang/tools/driver/CMakeFiles/clang.dir/build.make:313: recipe for target 'bin/clang-10' failed
make[2]: *** [bin/clang-10] Error 1

@rileyrg

rileyrg commented Mar 1, 2021

Copy link
Copy Markdown

Just hit the same on Debian bullseye with 32gb of memory.

This worked.

@BhargavJayswal

Copy link
Copy Markdown

I am doing : cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../
I am getting this error:
[ 86%] Linking CXX executable ../../../../bin/clang
/usr/bin/ld.gold: error: cannot find -lLLVMExtensions
collect2: error: ld returned 1 exit status
tools/clang/tools/driver/CMakeFiles/clang.dir/build.make:313: recipe for target 'bin/clang-10' failed
make[2]: *** [bin/clang-10] Error 1

HI Devyani,

Have you resolved this problem ?
I am facing same issue.

@rileyrg

rileyrg commented Apr 22, 2021

Copy link
Copy Markdown

I am doing : cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../
I am getting this error:
[ 86%] Linking CXX executable ../../../../bin/clang
/usr/bin/ld.gold: error: cannot find -lLLVMExtensions
collect2: error: ld returned 1 exit status
tools/clang/tools/driver/CMakeFiles/clang.dir/build.make:313: recipe for target 'bin/clang-10' failed
make[2]: *** [bin/clang-10] Error 1

HI Devyani,

Have you resolved this problem ?
I am facing same issue.

See here https://gist.github.com/rkitover/552e0ad79714b1e7b182ed8c2823445b#gistcomment-3649767

@tamasgal

tamasgal commented May 21, 2021

Copy link
Copy Markdown

Thanks, -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release fixed this on my MacBook M1 (16GB). I even had problems on my 8 Core Xeon with 64GB RAM, that's quite insane...

@gcasa

gcasa commented Sep 14, 2021

Copy link
Copy Markdown

Hello,

Not sure if somebody could help here on priority !
I am unable to build the LLVm 10.0.0 with GCC 9.3.0 version.
On running or executing the "make -j6" command it throws an error at 24%
The last few errors are pasted as below :

      |                                                     ^
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp: In member function ‘void {anonymous}::NeonEmitter::runFP16(llvm::raw_ostream&)’:
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp:2566:33: error: ‘less_ptr’ is not a member of ‘llvm’; did you mean ‘less_first’?
 2566 |   llvm::stable_sort(Defs, llvm::less_ptr<Intrinsic>());
      |                                 ^~~~~~~~
      |                                 less_first
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp:2566:51: error: expected primary-expression before ‘>’ token
 2566 |   llvm::stable_sort(Defs, llvm::less_ptr<Intrinsic>());
      |                                                   ^
/root/rpmbuild/BUILD/llvm-10.0.0rc6.src/tools/clang/utils/TableGen/NeonEmitter.cpp:2566:53: error: expected primary-expression before ‘)’ token
 2566 |   llvm::stable_sort(Defs, llvm::less_ptr<Intrinsic>());
      |                                                     ^
make[2]: *** [tools/clang/utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/NeonEmitter.cpp.o] Error 1
make[1]: *** [tools/clang/utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 24%] Building CXX object projects/compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_utils.cpp.o
[ 24%] Building CXX object projects/compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_x86_64.cpp.o
[ 24%] Building CXX object tools/llvm-cxxfilt/CMakeFiles/llvm-cxxfilt.dir/llvm-cxxfilt.cpp.o
[ 24%] Built target RTGwpAsanTest.x86_64
[ 24%] Building ASM object projects/compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_trampoline_x86_64.S.o
[ 24%] Building CXX object projects/compiler-rt/lib/xray/CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profiling_flags.cpp.o
[ 24%] Built target RTXrayPROFILING.x86_64
[ 24%] Built target RTXray.x86_64
[ 24%] Linking CXX executable ../../bin/llvm-cxxfilt
[ 24%] Built target llvm-cxxfilt
[ 24%] Linking CXX executable ../../bin/llvm-config
[ 24%] Built target llvm-config
make: *** [all] Error 2

It is UNBELIEVABLE that clang / ld.gold would take THAT much memory just to link. 7GB is an OUTRAGOUSLY large amount of memory for something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment