Fix -undef option handling

Submitted by Joseph S. Myers on Sept. 24, 2010, 2:49 p.m.

Details

Message ID Pine.LNX.4.64.1009241448460.16899@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph S. Myers Sept. 24, 2010, 2:49 p.m.
My patch <http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00669.html>
broke building glibc because it taught the .opt machinery about the -u
option, as a driver option, causing the driver to treat "-undef" as
"-u ndef", so breaking the -undef option and causing the glibc build
process, when preprocessing shlib-versions files, to expand "linux" to
"1".  (In cases where an option on the command line matches multiple
.opt entries, one with the language matching is preferred to one where
it does not match.)

This patch fixes this by adding a "Driver" entry for the -undef
option.  Bootstrapped with no regressions on
x86_64-unknown-linux-gnu.  OK to commit?

2010-09-24  Joseph Myers  <joseph@codesourcery.com>

	* common.opt (undef): New.

testsuite:
2010-09-24  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/cpp/undef-opt-1.c: New test.

Comments

Richard Guenther Sept. 24, 2010, 3:04 p.m.
On Fri, Sep 24, 2010 at 4:49 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> My patch <http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00669.html>
> broke building glibc because it taught the .opt machinery about the -u
> option, as a driver option, causing the driver to treat "-undef" as
> "-u ndef", so breaking the -undef option and causing the glibc build
> process, when preprocessing shlib-versions files, to expand "linux" to
> "1".  (In cases where an option on the command line matches multiple
> .opt entries, one with the language matching is preferred to one where
> it does not match.)
>
> This patch fixes this by adding a "Driver" entry for the -undef
> option.  Bootstrapped with no regressions on
> x86_64-unknown-linux-gnu.  OK to commit?

Ok.

Thanks,
Richard.

> 2010-09-24  Joseph Myers  <joseph@codesourcery.com>
>
>        * common.opt (undef): New.
>
> testsuite:
> 2010-09-24  Joseph Myers  <joseph@codesourcery.com>
>
>        * gcc.dg/cpp/undef-opt-1.c: New test.
>
> Index: gcc/testsuite/gcc.dg/cpp/undef-opt-1.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/cpp/undef-opt-1.c      (revision 0)
> +++ gcc/testsuite/gcc.dg/cpp/undef-opt-1.c      (revision 0)
> @@ -0,0 +1,8 @@
> +/* Test -undef.  A bug in its handling broke glibc builds because
> +   "linux" was wrongly defined.  */
> +/* { dg-do preprocess } */
> +/* { dg-options "-undef" } */
> +
> +#ifdef linux
> +#error -undef broken
> +#endif
> Index: gcc/common.opt
> ===================================================================
> --- gcc/common.opt      (revision 164532)
> +++ gcc/common.opt      (working copy)
> @@ -1924,6 +1924,10 @@
>  u
>  Driver Joined Separate
>
> +undef
> +Driver
> +; C option, but driver must not handle as "-u ndef".
> +
>  v
>  Driver
>
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>

Patch hide | download patch | download mbox

Index: gcc/testsuite/gcc.dg/cpp/undef-opt-1.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/undef-opt-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/cpp/undef-opt-1.c	(revision 0)
@@ -0,0 +1,8 @@ 
+/* Test -undef.  A bug in its handling broke glibc builds because
+   "linux" was wrongly defined.  */
+/* { dg-do preprocess } */
+/* { dg-options "-undef" } */
+
+#ifdef linux
+#error -undef broken
+#endif
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 164532)
+++ gcc/common.opt	(working copy)
@@ -1924,6 +1924,10 @@ 
 u
 Driver Joined Separate
 
+undef
+Driver
+; C option, but driver must not handle as "-u ndef".
+
 v
 Driver