9

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

1
  • What exactly are you trying to do? Link object files or LLVM bitcode files? Create an .so? Feb 7, 2012 at 2:20

1 Answer 1

12
  • 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
3
  • 3
    To add to this, please don't use llvm-ld directly. Heck, please don't ever use any linker directly unless you know exactly what you're doing and you don't have a compiler driver to handle it for you.
    – echristo
    Feb 9, 2012 at 19:15
  • 4
    Just a hint, on Mac, use '-dynamiclib' to replace '-shared ....-Wl,-soname,libxxxxx' part
    – clsung
    Oct 18, 2012 at 2:38
  • 4
    LLVM currently has no real linking capabilities. Is it still the case? (Note lld.llvm.org)
    – Antonio
    Mar 2, 2016 at 16:10

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.