thoughts on a new switch, -print-flags ?

Phil Edwards pedwards@disaster.jaj.com
Wed Nov 22 15:17:00 GMT 2000


A -print-flags switch to the driver and compilers would show which internal
flags are turned on by default, and by other command line switches.
Currently we can see such information only with '-v -Q', which also dumps
out a ton of other verbose info, and requires you to be actually compiling
something.

Doing this is simple, but doing it /completely/ also involves changes to
each front-end.

The print_switch_values() function in toplev.c is doing the real work so
far; I'd thought about creating sorted output instead, but that sounds like
overkill.  The only deficiency in this function is that the lang-specific
flags aren't looked at.  I have some thoughts on how to do that, but wanted
to hear any thoughts first.

Here are two examples of what's working so far.  I'm thinking about not
printing the "options passed" block or the "options enabled:" title;
print_switch_values() prints both in "-v -Q" mode.

    % install/bin/gcc -print-flags
    options passed:  -lang-c -iprefix -D__GNUC__=2 -D__GNUC_MINOR__=97
     -D__GNUC_PATCHLEVEL__=0 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4
     -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun
     -D__unix -Asystem=unix -Asystem=svr4 -D__STDC_HOSTED__=1
     -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc
    options enabled:  -fpeephole -ffunction-cse -fkeep-static-consts
     -fpcc-struct-return -fsched-interblock -fsched-spec -fbranch-count-reg
     -fnew-exceptions -fcommon -fgnu-linker -fargument-alias -fident
     -fmath-errno -mepilogue

    % install/bin/gcc --print-flags -O3
    options passed:  -lang-c -iprefix -D__GNUC__=2 -D__GNUC_MINOR__=97
     -D__GNUC_PATCHLEVEL__=0 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4
     -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun
     -D__unix -Asystem=unix -Asystem=svr4 -D__OPTIMIZE__ -D__STDC_HOSTED__=1
     -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc -O3
    options enabled:  -fdefer-pop -fomit-frame-pointer -foptimize-sibling-calls
     -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations
     -fthread-jumps -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse
     -finline-functions -finline -fkeep-static-consts -fcaller-saves
     -fpcc-struct-return -fdelayed-branch -fgcse -frerun-cse-after-loop
     -frerun-loop-opt -fdelete-null-pointer-checks -fschedule-insns
     -fschedule-insns2 -fsched-interblock -fsched-spec -fbranch-count-reg
     -fnew-exceptions -freorder-blocks -frename-registers -fcommon -fgnu-linker
     -fregmove -foptimize-register-move -fargument-alias -fstrict-aliasing
     -fident -fpeephole2 -fmath-errno -mepilogue

Okay, there's all the stuff turned on by -O3; maybe a good way to check the
corresponding documentation.

    % install/bin/g++ -print-flags
    options passed:  -lang-c -iprefix -D__GNUC__=2 -D__GNUC_MINOR__=97
     -D__GNUC_PATCHLEVEL__=0 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4
     -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun
     -D__unix -Asystem=unix -Asystem=svr4 -D__STDC_HOSTED__=1
     -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc -fnew-abi
    options enabled:  -fpeephole -ffunction-cse -fkeep-static-consts
     -fpcc-struct-return -fsched-interblock -fsched-spec -fbranch-count-reg
     -fnew-exceptions -fcommon -fgnu-linker -fargument-alias -fident
     -fmath-errno -mepilogue

Here in another front-end, -fnew-abi shows up in 'passed' but not 'enabled',
which is documented behavior for print_switch_values().

Before I start hacking on language-specific stuff, does this sound like
a worthwhile option?


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.



More information about the Gcc mailing list