diff options
author | Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> | 2001-11-27 17:31:38 +0000 |
---|---|---|
committer | Rainer Orth <ro@gcc.gnu.org> | 2001-11-27 17:31:38 +0000 |
commit | b856c15d7e97280853a83042ccb3ba29c79e7e9f (patch) | |
tree | ee26d5564cb1ec6bb1e597398f2094f13bbfc5c2 /gcc/gcc.c | |
parent | ae08d4c0e94fd3f08cd1e47ed92b1fb1628f15e2 (diff) | |
download | gcc-b856c15d7e97280853a83042ccb3ba29c79e7e9f.zip gcc-b856c15d7e97280853a83042ccb3ba29c79e7e9f.tar.gz gcc-b856c15d7e97280853a83042ccb3ba29c79e7e9f.tar.bz2 |
re PR other/3968 (COLLECT_GCC_OPTIONS empty)
* 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.
* gcc.c (set_input): Export.
Move declaration ...
gcc.h (set_input): ... here.
java:
* jvspec.c (jvgenmain_spec): Cannot use %umain, breaks
ASM_FINAL_SPEC.
(lang_specific_pre_link): Use set_input to set input_filename.
Append `main' here.
* jvgenmain.c (usage): Append literal `main' to CLASSNAME.
(main): Fix definition.
Strip `main' from classname.
Fixes PR java/227.
From-SVN: r47385
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 111 |
1 files changed, 63 insertions, 48 deletions
@@ -286,6 +286,7 @@ static void clear_failure_queue PARAMS ((void)); 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)); @@ -309,7 +310,6 @@ static void process_command PARAMS ((int, const char *const *)); static int execute PARAMS ((void)); static void clear_args PARAMS ((void)); static void fatal_error PARAMS ((int)); -static void set_input PARAMS ((const char *)); #ifdef ENABLE_SHARED_LIBGCC static void init_gcc_specs PARAMS ((struct obstack *, const char *, @@ -3985,6 +3985,63 @@ process_command (argc, argv) switches[n_switches].part1 = 0; infiles[n_infiles].name = 0; } + +/* Store switches not filtered out by %{<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. */ @@ -4058,6 +4115,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 (); } @@ -4128,6 +4187,8 @@ do_spec_1 (spec, inswitch, soft_matched_part) argbuf_index--; } + set_collect_gcc_options (); + if (argbuf_index > 0) { value = execute (); @@ -5506,7 +5567,7 @@ is_directory (path1, path2, linker) /* Set up the various global variables to indicate that we're processing the input file named FILENAME. */ -static void +void set_input (filename) const char *filename; { @@ -5668,52 +5729,6 @@ main (argc, argv) 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. */ |