This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
3.0.2 PATCH: Don't pass elided switches to COLLECT_GCC_OPTIONS (version 2)
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Subject: 3.0.2 PATCH: Don't pass elided switches to COLLECT_GCC_OPTIONS (version 2)
- From: Rainer Orth <ro at TechFak dot Uni-Bielefeld dot DE>
- Date: Mon, 24 Sep 2001 17:09:45 +0200 (MEST)
- Cc: David Edelsohn <dje at watson dot ibm dot com>
This is an updated version of
http://gcc.gnu.org/ml/java-patches/2001-q3/msg00128.html
It fixes the bug (documented in PR other/3968) that lead to the reversal of
the previous version, as explained in
http://gcc.gnu.org/ml/gcc-bugs/2001-09/msg00616.html
and confirmed by David Edelsohn:
http://gcc.gnu.org/ml/gcc-bugs/2001-09/msg00619.html
This patch, together with
http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00983.html
survived a full bootstrap on alpha-dec-osf5.1 without regressions.
Ok for branch and mainline?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Email: ro@TechFak.Uni-Bielefeld.DE
Mon Sep 24 17:07:01 2001 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* gcc.c (set_collect_gcc_options): New function, split out from
main.
Ignore elided switches.
(do_spec): Invoke before executing command.
(do_spec_1): Likewise.
Fixes PR other/3968.
Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.205.2.20
diff -u -p -r1.205.2.20 gcc.c
--- gcc.c 2001/08/12 20:22:17 1.205.2.20
+++ gcc.c 2001/09/24 14:43:17
@@ -243,6 +243,7 @@ static void clear_failure_queue PARAMS (
static int check_live_switch PARAMS ((int, int));
static const char *handle_braces PARAMS ((const char *));
static char *save_string PARAMS ((const char *, int));
+static void set_collect_gcc_options PARAMS ((void));
static int do_spec_1 PARAMS ((const char *, int, const char *));
static const char *find_file PARAMS ((const char *));
static int is_directory PARAMS ((const char *, const char *, int));
@@ -3869,6 +3869,63 @@ process_command (argc, argv)
switches[n_switches].part1 = 0;
infiles[n_infiles].name = 0;
}
+
+/* Store switches not filtered out but %{<S} in spec in COLLECT_GCC_OPTIONS
+ and place that in the environment. */
+
+static void
+set_collect_gcc_options ()
+{
+ int i;
+ int first_time;
+
+ /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
+ the compiler. */
+ obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
+ sizeof ("COLLECT_GCC_OPTIONS=") - 1);
+
+ first_time = TRUE;
+ for (i = 0; (int) i < n_switches; i++)
+ {
+ const char *const *args;
+ const char *p, *q;
+ if (!first_time)
+ obstack_grow (&collect_obstack, " ", 1);
+
+ first_time = FALSE;
+
+ /* Ignore elided switches. */
+ if (switches[i].live_cond == SWITCH_IGNORE)
+ continue;
+
+ obstack_grow (&collect_obstack, "'-", 2);
+ q = switches[i].part1;
+ while ((p = strchr (q, '\'')))
+ {
+ obstack_grow (&collect_obstack, q, p - q);
+ obstack_grow (&collect_obstack, "'\\''", 4);
+ q = ++p;
+ }
+ obstack_grow (&collect_obstack, q, strlen (q));
+ obstack_grow (&collect_obstack, "'", 1);
+
+ for (args = switches[i].args; args && *args; args++)
+ {
+ obstack_grow (&collect_obstack, " '", 2);
+ q = *args;
+ while ((p = strchr (q, '\'')))
+ {
+ obstack_grow (&collect_obstack, q, p - q);
+ obstack_grow (&collect_obstack, "'\\''", 4);
+ q = ++p;
+ }
+ obstack_grow (&collect_obstack, q, strlen (q));
+ obstack_grow (&collect_obstack, "'", 1);
+ }
+ }
+ obstack_grow (&collect_obstack, "\0", 1);
+ putenv (obstack_finish (&collect_obstack));
+}
/* Process a spec string, accumulating and running commands. */
@@ -3942,6 +3999,8 @@ do_spec (spec)
if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|"))
argbuf_index--;
+ set_collect_gcc_options ();
+
if (argbuf_index > 0)
value = execute ();
}
@@ -4012,6 +4071,8 @@ do_spec_1 (spec, inswitch, soft_matched_
argbuf_index--;
}
+ set_collect_gcc_options ();
+
if (argbuf_index > 0)
{
value = execute ();
@@ -5567,52 +5628,6 @@ main (argc, argv)
Decode switches that are handled locally. */
process_command (argc, argv);
-
- {
- int first_time;
-
- /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
- the compiler. */
- obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
- sizeof ("COLLECT_GCC_OPTIONS=") - 1);
-
- first_time = TRUE;
- for (i = 0; (int) i < n_switches; i++)
- {
- const char *const *args;
- const char *p, *q;
- if (!first_time)
- obstack_grow (&collect_obstack, " ", 1);
-
- first_time = FALSE;
- obstack_grow (&collect_obstack, "'-", 2);
- q = switches[i].part1;
- while ((p = strchr (q, '\'')))
- {
- obstack_grow (&collect_obstack, q, p - q);
- obstack_grow (&collect_obstack, "'\\''", 4);
- q = ++p;
- }
- obstack_grow (&collect_obstack, q, strlen (q));
- obstack_grow (&collect_obstack, "'", 1);
-
- for (args = switches[i].args; args && *args; args++)
- {
- obstack_grow (&collect_obstack, " '", 2);
- q = *args;
- while ((p = strchr (q, '\'')))
- {
- obstack_grow (&collect_obstack, q, p - q);
- obstack_grow (&collect_obstack, "'\\''", 4);
- q = ++p;
- }
- obstack_grow (&collect_obstack, q, strlen (q));
- obstack_grow (&collect_obstack, "'", 1);
- }
- }
- obstack_grow (&collect_obstack, "\0", 1);
- putenv (obstack_finish (&collect_obstack));
- }
/* Initialize the vector of specs to just the default.
This means one element containing 0s, as a terminator. */