From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Edwards To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: c/2678: gcc/g++ should stick compilation options into the .o file Date: Sun, 29 Apr 2001 20:06:00 -0000 Message-id: <20010430030601.10725.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00736.html List-Id: The following reply was made to PR c/2678; it has been noted by GNATS. From: Phil Edwards To: "Ronald F. Guilmette" Cc: gcc-gnats@gcc.gnu.org Subject: Re: c/2678: gcc/g++ should stick compilation options into the .o file Date: Sun, 29 Apr 2001 21:41:04 -0400 On Sun, Apr 29, 2001 at 06:56:00PM -0000, Ronald F. Guilmette wrote: > My alopogies if my slippery fingers typed in `.command' when I intended > to write `.comment'. :-) > For documentation of the intended usage and format of data in ELF .note > and .comment sections, you will need to refer to the original AT&T docu- > mentation of ELF. [...] > but when I glanced again at the original AT&T documentation on ELF the other > day, it appears to me that the contents of .note is supposed to be, in > effect, a set of name/value pairs (vaguely reminicent of UNIX environment > variables). The required ``structure'' of the .note section just tells > you where and how to encode one of these name/value pairs, in general. Yep. Just before I left last night (er, this morning), I pulled up wotsit.org and grabbed the ELF 1.1 spec. Useful site, that. After some sleep, I've concluded that my original idea of using the print_switch_values routine might be stupid. I don't think people would like options passed: -iprefix -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -D__GNUG__=3 -D_GNU_SOURCE -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 options enabled: -fpeephole -ffunction-cse -fkeep-static-consts -fpcc-struct-return -fgcse-lm -fgcse-sm -fsched-interblock -fsched-spec -fbranch-count-reg -fexceptions -fcommon -fgnu-linker -fargument-alias -fident -fmath-errno -ftrapping-math -m80387 -mhard-float -mno-soft-float -mieee-fp -mfp-ret-in-387 showing up in their object files, for example. (Or do you?) The kicker is that the driver doesn't pass down the set of command-line options directly to the compiler. It does some translations on them, and then adds a bunch of defaults, and then passes /all/ of that down. See the "options passed" block above, for example; all of those are options to the compiler that the driver is inserting. If I had used -fomit-frame-pointer, for example, then that would be at the end of the list after the -D__*'s. (Side note: the "options enabled" block are everything that's on by default, as modified by the "options passed". If you really wanted to re-create the compilation environment for a particular file, you'd need to use all of those. The defaults might have changed.) The compiler does have available a save_argv and save_argc, but that's how the "options passed" block is constructed in the first place. We don't have any obvious way of distinguishing which options the user passed from the default ones added by the specs file. Phil -- pedwards at disaster dot jaj dot com | pme at sources dot redhat dot com devphil at several other less interesting addresses in various dot domains The gods do not protect fools. Fools are protected by more capable fools.