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

Daniel Dunbar daniel at zuster.org
Fri Sep 18 01:00:58 PDT 2009

To add to what Duncan said,

On Wed, Sep 16, 2009 at 1:28 PM, Aaron Gray
<aaronngray.lists at googlemail.com> wrote:
> Hi,
> I have been trying to get to grips with GCC's specs language in order to add
> COFF and ELF emission options.

Good luck. :)

> 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'
> 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 LLVM code is as follows :-
> "%{O4|emit-llvm|flto:%{S:-emit-llvm} %{!S:-emit-llvm-bc %{c: %W{o*} %{!o*:-o
> %b%w.o}} %{!c:-o %d%w%u%O}}}"
> So we have '-O4', '-emit-llvm', and '-flto' equivalent options.

Yes, although they aren't actually equivalent, they definitely overlap
a lot. The distinctions are *mostly* pedantic though.

> 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.

As Duncan said, this doesn't make sense.

Is there any precedent for what this option should be called? I'd like
to agree on a design, since clang will eventually want the same thing.

Off the top of my head, I think the design "most compatible" with the
gcc driver design is to have '-integrated-asm' and
'-no-integrated-asm'. The object file format itself should be
determined by the target. Presumably -no-integrated-asm would start
off as the default, and eventually we would make it default when
everything works. -S would of course not use it.

As precedent, this conceptually matches -{no-,}integrated-cpp, for
example. The verbosity of the option shouldn't matter, since the
default should almost always be "right".

Unfortunately, implementing this in llvm-gcc is going to require
significant surgery, I think, although I haven't looked closely. It's
possible that you can just make the invoke_as 'spec' be empty if this
flag is present and have things just work, although you will still
have to work out the details of getting the correct output file to
cc1, suppressing the .s temporary files, etc.

It may even be worth mentioning whatever design we go with on the gcc
list, since we largely share the UI and they may want the same option
one day.

 - Daniel

More information about the llvm-dev mailing list