[LLVMdev] [OT] GCC specs language and adding options

Duncan Sands baldrick at free.fr
Thu Sep 17 02:15:37 PDT 2009


Hi Aaron Gray,

> I have been trying to get to grips with GCC's specs language in order to 
> add COFF and ELF emission options.
> 
> I have noticed that the '-emit-llvm-bc' option does not appear to work 
> at all either with -S or without, giving :-
> 
>     llvm-gcc: unrecognized option '-emit-llvm-bc'

you should use -emit-llvm.  If used with -S then this gets passed to the
backend (cc1 for example) as -emit-llvm; if used with -c then it gets
passed as -emit-llvm-bc.  So -emit-llvm-bc is an internal flag that
users don't need to know about.

> Also this seems by default seems for '-emit-llvm' to produce a '.o' file 
> instead of a '.bc' file extension, unless using a '-o' option and 
> overriding the filename.

The output is placed in whatever output file gcc would normally use,
so .o if -emit-llvm is used with -c, .s if used with -S.  This is
needed to make lto transparent: if -emit-llvm caused .bc to be generated
rather than .o then that would break makefiles etc.  As it is you can
add -emit-llvm to your CFLAGS and have everything work without any
change to your makefile (assuming you have LLVM aware system tools, like
the gold linker).

> What I out like is either a '-emit-llvm-coff' and '-emit-llvm-elf' or 
> ideally an '-emit-llvm=coff' if this can be done transparently with an 
> '-emit-llvm' functioning normally.

This doesn't make much sense to me.  LLVM bitcode is the same whether
the final object file will be elf or coff.  Since -emit-llvm means to
output LLVM bitcode or LLVM assembler, elf/coff doesn't seem relevant.
Elf/coff is a codegen option.

Ciao,

Duncan.



More information about the llvm-dev mailing list