Subject: Re: How can I get llvm-as for Ubuntu?
Date: Thursday 6th February 2014 06:11:17 UTC (over 4 years ago)
> Andrew Pennebaker wrote: > > I used to be able to `apt-get install llvm` to install `llvm-as`, an > > LLVM assembler. I think some tools/packages have moved around since > then. > > > > What can I use to compile `.ll` assembler files into executables? > > You'll have to ask your distributor about how llvm is packaged, but I can > answer about what the tools are. > > llvm-as converts .ll to .bc. The formats are equivalent except that the former > is human readable and the latter is machine readable. They are both LLVM IR > (llvm's assembly format) not native machine code. > > llc converts .ll or .bc to .s (native assembly) or .o files (native object file). > These are what you commonly get out of a compiler, and must be linked to > form an executable. > > llvm-mc converts between .s and .o. It is a native assembler and > disassembler. > > Given a set of .o files, you need to (native) link them to form an executable. > LLVM proper does not include a native linker. (llvm-link is not one, it > combines multiple .bc files into a single .bc file. You'll still need a native > linker.) There is the lld.llvm.org project which you can use to link, if you want > to use llvm parts. > > So I think the answer you want is "llc foo.ll -filetype=obj -o foo.o" > and then you link foo.o with "ld" on your system. > > Nick You don't really need to go to that much effort, possibly unless you're cross-compiling or doing something else weird. Clang will happily accept any mixture of regular object files and bitcode (in either .bc or .ll format) and drive the process to completion. With the default Ubuntu 12.04 clang package (3.0 I think?) -------- file world.c -------------- #include