Skip to content

Instantly share code, notes, and snippets.

@rkitover
Created April 9, 2016 00:20
Show Gist options
  • Save rkitover/552e0ad79714b1e7b182ed8c2823445b to your computer and use it in GitHub Desktop.
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')
@ChaoPeng13
Copy link

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

@m-happy
Copy link

m-happy commented Aug 19, 2019

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

@jubnzv
Copy link

jubnzv commented Sep 14, 2019

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

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
Copy link

abdpp commented May 30, 2020

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
Copy link

sabetAI commented Oct 11, 2020

Same problem, and still no solution?

@greco-roamin
Copy link

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

@shifz
Copy link

shifz commented Nov 29, 2020

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

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
Copy link

rileyrg commented Mar 1, 2021

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

This worked.

@BhargavJayswal
Copy link

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
Copy link

rileyrg commented Apr 22, 2021

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
Copy link

tamasgal commented May 21, 2021

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
Copy link

gcasa commented Sep 14, 2021

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