[LLVMdev] Need help with generating executables from llvm

Duncan Sands baldrick at free.fr
Mon Nov 26 09:16:25 PST 2012

Hi Chinmaya,

>    We are using llvm for our project on code generation and we are stuck at
> something very simple but hard to find on the internet. Hence the mail. We need
> to generate .out (executables that can run on linux) from .s file. We are right
> now trying it out on coreutils package(who, ls etc). We have generated who.bc,
> who.s using llvm tools but are unable to get an executable from the .s (rather
> we dont know how to).

gcc who.s

You may need to add libraries, eg

gcc who.s -lm

Your other methods can work too:

> We tried
> 1) llvm-ld (llvm-ld: warning: Ignoring file 'who.bc' because does not contain
> bitcode.).

If who.bc doesn't contain bitcode, what does it contain?  This should work
(with the -native flag) is who.bc contains bitcode.

> 2) llc -filetype=obj who.bc , followed by ./who.o  (bash: ./who.o: cannot
> execute binary file)

You still need to link the .o.  For example:

gcc who.o

You may need to add libraries, eg

gcc who.o -lm

As you can see this is basically the same as for the .s, because a .s is just a
human readable form of a .o really.

Ciao, Duncan.

> The above actually carry out .bc to .o translation. We are more interested in .s
> to .o
>   We saw this mail on the website and found out we were stuck at kind of the
> same spot. http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-May/050143.html
> Can you help us with it or maybe direct us to a verbose documentation of how
> executables are generated?
> --
> Chinmaya Dattathri
> cd25658
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list