AW: default specs file

Warlich, Christof
Thu Nov 26 15:36:00 GMT 2015

Looking at gcc/gcc.c, it seems that specs files passed to gcc though the -specs switch are handled differently _on_ _purpose_  compared with default specs files:

In the first (good) case, the function read_specs(const char *specs, bool main_p, bool user_p) is called with

read_specs(specsfile, false, true);

while it is called like

read_specs(specsfile, true, false);

with the default specs file. And when parsing the specs file within that function the second way, several documented features in the specs file are considered invalid, e.g. the %rename command, as it does not end with a colon.

Could anyone please tell if this is either a bug or intended behavior?

-----Ursprüngliche Nachricht-----
Von: Warlich, Christof 
Gesendet: Mittwoch, 25. November 2015 11:42
An: gcc-help (
Betreff: default specs file


I see a rather unexpected behavior when using a default specs file:

1) Check if the builtin spec is used initially:
$ gcc -v 2>&1  | grep specs
Using built-in specs.

2) Copy the builtin spec to the location of default specs file:
$ sudo bash -c "gcc -dumpspecs >$(dirname $(gcc -print-libgcc-file-name))/specs"

3) Check if the newly created default spec is used now:
$ gcc -v 2>&1  | grep specs
Reading specs from /usr/lib/gcc/x86_64-linux-gnu/4.8/specs

4) Adding a custom gcc command-line switch (--myswitch) by appending
at the end of the *cpp: section of the default specs file.

5) Testing the new switch:
$ gcc --myswitch  -xc -c /dev/null
gcc: error: unrecognized command line option '--myswitch'

6) But when passing the specs file explicitly, everything works as expected:
$ rm -f /tmp/tst.o
$ gcc --myswitch  -xc -c -specs=$(dirname $(gcc -print-libgcc-file-name))/specs /dev/null -o /tmp/tst.o
$ ls /tmp/tst.o

To sum up: The modification of the specs file (i.e. adding a custom command line switch) works as expected when passing the specs file to gcc though its -specs option, but seems to be ignored if read from the default specs file.

Did I ran into a gcc bug? Or is this the intended behavior, and if so, why does gcc -v tells me that it is reading from the modified default specs file but then obviously ignores it?

Thanks for any suggestions,


More information about the Gcc-help mailing list