[cfe-dev] [clang] Implementing autolink with LLVM bitcode objects

Beren Minor via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 22 11:23:25 PST 2015


Hi there,

I am playing around with clang C++ Modules, trying to figure ou how it
could be leveraged to get rid of build systems on simple projects.

I want to use the link attribute in the modulemap to indicate which library
should be linked when a module is imported, however AFAIK the capability to
automatically add these flags to the link flags depends on the underlying
linker and the GNU linker doesn't support it.

At the moment I use LLVM bitcode as my object file format, because Clang
keeps the module link flags in a "Linker Options" attribute, and I can
parse the object files afterwards to extract these flags and add them to my
link command-line. Clang does then the lowering to native objects and the
actual native linker call.

I would like to simplify this, and I was thinking that Clang could parse
the object files itself if they are LLVM BC, and then pass the flags to the
linker if the link step is done in the same execution.

I have two way of doing it in mind, first way would be to have the driver
parse the objects and add the required flags to the link action, but maybe
it's not the right place to do that. Another way would be to add the linker
flags in some private ELF section during the compilation phase, and have
the link phase load them afterwards, which could work even without LLVM
bitcode intermediate.

Does that makes sense? Any thoughts, advices?
--
Beren Minor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151222/4b590b08/attachment.html>


More information about the cfe-dev mailing list