Bogus usage of gcc --print-file

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


steve crosby wrote:
>   gcc -dumpspecs | sed -e 's@ /lib/ld-linux.so.2@
> /tools/lib/ld-linux.so.2 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:

"-specs=file
     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/ld-linux.so.2@/tools&@g' \
     $SPECFILE > tempspecfile &&
mv -f tempspecfile $SPECFILE &&
unset SPECFILE

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

Regards,

Matt.
[1]http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Directory-Options.html#Directory-Options



More information about the lfs-dev mailing list