Bogus usage of gcc --print-file

Matthew Burgess matthew at
Tue Aug 16 14:09:03 PDT 2005

steve crosby wrote:
>   gcc -dumpspecs | sed -e 's@ /lib/
> /tools/lib/ at g' > tempfile
>   gcc -specs=tempfile

I'm not sure that does what you think it does.  If I'm reading the 
manual[1] correctly, the -specs flag is a runtime option to control what 
specs the compiler uses for that particular invocation.  It overrides 
the default specs that would normally be used, but I don't think it 
updates those default specs.  Here's the relevant snippet:

     Process file after the compiler reads in the standard specs file, 
in order to override the defaults that the gcc driver program uses when 
determining what switches to pass to cc1, cc1plus, as, ld, etc. More 
than one -specs=file can be specified on the command line, and they are 
processed in order, from left to right."

Therefore, in order to change GCC's default specs file, I still think we 
need to 1) dump them (as gcc-4.x no longer installs a specs file) 2) 
change the relevant specs and 3) Place the updated specs file in 
whatever directory GCC searches for its default specs in.  So, the 
incantation for gcc-4 becomes:

SPECFILE=`gcc -print-file-name=specs` &&
gcc -dumpspecs > $SPECFILE &&
sed 's@^/lib/' \
     $SPECFILE > tempspecfile &&
mv -f tempspecfile $SPECFILE &&

For 3.4.x compilers, we can remove the dumpspecs call and change the '^' 
to a ' ' in the sed.



More information about the lfs-dev mailing list