public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/48524] New: spec language does not cover switches with separated form
@ 2011-04-09  2:35 dirtyepic at gentoo dot org
  2011-04-09 11:28 ` [Bug driver/48524] " joseph at codesourcery dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-04-09  2:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

           Summary: spec language does not cover switches with separated
                    form
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dirtyepic@gentoo.org


Up until 4.6.0, we could write a simple spec rule for an arbitrary preprocessor
definition like:

%{!U_FORTIFY_SOURCE:-D_FORTIFY_SOURCE=2}

-D and -U flags have both joined and separate forms and the above rule worked
as long as the joined form was used.  This was good enough for the most part,
since the separate form is rare enough that I didn't even know it existed until
now.  As of 4.6.0, as outlined in PR47236, these flags are now regenerated in
their canonical, separate, form for specs processing with the benefit that
specs no longer have to handle the non-canonical cases.

The problem we have though, is that there doesn't actually seem to be any way
to write a spec rule for a switch substitution using the separated form, or at
least any that I've found.  The above rule no longer matches, and whitespace
and wildcard characters don't seem to be allowed in switch names.

I'd like to request that the spec language be extended to provide a way to
match separate-form switches, which would restore the functionality we need. 
This is both an enhancement request and, in my point of view, a regression,
since the loss of the ability to write specs matching preprocessor symbols has
broken several of our projects in ways that would be very difficult to fix
otherwise.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
@ 2011-04-09 11:28 ` joseph at codesourcery dot com
  2011-04-09 18:51 ` dirtyepic at gentoo dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2011-04-09 11:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-04-09 11:28:33 UTC ---
Specs are an internal GCC implementation detail, subject to change 
whenever convenient for implementation purposes.  (Whoever put 
documentation for them in invoke.texi was wrong to do so - and as far as I 
know, did not have FSF permission either for copying text from gcc.c under 
one license to invoke.texi under another - the comment starting "Specs are 
strings containing lines" is the proper documentation for specs.)  My 
recommendation in 
<http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01486.html> for certain 
broken -D specs in GCC was that any required semantics should be moved 
into cc1.  We have for a long time been moving away from defining built-in 
macros in specs, towards defining them based on actual logical state 
derived from option processing.  In any case if you wish to submit a patch 
for some new specs feature I would suggest you include the 
--enable-fortify-source=2 or similar configure option with it to provide 
some actual use for that feature in GCC.  Note that the spec you give 
appears wrong in that any -D_FORTIFY_SOURCE or -D_FORTIFY_SOURCE=<value> 
option passed by the user should presumably also disable a default 
-D_FORTIFY_SOURCE=2 option; maybe you actually want an 
if-macro-not-defined spec function that covers all these cases.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
  2011-04-09 11:28 ` [Bug driver/48524] " joseph at codesourcery dot com
@ 2011-04-09 18:51 ` dirtyepic at gentoo dot org
  2011-04-10  0:27 ` joseph at codesourcery dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-04-09 18:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

--- Comment #2 from Ryan Hill <dirtyepic at gentoo dot org> 2011-04-09 18:51:20 UTC ---
Sorry, i just wanted a trivial example.  The actual rule we use is 

%{!D_FORTIFY_SOURCE:%{!D_FORTIFY_SOURCE=*:%{!U_FORTIFY_SOURCE:-D_FORTIFY_SOURCE=2}}}

but this is just one example of several.  The reason we use specs instead of
just changing the default is so we can easily bypass them at runtime.  This
allows us, for example, to have a single compiler for both normal and hardened
profiles.

I understand what you're saying, but it still seems like an omission to me to
not have a way to match switches with separate arguments.  Surely this isn't
the only case where this is useful?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
  2011-04-09 11:28 ` [Bug driver/48524] " joseph at codesourcery dot com
  2011-04-09 18:51 ` dirtyepic at gentoo dot org
@ 2011-04-10  0:27 ` joseph at codesourcery dot com
  2011-04-12  2:22 ` vapier at gentoo dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2011-04-10  0:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-04-10 00:27:28 UTC ---
On Sat, 9 Apr 2011, dirtyepic at gentoo dot org wrote:

> Sorry, i just wanted a trivial example.  The actual rule we use is 
> 
> %{!D_FORTIFY_SOURCE:%{!D_FORTIFY_SOURCE=*:%{!U_FORTIFY_SOURCE:-D_FORTIFY_SOURCE=2}}}
> 
> but this is just one example of several.  The reason we use specs instead of
> just changing the default is so we can easily bypass them at runtime.  This
> allows us, for example, to have a single compiler for both normal and hardened
> profiles.
> 
> I understand what you're saying, but it still seems like an omission to me to
> not have a way to match switches with separate arguments.  Surely this isn't
> the only case where this is useful?

