Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install LLVMgold.so for clang+llvm binary package?

I would like to use llvm control flow integrity and I used the clang+llvm binary packaged version 7.0.1 shipped for Ubuntu 14.04. When I use clang++ with options '-fsanitize=cfi -flto -fvisibility=hidden' I get the following error:

/usr/bin/ld: /home/username/llvm-7.0.1/bin/../lib/LLVMgold.so: error loading plugin: /home/username/llvm-7.0.1/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory

Any idea how can I fix that without compiling the source code with option that enables gold?

like image 428
masec Avatar asked Feb 11 '19 21:02

masec


People also ask

What is LLVMgold so?

LLVMgold uses the interface file plugin-api. h from gold which means that the resulting LLVMgold.so binary is also GPLv3. This can still be used to link non-GPLv3 programs just as much as gold could without the plugin.

Where is LLVM installed?

The binaries for LLVM tools are placed in ~/llvm/build/bin . These tools are used to run the LLVM passes. To make it easy to run the tools, it is a good idea to add the path to the binaries to the bash PATH variable so that you can invoke the tools from any directory.

Does GCC use LLVM?

How Is LLVM Different From GCC? LLVM and the GNU Compiler Collection (GCC) are both compilers. The difference is that GCC supports a number of programming languages while LLVM isn't a compiler for any given language. LLVM is a framework to generate object code from any kind of source code.


2 Answers

I received a similar error when linking with clang 13.0.0-2.

/usr/bin/ld: /usr/lib/llvm-13/bin/../lib/LLVMgold.so: error loading plugin: /usr/lib/llvm-13/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I ran apt search for llvmgold and found llvm-13-linker-tools recommended. Installing this made the issue go away.

sudo apt-get install llvm-13-linker-tools

I got clang simply via sudo apt-get install clang. Try looking for the llvm-7 equivalent.

like image 106
Ryan Maguire Avatar answered Oct 26 '22 00:10

Ryan Maguire


I received a similar error warning when trying to compile Python from sources with --with-lto option on Ubuntu 14. The easiest thing to do was to just remove the --with-lto flag during configuration.

like image 21
Nathan Moinvaziri Avatar answered Oct 26 '22 01:10

Nathan Moinvaziri