Hi, 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' 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. 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. Any Help welcome ! Many thanks in advance, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090916/699f8570/attachment.html>
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.
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
On Fri, Sep 18, 2009 at 1:00 AM, Daniel Dunbar <daniel at zuster.org> wrote:>> 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. >-flto is documented command line options for llvm-gcc users to enable link time optimization (LTO). -emit-llvm was added for folks who has write access to llvm svn (IMO :). -emit-llvm is intentionally not documented in man page. -emit-llvm is not appropriate name to enable LTO, it does not follow usual gcc command line naming conversions and it was introduced before LTO. Yes, internally, -flto and -emit-llvm enables same functionality. However, -O4 is not same as -flto. -flto enables link time optimization but one can use various -Oblah flags to select compile time options. -O4 means -O3 + -flto. It would be OK to say -Os + -flto also, if code size is important. - Devang