The same principle applies that if you wish to submit a patch to add such 
a feature it is desirable to have a (properly functional) use case in FSF 
GCC, as code with no such use case is liable to be removed in cleanups.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
                   ` (2 preceding siblings ...)
  2011-04-10  0:27 ` joseph at codesourcery dot com
@ 2011-04-12  2:22 ` vapier at gentoo dot org
  2011-04-13  3:49 ` dirtyepic at gentoo dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vapier at gentoo dot org @ 2011-04-12  2:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

Mike Frysinger <vapier at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |toolchain at gentoo dot org

--- Comment #4 from Mike Frysinger <vapier at gentoo dot org> 2011-04-12 02:22:12 UTC ---
a few test cases would cover that aspect i'd think


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
                   ` (3 preceding siblings ...)
  2011-04-12  2:22 ` vapier at gentoo dot org
@ 2011-04-13  3:49 ` dirtyepic at gentoo dot org
  2011-12-17 20:33 ` zorry at gentoo dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-04-13  3:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

Ryan Hill <dirtyepic at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
                   ` (4 preceding siblings ...)
  2011-04-13  3:49 ` dirtyepic at gentoo dot org
@ 2011-12-17 20:33 ` zorry at gentoo dot org
  2011-12-17 21:22 ` zorry at gentoo dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zorry at gentoo dot org @ 2011-12-17 20:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

--- Comment #5 from Magnus Granberg <zorry at gentoo dot org> 2011-12-17 20:30:17 UTC ---
Created attachment 26122
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26122
switches with separated form -D and -U

This patch make the -D and -U switches with separated form work in the spec
language. Tested on Gentoo with the spec as in comment 2.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
                   ` (5 preceding siblings ...)
  2011-12-17 20:33 ` zorry at gentoo dot org
@ 2011-12-17 21:22 ` zorry at gentoo dot org
  2011-12-18 20:46 ` zorry at gentoo dot org
  2012-02-08 21:38 ` jsm28 at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: zorry at gentoo dot org @ 2011-12-17 21:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

Magnus Granberg <zorry at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26122|0                           |1
        is obsolete|                            |

--- Comment #6 from Magnus Granberg <zorry at gentoo dot org> 2011-12-17 21:13:58 UTC ---
Created attachment 26124
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26124
switches with separated form -D and -U

fix typos in the last patch


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
                   ` (6 preceding siblings ...)
  2011-12-17 21:22 ` zorry at gentoo dot org
@ 2011-12-18 20:46 ` zorry at gentoo dot org
  2012-02-08 21:38 ` jsm28 at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: zorry at gentoo dot org @ 2011-12-18 20:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

Magnus Granberg <zorry at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26124|0                           |1
        is obsolete|                            |

--- Comment #7 from Magnus Granberg <zorry at gentoo dot org> 2011-12-18 20:11:32 UTC ---
Created attachment 26128
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26128
switches with separated form -D and -U

Same patch but with a testcase.
Tested on Gentoo with snapshot 4.7-20111217


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug driver/48524] spec language does not cover switches with separated form
  2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
                   ` (7 preceding siblings ...)
  2011-12-18 20:46 ` zorry at gentoo dot org
@ 2012-02-08 21:38 ` jsm28 at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-02-08 21:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48524

--- Comment #8 from Joseph S. Myers <jsm28 at gcc dot gnu.org> 2012-02-08 21:37:57 UTC ---
Author: jsm28
Date: Wed Feb  8 21:37:50 2012
New Revision: 184022

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184022
Log:
2012-02-08  Magnus Granberg  <zorry@gentoo.org>

    PR driver/48524
    * gcc.c (switch_matches) Support switches with separated form, -D
    and -U.

testsuite:
    * gcc.dg/pr48524.c: New test.
    * gcc.dg/pr48524.spec: New spec file for test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr48524.c
    trunk/gcc/testsuite/gcc.dg/pr48524.spec
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gcc.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-02-08 21:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-09  2:35 [Bug driver/48524] New: spec language does not cover switches with separated form dirtyepic at gentoo dot org
2011-04-09 11:28 ` [Bug driver/48524] " joseph at codesourcery dot com
2011-04-09 18:51 ` dirtyepic at gentoo dot org
2011-04-10  0:27 ` joseph at codesourcery dot com
2011-04-12  2:22 ` vapier at gentoo dot org
2011-04-13  3:49 ` dirtyepic at gentoo dot org
2011-12-17 20:33 ` zorry at gentoo dot org
2011-12-17 21:22 ` zorry at gentoo dot org
2011-12-18 20:46 ` zorry at gentoo dot org
2012-02-08 21:38 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).