Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use llvm linker?

Tags:

c++

llvm

LLVM provides 2 tools llvm-link and llvm-ld. I would like to know:

  • how merge all .o file in one ?

  • how set a soname like with gcc -Wl,-soname,libsomething.so.1 ?

I would like do this in c++ but if show to me how do that from command line i will found how do to do in c++.

thanks

like image 345
bioinfornatics Avatar asked Feb 02 '23 08:02

bioinfornatics


1 Answers

  • llvm-link is a tool for linking (~ merging) LLVM IR files into another LLVM IR file.
  • llvm-ld tries to be compatible to ld. Note that LLVM currently has no real linking capabilities, so llvm-ld calls gcc to do the actual final stages.

Note that if you just want to have GCC's functionality, use the clang driver:

clang -c file.c -fpic
clang -shared file.o -o file.so

You can also pass the -Wl flags to clang as you'd do for gcc:

clang -shared file.o -Wl,-soname,libfile.so.8 -o file.so
like image 77
Eli Bendersky Avatar answered Feb 06 '23 15:02

Eli Bendersky