[llvm-dev] Compile assembly to llvm bitcode

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 18 12:05:04 PST 2020


If you are able to treat the assembly routines as calls to external
functions, you should be able to use LLD or gold for this use case instead
of llvm-link. In this case, the .s files will be compiled to native
objects, symbol resolution will occur as usual, LLD will perform an LTO
link, and there should be a way to get the fully linked and optimized
bitcode blob before it is compiled to a native object file. At the very
least, you can do this with -save-temps. I can't find a better way to do it
at the moment, although I see -lto-obj-path=, which controls where the
native object file goes.

On Mon, Feb 17, 2020 at 6:13 PM Anahit Hayrapetyan via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
>
> Is it possible to compile assembler source code to llvm bitcode? And if
> yes, then how?
>
> I’m trying to compile a project to llvm bitcode. The project has both C
> (.c) sources and some assembly(.S) sources. The make compiles all sources
> to object (.o) files and then links them together. What I’m trying to do is
> replace all commands compiling to .o with ‘clang -c -emit-llvm ...’ to get
> bitcodes and then use “llvm-link” to link them together in one .bc. However
> the llvm-link fails as the bitcodes I got from .s files are not recognized
> as llvm bitcodes (the header does not correspond to llvm bitcode header).
>
> Best,
> Anahit.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200218/c9b00234/attachment.html>


More information about the llvm-dev mailing list