Bug 51020 - %{...*; :default} spec lines cause all switches to be validated
Summary: %{...*; :default} spec lines cause all switches to be validated
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2011-11-08 01:54 UTC by Colin Watson
Modified: 2012-04-28 10:20 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed:

Reset starred flag patch. (446 bytes, patch)
2012-04-28 09:53 UTC, Alexey Kravets
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Watson 2011-11-08 01:54:20 UTC
This is a reduced test case from a cmake test failure manifesting on Ubuntu ARM (https://bugs.launchpad.net/bugs/887377):

$ gcc -v
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.2 (Ubuntu/Linaro 4.6.2-2ubuntu1)
$ cat specs
 %{mcpu=generic-*:-march=%*;   :%{mcpu=*:-mcpu=%*} %{march=*:-march=%*}}
$ gcc -specs=specs ---
gcc: fatal error: no input files
compilation terminated.
$ gcc ---
gcc: error: unrecognized option ‘---’
gcc: fatal error: no input files
compilation terminated.

cmake (which I'm not responsible for; I'm just trying to build it) has a facility to try to work out whether compiler options are valid, and apparently looks for "unrecognized option" on stderr.  I'm not exactly a fan of matching human-readable error output like this, but this spec line currently has the side-effect of validating all switches, and I don't think that can possibly be its intent.

This spec line was added in this commit:


I think the `validate_switches' function should only mark matching switches as valid if `len' is non-zero.
Comment 1 Colin Watson 2011-11-08 02:05:33 UTC
Looking more closely, I wonder if the problem here is that `starred' isn't getting reset.  This construction is effectively a switch statement, isn't it?  I can't see why the presence of an `mcpu=generic-*` case ought to imply that the default case should be treated as starred.  Perhaps `starred' should be reset upon encountering a ';' character?
Comment 2 joseph@codesourcery.com 2011-11-08 03:03:58 UTC
Note that in 4.7 all options will be validated by the .opt machinery 
(producing "gcc: error: unrecognized command line option '---'") by the 
driver and only options passing that (and -Wno-* options) will then go 
through the specs validation as well.  This may break things depending on 
the exact error message; it may also make this bug less significant 
because fewer cases will be left to be caught by the check against specs.
Comment 3 Alexey Kravets 2012-04-28 09:53:38 UTC
Created attachment 27259 [details]
Reset starred flag patch.

This patch seems to solve this problem. It has been tested on 4.6.3 (Linaro release) for ARM and showed no regressions.