[LLVMdev] Preferring to use GCC instead of LLVM

Joachim Durchholz jo at durchholz.org
Tue May 13 03:05:28 PDT 2008


Am Sonntag, den 11.05.2008, 12:55 +1000 schrieb kr512:
> Alright, I read some more on llvm.org and it confirmed what 
> I was saying:
> http://www.llvm.org/docs/GettingStarted.html#tutorial
> 
> See at the end where it says:
> -----------
> 6.Compile the program to native assembly using the LLC code 
> generator:
>   % llc hello.bc -o hello.s
> 7.Assemble the native assembly language file into a program:
>   % gcc hello.s -o hello.native
> 8.Execute the native code program:
>   % ./hello.native
> -----------
> 
> See how gcc is invoked to generate the final executable 
> file.

gcc is called just as a compilation driver here. It looks into various
environment variables to check which specific flags need to be passed to
gas (assembler), what library paths to use, which flags to use for the
linker, and similar stuff.

This is valuable a Unixoid platforms where these things can vary, but
irrelevant on Windows. So on Windows, you can simply hardcode the calls
to assembler and linker and don't need to deliver gcc.

> This means LLVM is an incomplete backend, 
> unfortunately.

As is gcc.
The difference being that gcc is usually packaged with binutils.

You know you can compile binutils in standalone mode? That's the MinGW
ports - you need Cygwin to do this compilation, but the binaries that
come out at the end are standalone.

> Yes, but if you install the Microsoft development tools, 
> then you may as well just use them to do everything, and not 
> bother with LLVM.   But I would prefer to use LLVM.

Why, actually?
If we know what you're trying to achieve, we might be able to tell you
whether it's possible and how to do that, without calling names.

> Bill Wendling wrote:
> > I don't know about your computer, by mine comes with an 
> > assembler.
> 
> MS Windows does not come with an assembler, AFAIK.

It didn't when I last developed for Windows (five years ago).
I have no reason to believe that this changed.

So to roll an installation package that uses LLVM, you'd have to include
an assembler (and probably a linker, too).
A MinGW port of binutils should fill this gap.

> John Criswell wrote:
> > As other have stated, most systems come with an assembler 
> > (even GCC relies on an assembler to generate native code).
> 
> Correct me if I am wrong, but MS Windows does not come with 
> an assembler.

Both are correct, in a sense.
Most Unixoid systems do come with an assembler and linker.
Most if not all Windows systems don't.

>  The Microsoft development tools can be 
> obtained separately and installed, but that is too difficult 
> for an average end-user to do

Indeed. MS toolchains tend to require a large installation.

Though I recall that MS unbundled the compiler and linker and made them
both easy to install and freely available.
I don't know whether you could pass them on as part of your installation
package though.

Regards,
Jo




More information about the llvm-dev mailing list