How to link object to libraries with LLVM >= 3.1 ?

2019-01-26 22:25发布

问题:

How I can generate a working executable with the tools provided with Llvm/Clang ( version 3.3 (trunk 168461) ) ?

I have compiled an object with clang++ -c [...] and i would like to try to link this object to 1 specific library and see if this can generate a working executable.

I have noticed that from the 3.1 release llvm-ld it's been removed and llvm-link doesn't look like it has inherited all the options from llvm-ld, although it's marked as the alternative to llvm-ld on the official docs, so i just don't get how I'm supposed to link this object.

I don't want to use ld from the GNU/GCC suite, only tools from llvm.

To summarize this are the tools that i have got from the llvm build from the svn

bugpoint      clang-check   llvm-bcanalyzer  llvm-extract   llvm-objdump  llvm-stress      scan-build
c++-analyzer  clang-tblgen  llvm-config      llvm-link      llvm-prof     llvm-symbolizer  scan-view
ccc-analyzer  llc           llvm-cov         llvm-lit       llvm-ranlib   llvm-tblgen      scanview.css
clang         lli           llvm-diff        llvm-mc        llvm-readobj  macho-dump       ScanView.py
clang++       llvm-ar       llvm-dis         llvm-mcmarkup  llvm-rtdyld   opt              sorttable.js
clang-3.3     llvm-as       llvm-dwarfdump   llvm-nm        llvm-size     Reporter.py      startfile.py

Thanks.

回答1:

There are no llvm linker at this time (yet). And no, llvm-link is not a replacement for LLVM ld. So, you'd need to use ar / ranlib / ld from your binutils for now.



回答2:

If you want to link LLVM bitcode files, you should have a look at the LLVM Gold Plugin : http://llvm.org/docs/GoldPlugin.html