This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[basic-improvements] Specs syntax tweaks
- From: Zack Weinberg <zack at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 17 Sep 2002 22:31:55 -0700
- Subject: [basic-improvements] Specs syntax tweaks
This patch makes a number of tweaks to the spec syntax. The goal is
to get rid of the odder cases of %{...} so that I can add an N-way
choice syntax without going insane trying to keep everything working.
The simple changes:
%{<S} becomes %<S; Java front end modified to match
%{^S} exterminated; Ada front end taught to deal with
"-I directory" with a space
The hairier change: %| and %{|...} are gone. Instead we have a couple
more %g.s variants (%|.s and %m.s; I welcome suggestions of more
mnemonic letters) and a tm.h define to indicate which should be given
to the assembler. Also, a couple of places have been taught the gospel
of %(invoke_as).
I was hoping to be able to get rid of %{pipe:...} entirely, but it
still remains in a couple of places.
I'll be bootstrapping this overnight. Reactions?
The planned N-way choice syntax, by the way, is
%{ pat1 : repl1 ;
pat2 : repl2 ;
...
patN : replN ;
: default }
where the 'default' clause is optional, white space is insignificant,
and each 'patX' can be anything that can appear on the left side of a
colon in a %{X:Y} expression now.
zw
* gcc.c (use_pipes): New flag.
(process_command): Set it. Adjust check for -pipe conflicting
with -time or -save-temps.
(do_spec_1): Use it. Handle %|SUFFIX, %mSUFFIX, and
%<SWITCH. Drop %| (without a SUFFIX).
(handle_braces): Drop %{<SWITCH}, %{^SWITCH}, %{|...}.
(give_switch): Third argument eliminated.
(invoke_as, @assembler_with_cpp spec): Use %|.s or %m.s
depending on AS_NEEDS_DASH_FOR_PIPED_INPUT.
(specs documentation comment): Update.
* config/netbsd-aout.h, config/openbsd.h, config/ptx4.h,
config/svr4.h, config/i386/freebsd-aout.h,
config/m68k/netbsd-elf.h, config/m68k/netbsd.h,
config/m68k/openbsd.h, config/mips/openbsd.h,
config/sparc/sparc.h: Define AS_NEEDS_DASH_FOR_PIPED_INPUT
instead of putting %| into ASM_SPEC and/or ASM_FINAL_SPEC.
* config/avr/avr.h: Delete do-nothing ASM_FINAL_SPEC.
* config/cris/cris.h: Update comment.
* ada/lang-specs.h: Use %(invoke_as). Straighten out
error messages. Don't use %{^SWITCH}.
* ada/misc.c (gnat_decode_option): Handle -I with a
separate argument.
* f/lang-specs.h: Use %| and %m.
* java/jvspec.c: Use %m and %(invoke_as). Change all
uses of %{<SWITCH} to %<SWITCH.
* doc/invoke.texi: Update documentation of specs.
* doc/tm.texi: Document AS_NEEDS_DASH_FOR_PIPED_INPUT.
===================================================================
Index: gcc.c
--- gcc.c 10 Aug 2002 20:58:43 -0000 1.336
+++ gcc.c 18 Sep 2002 05:17:54 -0000
@@ -197,6 +197,11 @@ static int report_times;
static int save_temps_flag;
+/* Nonzero means use pipes to communicate between subprocesses.
+ Overridden by either of the above two flags. */
+
+static int use_pipes;
+
/* The compiler version. */
static const char *compiler_version;
@@ -294,7 +299,7 @@ static const char *find_file PARAMS ((co
static int is_directory PARAMS ((const char *, const char *, int));
static void validate_switches PARAMS ((const char *));
static void validate_all_switches PARAMS ((void));
-static void give_switch PARAMS ((int, int, int));
+static void give_switch PARAMS ((int, int));
static int used_arg PARAMS ((const char *, int));
static int default_arg PARAMS ((const char *, int));
static void set_multilib_dir PARAMS ((void));
@@ -354,6 +359,12 @@ or with constant text in a single argume
with a file name chosen once per compilation, without regard
to any appended suffix (which was therefore treated just like
ordinary text), making such attacks more likely to succeed.
+ %|SUFFIX
+ like %g, but if -pipe is in effect, expands simply to "-".
+ %mSUFFIX
+ like %g, but if -pipe is in effect, expands to nothing. (We have both
+ %| and %m to accommodate differences between system assemblers; see
+ the AS_NEEDS_DASH_FOR_PIPED_INPUT target macro.)
%uSUFFIX
like %g, but generates a new temporary file name even if %uSUFFIX
was already seen.
@@ -439,10 +450,15 @@ or with constant text in a single argume
%C process CPP_SPEC as a spec.
%1 process CC1_SPEC as a spec.
%2 process CC1PLUS_SPEC as a spec.
- %| output "-" if the input for the current command is coming from a pipe.
%* substitute the variable part of a matched option. (See below.)
Note that each comma in the substituted string is replaced by
a single space.
+ %<S remove all occurrences of -S from the command line.
+ Note - this command is position dependent. % commands in the
+ spec string before this one will see -S, % commands in the
+ spec string after this one will not.
+ %<S* remove all occurrences of all switches beginning with -S from the
+ command line.
%{S} substitutes the -S switch, if that switch was given to CC.
If that switch was not specified, this substitutes nothing.
Here S is a metasyntactic variable.
@@ -451,7 +467,6 @@ or with constant text in a single argume
arguments. CC considers `-o foo' as being one switch whose
name starts with `o'. %{o*} would substitute this text,
including the space; thus, two arguments would be generated.
- %{^S*} likewise, but don't put a blank between a switch and any args.
%{S*&T*} likewise, but preserve order of S and T options (the order
of S and T in the spec is not significant). Can be any number
of ampersand-separated variables; for each the wild card is
@@ -460,14 +475,8 @@ or with constant text in a single argume
specified to CC. Note that the tail part of the -S option
(i.e. the part matched by the `*') will be substituted for each
occurrence of %* within X.
- %{<S} remove all occurrences of -S from the command line.
- Note - this option is position dependent. % commands in the
- spec string before this option will see -S, % commands in the
- spec string after this option will not.
%{S:X} substitutes X, but only if the -S switch was given to CC.
%{!S:X} substitutes X, but only if the -S switch was NOT given to CC.
- %{|S:X} like %{S:X}, but if no S switch, substitute `-'.
- %{|!S:X} like %{!S:X}, but if there is an S switch, substitute `-'.
%{.S:X} substitutes X, but only if processing a file with suffix S.
%{!.S:X} substitutes X, but only if NOT processing a file with suffix S.
%{S|P:X} substitutes X if either -S or -P was given to CC. This may be
@@ -709,7 +718,11 @@ static const char *asm_options =
"%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
static const char *invoke_as =
-"%{!S:-o %{|!pipe:%g.s} |\n as %(asm_options) %{!pipe:%g.s} %A }";
+#ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT
+"%{!S:-o %|.s |\n as %(asm_options) %|.s %A }";
+#else
+"%{!S:-o %|.s |\n as %(asm_options) %m.s %A }";
+#endif
/* Some compilers have limits on line lengths, and the multilib_select
and/or multilib_matches strings can be very long, so we build them at
@@ -855,10 +868,19 @@ static const struct compiler default_com
"%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0},
{".S", "@assembler-with-cpp", 0},
{"@assembler-with-cpp",
+#ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT
+ "%(trad_capable_cpp) -lang-asm %(cpp_options)\
+ %{E|M|MM:%(cpp_debug_options)}\
+ %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\
+ as %(asm_debug) %(asm_options) %|.s %A }}}}"
+#else
"%(trad_capable_cpp) -lang-asm %(cpp_options)\
%{E|M|MM:%(cpp_debug_options)}\
- %{!M:%{!MM:%{!E:%{!S:-o %{|!pipe:%g.s} |\n\
- as %(asm_debug) %(asm_options) %{!pipe:%g.s} %A }}}}", 0},
+ %{!M:%{!MM:%{!E:%{!S:-o %|.s |\n\
+ as %(asm_debug) %(asm_options) %m.s %A }}}}"
+#endif
+ , 0},
+
#include "specs.h"
/* Mark end of table */
{0, 0, 0}
@@ -2918,7 +2940,7 @@ See %s for instructions.",
0 when initialized
1 if the switch is true in a conditional spec,
-1 if false (overridden by a later switch)
- -2 if this switch should be ignored (used in %{<S})
+ -2 if this switch should be ignored (used in %<S)
The `validated' field is nonzero if any spec has looked at this switch;
if it remains zero at the end of the run, it must be meaningless. */
@@ -3561,6 +3583,12 @@ warranty; not even for MERCHANTABILITY o
}
else if (strcmp (argv[i], "-time") == 0)
report_times = 1;
+ else if (strcmp (argv[i], "-pipe") == 0)
+ {
+ /* -pipe has to go into the switches array as well as setting a flag. */
+ use_pipes = 1;
+ n_switches++;
+ }
else if (strcmp (argv[i], "-###") == 0)
{
/* This is similar to -v except that there is no execution
@@ -3763,6 +3791,19 @@ warranty; not even for MERCHANTABILITY o
if (have_c && have_o && lang_n_infiles > 1)
fatal ("cannot specify -o with -c or -S and multiple compilations");
+ if ((save_temps_flag || report_times) && use_pipes)
+ {
+ /* -save-temps overrides -pipe, so that temp files are produced */
+ if (save_temps_flag)
+ error ("warning: -pipe ignored because -save-temps specified");
+ /* -time overrides -pipe because we can't get correct stats when
+ multiple children are running at once. */
+ else if (report_times)
+ error ("warning: -pipe ignored because -time specified");
+
+ use_pipes = 0;
+ }
+
/* Set up the search paths before we go looking for config files. */
/* These come before the md prefixes so that we will find gcc's subcommands
@@ -3927,17 +3968,6 @@ warranty; not even for MERCHANTABILITY o
;
else if (strcmp (argv[i], "-time") == 0)
;
- else if ((save_temps_flag || report_times)
- && strcmp (argv[i], "-pipe") == 0)
- {
- /* -save-temps overrides -pipe, so that temp files are produced */
- if (save_temps_flag)
- error ("warning: -pipe ignored because -save-temps specified");
- /* -time overrides -pipe because we can't get correct stats when
- multiple children are running at once. */
- else if (report_times)
- error ("warning: -pipe ignored because -time specified");
- }
else if (strcmp (argv[i], "-###") == 0)
;
else if (argv[i][0] == '-' && argv[i][1] != 0)
@@ -4074,7 +4104,7 @@ warranty; not even for MERCHANTABILITY o
infiles[n_infiles].name = 0;
}
-/* Store switches not filtered out by %{<S} in spec in COLLECT_GCC_OPTIONS
+/* Store switches not filtered out by %<S in spec in COLLECT_GCC_OPTIONS
and place that in the environment. */
static void
@@ -4267,13 +4297,12 @@ do_spec_1 (spec, inswitch, soft_matched_
if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|"))
{
- for (i = 0; i < n_switches; i++)
- if (!strcmp (switches[i].part1, "pipe"))
- break;
-
/* A `|' before the newline means use a pipe here,
but only if -pipe was specified.
Otherwise, execute now and don't pass the `|' as an arg. */
+ if (use_pipes)
+ break;
+
if (i < n_switches)
{
input_from_pipe = 1;
@@ -4502,10 +4531,10 @@ do_spec_1 (spec, inswitch, soft_matched_
{
struct stat st;
- /* If save_temps_flag is off, and the HOST_BIT_BUCKET is defined,
- and it is not a directory, and it is writable, use it.
- Otherwise, fall through and treat this like any other
- temporary file. */
+ /* If save_temps_flag is off, and the HOST_BIT_BUCKET is
+ defined, and it is not a directory, and it is
+ writable, use it. Otherwise, treat this like any
+ other temporary file. */
if ((!save_temps_flag)
&& (stat (HOST_BIT_BUCKET, &st) == 0) && (!S_ISDIR (st.st_mode))
@@ -4518,9 +4547,39 @@ do_spec_1 (spec, inswitch, soft_matched_
break;
}
}
+ goto create_temp_file;
+ case '|':
+ if (use_pipes)
+ {
+ obstack_1grow (&obstack, '-');
+ delete_this_arg = 0;
+ arg_going = 1;
+
+ /* consume suffix */
+ while (*p == '.' || ISALPHA ((unsigned char) *p))
+ p++;
+ if (p[0] == '%' && p[1] == 'O')
+ p += 2;
+
+ break;
+ }
+ goto create_temp_file;
+ case 'm':
+ if (use_pipes)
+ {
+ /* consume suffix */
+ while (*p == '.' || ISALPHA ((unsigned char) *p))
+ p++;
+ if (p[0] == '%' && p[1] == 'O')
+ p += 2;
+
+ break;
+ }
+ goto create_temp_file;
case 'g':
case 'u':
case 'U':
+ create_temp_file:
{
struct temp_name *t;
int suffix_length;
@@ -4603,7 +4662,7 @@ do_spec_1 (spec, inswitch, soft_matched_
for (t = temp_names; t; t = t->next)
if (t->length == suffix_length
&& strncmp (t->suffix, suffix, suffix_length) == 0
- && t->unique == (c != 'g'))
+ && t->unique == (c == 'u' || c == 'j'))
break;
/* Make a new association if needed. %u and %j
@@ -4624,7 +4683,7 @@ do_spec_1 (spec, inswitch, soft_matched_
}
else
t->suffix = save_string (suffix, suffix_length);
- t->unique = (c != 'g');
+ t->unique = (c == 'u' || c == 'j');
temp_filename = make_temp_file (t->suffix);
temp_filename_length = strlen (temp_filename);
t->filename = temp_filename;
@@ -5035,6 +5094,32 @@ do_spec_1 (spec, inswitch, soft_matched_
}
break;
+ /* Henceforth ignore the option(s) matching the pattern
+ after the %<. */
+ case '<':
+ {
+ unsigned len = 0;
+ int have_wildcard = 0;
+ int i;
+
+ while (p[len] && p[len] != ' ' && p[len] != '\t')
+ len++;
+
+ if (p[len-1] == '*')
+ have_wildcard = 1;
+
+ for (i = 0; i < n_switches; i++)
+ if (!strncmp (switches[i].part1, p, len - have_wildcard)
+ && (have_wildcard || switches[i].part1[len] == '\0'))
+ {
+ switches[i].live_cond = SWITCH_IGNORE;
+ switches[i].validated = 1;
+ }
+
+ p += len;
+ }
+ break;
+
case '*':
if (soft_matched_part)
{
@@ -5191,11 +5276,6 @@ do_spec_1 (spec, inswitch, soft_matched_
}
break;
- case '|':
- if (input_from_pipe)
- do_spec_1 ("-", 0, NULL);
- break;
-
default:
error ("spec failure: unrecognized spec option '%c'", c);
break;
@@ -5224,38 +5304,11 @@ handle_braces (p)
const char *p;
{
const char *filter, *body = NULL, *endbody = NULL;
- int pipe_p = 0;
int true_once = 0; /* If, in %{a|b:d}, at least one of a,b was seen. */
int negate;
int suffix;
- int include_blanks = 1;
- int elide_switch = 0;
int ordered = 0;
- if (*p == '^')
- {
- /* A '^' after the open-brace means to not give blanks before args. */
- include_blanks = 0;
- ++p;
- }
-
- if (*p == '|')
- {
- /* A `|' after the open-brace means,
- if the test fails, output a single minus sign rather than nothing.
- This is used in %{|!pipe:...}. */
- pipe_p = 1;
- ++p;
- }
-
- if (*p == '<')
- {
- /* A `<' after the open-brace means that the switch should be
- removed from the command-line. */
- elide_switch = 1;
- ++p;
- }
-
next_member:
negate = suffix = 0;
@@ -5267,26 +5320,16 @@ next_member:
if (*p == '.')
/* A `.' after the open-brace means test against the current suffix. */
{
- if (pipe_p)
- abort ();
-
suffix = 1;
++p;
}
- if (elide_switch && (negate || pipe_p || suffix))
- {
- /* It doesn't make sense to mix elision with other flags. We
- could fatal() here, but the standard seems to be to abort. */
- abort ();
- }
-
next_ampersand:
filter = p;
while (*p != ':' && *p != '}' && *p != '|' && *p != '&')
p++;
- if (*p == '|' && (pipe_p || ordered))
+ if (*p == '|' && ordered)
abort ();
if (!body)
@@ -5338,13 +5381,8 @@ next_member:
if (!strncmp (switches[i].part1, filter, p - 1 - filter)
&& check_live_switch (i, p - 1 - filter))
{
- if (elide_switch)
- {
- switches[i].live_cond = SWITCH_IGNORE;
- switches[i].validated = 1;
- }
- else
- ordered = 1, switches[i].ordering = 1;
+ ordered = 1;
+ switches[i].ordering = 1;
}
}
else
@@ -5384,7 +5422,7 @@ next_member:
{
do_spec_1 (string, 0, &switches[i].part1[hard_match_len]);
/* Pass any arguments this switch has. */
- give_switch (i, 1, 1);
+ give_switch (i, 1);
suffix_subst = NULL;
}
@@ -5431,26 +5469,14 @@ next_member:
conditional text. */
if (present != negate)
{
- if (elide_switch)
- {
- switches[i].live_cond = SWITCH_IGNORE;
- switches[i].validated = 1;
- }
- else if (ordered || *p == '&')
+ if (ordered || *p == '&')
ordered = 1, switches[i].ordering = 1;
else if (*p == '}')
- give_switch (i, 0, include_blanks);
+ give_switch (i, 0);
else
/* Even if many alternatives are matched, only output once. */
true_once = 1;
}
- else if (pipe_p)
- {
- /* Here if a %{|...} conditional fails: output a minus sign,
- which means "standard output" or "standard input". */
- do_spec_1 ("-", 0, NULL);
- return endbody;
- }
}
/* We didn't match; try again. */
@@ -5472,7 +5498,7 @@ next_member:
if (switches[i].ordering == 1)
{
switches[i].ordering = 0;
- give_switch (i, 0, include_blanks);
+ give_switch (i, 0);
}
}
/* Process the spec just once, regardless of match count. */
@@ -5568,16 +5594,12 @@ check_live_switch (switchnum, prefix_len
the vector of switches gcc received, which is `switches'.
This cannot fail since it never finishes a command line.
- If OMIT_FIRST_WORD is nonzero, then we omit .part1 of the argument.
-
- If INCLUDE_BLANKS is nonzero, then we include blanks before each argument
- of the switch. */
+ If OMIT_FIRST_WORD is nonzero, then we omit .part1 of the argument. */
static void
-give_switch (switchnum, omit_first_word, include_blanks)
+give_switch (switchnum, omit_first_word)
int switchnum;
int omit_first_word;
- int include_blanks;
{
if (switches[switchnum].live_cond == SWITCH_IGNORE)
return;
@@ -5595,8 +5617,7 @@ give_switch (switchnum, omit_first_word,
{
const char *arg = *p;
- if (include_blanks)
- do_spec_1 (" ", 0, NULL);
+ do_spec_1 (" ", 0, NULL);
if (suffix_subst)
{
unsigned length = strlen (arg);
===================================================================
Index: ada/lang-specs.h
--- ada/lang-specs.h 14 Mar 2002 10:59:29 -0000 1.3
+++ ada/lang-specs.h 18 Sep 2002 05:17:55 -0000
@@ -31,12 +31,13 @@
{".ads", "@ada", 0},
{".adb", "@ada", 0},
{"@ada",
- "gnat1 %{^I*} %{k8:-gnatk8} %{w:-gnatws} %1 %{!Q:-quiet} %{nostdinc*}\
+ "\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{!gnatc:%{!gnatz:%{!gnats:%{!S:%{!c:\
+ %eone of -c, -S, -gnatc, -gnatz, or -gnats is required for Ada}}}}}\
+ gnat1 %{I*} %{k8:-gnatk8} %{w:-gnatws} %1 %{!Q:-quiet} %{nostdinc*}\
-dumpbase %{.adb:%b.adb}%{.ads:%b.ads}%{!.adb:%{!.ads:%b.ada}}\
%{g*} %{O*} %{W*} %{w} %{p} %{pg:-p} %{m*} %{a} %{f*} %{d*}\
%{!S:%{o*:%w%*-gnatO}} \
- %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %i %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
- %{!S:%{!gnatc:%{!gnatz:%{!gnats:as %a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}\
- %{!c:%e-c or -S required for Ada}\
- %{!pipe:%g.s} %A\n}}}} ", 0},
+ %i %{S:%W{o*}%{!o*:-o %b.s}} \
+ %{!gnatc:%{!gnatz:%{!gnats:%(invoke_as)}}}", 0},
===================================================================
Index: ada/misc.c
--- ada/misc.c 30 Jul 2002 02:24:15 -0000 1.41
+++ ada/misc.c 18 Sep 2002 05:17:55 -0000
@@ -206,8 +206,8 @@ gnat_parse_file (set_yydebug)
/* Decode all the language specific options that cannot be decoded by GCC.
The option decoding phase of GCC calls this routine on the flags that
- it cannot decode. This routine returns 1 if it is successful, otherwise
- it returns 0. */
+ it cannot decode. This routine returns the number of consecutive arguments
+ from ARGV that it successfully decoded; 0 indicates failure. */
int
gnat_decode_option (argc, argv)
@@ -219,10 +219,28 @@ gnat_decode_option (argc, argv)
if (!strncmp (p, "-I", 2))
{
- /* Pass the -I switches as-is. */
- gnat_argv[gnat_argc] = p;
- gnat_argc ++;
- return 1;
+ /* We might get -I foo or -Ifoo. Canonicalize to the latter. */
+ if (p[2] == '\0')
+ {
+ char *q;
+
+ if (argv[1] == 0)
+ return 0;
+
+ q = xmalloc (sizeof("-I") + strlen (argv[1]));
+ strcpy (q, "-I");
+ strcat (q, argv[1]);
+
+ gnat_argv[gnat_argc] = q;
+ gnat_argc ++;
+ return 2; /* consumed argument */
+ }
+ else
+ {
+ gnat_argv[gnat_argc] = p;
+ gnat_argc ++;
+ return 1;
+ }
}
else if (!strncmp (p, "-gant", 5))
===================================================================
Index: config/netbsd-aout.h
--- config/netbsd-aout.h 28 Jul 2002 18:44:33 -0000 1.6
+++ config/netbsd-aout.h 18 Sep 2002 05:17:55 -0000
@@ -39,7 +39,9 @@ Boston, MA 02111-1307, USA. */
with the options for generating PIC code. */
#undef ASM_SPEC
-#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K}"
+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out. Here we
===================================================================
Index: config/openbsd.h
--- config/openbsd.h 31 Jul 2002 02:13:32 -0000 1.14
+++ config/openbsd.h 18 Sep 2002 05:17:55 -0000
@@ -106,15 +106,11 @@ Boston, MA 02111-1307, USA. */
still uses a special flavor of gas that needs to be told when generating
pic code. */
#undef ASM_SPEC
-#define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K} %|"
-
-#else
-/* Since we use gas, stdin -> - is a good idea, but we don't want to
- override native specs just for that. */
-#ifndef ASM_SPEC
-#define ASM_SPEC "%|"
-#endif
+#define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K}"
#endif
+
+/* Since we use gas, stdin -> - is a good idea. &/
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* LINK_SPEC appropriate for OpenBSD. Support for GCC options
-static, -assert, and -nostdlib. */
===================================================================
Index: config/ptx4.h
--- config/ptx4.h 17 Jul 2002 21:31:30 -0000 1.16
+++ config/ptx4.h 18 Sep 2002 05:17:55 -0000
@@ -93,16 +93,7 @@ Boston, MA 02111-1307, USA.
"-no_0f_fix -no_eflags_chk %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}"
#endif
-/* svr4 assemblers need the `-' (indicating input from stdin) to come after
- the -o option (and its argument) for some reason. If we try to put it
- before the -o option, the assembler will try to read the file named as
- the output file in the -o option as an input file (after it has already
- written some stuff to it) and the binary stuff contained therein will
- cause totally confuse the assembler, resulting in many spurious error
- messages. */
-
-#undef ASM_FINAL_SPEC
-#define ASM_FINAL_SPEC "%{pipe:-}"
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* Provide a LIB_SPEC appropriate for svr4. Here we tack on the default
standard C library (unless we are building a shared library). */
===================================================================
Index: config/svr4.h
--- config/svr4.h 17 Jul 2002 21:31:30 -0000 1.27
+++ config/svr4.h 18 Sep 2002 05:17:55 -0000
@@ -79,22 +79,16 @@ Boston, MA 02111-1307, USA.
Note that gcc doesn't allow a space to follow -Y in a -Ym,* or -Yd,*
option.
+
+ The svr4 assembler wants '-' on the command line if it's expected to
+ read its stdin.
*/
#undef ASM_SPEC
#define ASM_SPEC \
"%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}"
-/* svr4 assemblers need the `-' (indicating input from stdin) to come after
- the -o option (and its argument) for some reason. If we try to put it
- before the -o option, the assembler will try to read the file named as
- the output file in the -o option as an input file (after it has already
- written some stuff to it) and the binary stuff contained therein will
- cause totally confuse the assembler, resulting in many spurious error
- messages. */
-
-#undef ASM_FINAL_SPEC
-#define ASM_FINAL_SPEC "%|"
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* Under svr4, the normal location of the `ld' and `as' programs is the
/usr/ccs/bin directory. */
===================================================================
Index: config/avr/avr.h
--- config/avr/avr.h 17 Sep 2002 23:10:03 -0000 1.69
+++ config/avr/avr.h 18 Sep 2002 05:17:56 -0000
@@ -2530,14 +2530,6 @@ extern int avr_case_values_threshold;
pass to `cc1plus'. */
#define ASM_SPEC "%{mmcu=*:-mmcu=%*}"
-/* A C string constant that tells the GNU CC driver program options to
- pass to the assembler. It can also specify how to translate
- options you give to GNU CC into options for GNU CC to pass to the
- assembler. See the file `sun3.h' for an example of this.
-
- Do not define this macro if it does not need to do anything. */
-
-#define ASM_FINAL_SPEC ""
/* A C string constant that tells the GNU CC driver program how to
run any programs which cleanup after the normal assembler.
Normally, this is not needed. See the file `mips.h' for an
===================================================================
Index: config/cris/cris.h
--- config/cris/cris.h 17 Sep 2002 23:10:04 -0000 1.40
+++ config/cris/cris.h 18 Sep 2002 05:17:57 -0000
@@ -122,7 +122,7 @@ extern const char *cris_elinux_stacksize
someone will fight for us. This year in the mountains.
Note that for -melinux and -mlinux, command-line -isystem options are
emitted both before and after the synthesized one. We can't remove all
- of them: a %{<isystem} will only remove the first one and %{<isystem*}
+ of them: a %<isystem will only remove the first one and %<isystem*
will not do TRT. Those extra occurrences are harmless anyway. */
#define CPP_SPEC \
"-$ -D__CRIS_ABI_version=2\
===================================================================
Index: config/i386/freebsd-aout.h
--- config/i386/freebsd-aout.h 28 Jul 2002 18:44:34 -0000 1.13
+++ config/i386/freebsd-aout.h 18 Sep 2002 05:17:57 -0000
@@ -210,7 +210,8 @@ do {
ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
} while (0)
-#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}"
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
+#define ASM_SPEC "%{fpic:-k} %{fPIC:-k}"
#define LINK_SPEC \
"%{p:%e`-p' not supported; use `-pg' and gprof(1)} \
%{shared:-Bshareable} \
===================================================================
Index: config/m68k/netbsd-elf.h
--- config/m68k/netbsd-elf.h 8 Jun 2002 07:31:42 -0000 1.6
+++ config/m68k/netbsd-elf.h 18 Sep 2002 05:17:57 -0000
@@ -103,9 +103,11 @@ Boston, MA 02111-1307, USA. */
#undef ASM_SPEC
#define ASM_SPEC \
- " %| %(asm_default_spec) \
+ "%(asm_default_spec) \
%{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \
%{fpic:-k} %{fPIC:-k -K}"
+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */
===================================================================
Index: config/m68k/netbsd.h
--- config/m68k/netbsd.h 29 Aug 2002 21:40:13 -0000 1.11
+++ config/m68k/netbsd.h 18 Sep 2002 05:17:57 -0000
@@ -31,7 +31,9 @@
"%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} %(netbsd_cpp_spec)"
#undef ASM_SPEC
-#define ASM_SPEC " %| %{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* Make gcc agree with <machine/ansi.h> */
===================================================================
Index: config/m68k/openbsd.h
--- config/m68k/openbsd.h 29 Aug 2002 21:40:13 -0000 1.5
+++ config/m68k/openbsd.h 18 Sep 2002 05:17:57 -0000
@@ -38,7 +38,9 @@ Boston, MA 02111-1307, USA. */
/* m68k as needs to know about the processor subtype. */
#undef ASM_SPEC
-#define ASM_SPEC "%| %{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* Layout of source language data types. */
===================================================================
Index: config/mips/openbsd.h
--- config/mips/openbsd.h 11 Jun 2002 07:26:38 -0000 1.8
+++ config/mips/openbsd.h 18 Sep 2002 05:17:58 -0000
@@ -21,7 +21,9 @@ Boston, MA 02111-1307, USA. */
/* Definitions needed for OpenBSD, to avoid picking mips 'defaults'. */
/* GAS must know this. */
-#define SUBTARGET_ASM_SPEC "%{fPIC:-KPIC} %|"
+#define SUBTARGET_ASM_SPEC "%{fPIC:-KPIC}"
+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* CPP specific OpenBSD specs. */
#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC
===================================================================
Index: config/sparc/sparc.h
--- config/sparc/sparc.h 17 Sep 2002 21:36:29 -0000 1.210
+++ config/sparc/sparc.h 18 Sep 2002 05:17:59 -0000
@@ -323,8 +323,10 @@ Unrecognized value in TARGET_CPU_DEFAULT
/* Special flags to the Sun-4 assembler when using pipe for input. */
#define ASM_SPEC "\
-%| %{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \
+%{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \
%(asm_cpu) %(asm_relax)"
+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
/* This macro defines names of additional specifications to put in the specs
that can be used in various specifications like CC1_SPEC. Its definition
===================================================================
Index: doc/invoke.texi
--- doc/invoke.texi 17 Sep 2002 03:35:34 -0000 1.185
+++ doc/invoke.texi 18 Sep 2002 05:18:03 -0000
@@ -4644,13 +4644,22 @@ for each @samp{%g.s} and another for eac
simply substituted with a file name chosen for the previous @samp{%u},
without regard to any appended suffix.
-@item %j@var{SUFFIX}
+@item %j@var{suffix}
Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
writable, and if save-temps is off; otherwise, substitute the name
of a temporary file, just like @samp{%u}. This temporary file is not
meant for communication between processes, but rather as a junk
disposal mechanism.
+@item %|@var{suffix}
+@itemx %m@var{suffix}
+Like @samp{%g}, except if @option{-pipe} is in effect. In that case
+@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
+all. These are the two most common ways to instruct a program that it
+should read from standard input or write to standard output. If you
+need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
+construct: see for example @file{f/lang-specs.h}.
+
@item %.@var{SUFFIX}
Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
when it is subsequently output with @samp{%*}. @var{SUFFIX} is
@@ -4701,9 +4710,6 @@ the full name found.
Print @var{str} as an error message. @var{str} is terminated by a newline.
Use this when inconsistent options are detected.
-@item %|
-Output @samp{-} if the input for the current command is coming from a pipe.
-
@item %(@var{name})
Substitute the contents of spec string @var{name} at this point.
@@ -4800,6 +4806,12 @@ Substitute the variable part of a matche
Note that each comma in the substituted string is replaced by
a single space.
+@item %<@code{S}
+Remove all occurrences of @code{-S} from the command line. Note---this
+command is position dependent. @samp{%} commands in the spec string
+before this one will see @code{-S}, @samp{%} commands in the spec string
+after this one will not.
+
@item %@{@code{S}@}
Substitutes the @code{-S} switch, if that switch was given to GCC@.
If that switch was not specified, this substitutes nothing. Note that
@@ -4820,22 +4832,12 @@ GCC considers @option{-o foo} as being
one switch whose names starts with @samp{o}. %@{o*@} would substitute this
text, including the space. Thus two arguments would be generated.
-@item %@{^@code{S}*@}
-Like %@{@code{S}*@}, but don't put a blank between a switch and its
-argument. Thus %@{^o*@} would only generate one argument, not two.
-
@item %@{@code{S}*&@code{T}*@}
Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
(the order of @code{S} and @code{T} in the spec is not significant).
There can be any number of ampersand-separated variables; for each the
wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
-@item %@{<@code{S}@}
-Remove all occurrences of @code{-S} from the command line. Note---this
-command is position dependent. @samp{%} commands in the spec string
-before this option will see @code{-S}, @samp{%} commands in the spec
-string after this option will not.
-
@item %@{@code{S}*:@code{X}@}
Substitutes @code{X} if one or more switches whose names start with
@code{-S} are specified to GCC@. Note that the tail part of the
@@ -4847,12 +4849,6 @@ Substitutes @code{X}, but only if the @s
@item %@{!@code{S}:@code{X}@}
Substitutes @code{X}, but only if the @samp{-S} switch was @emph{not} given to GCC@.
-
-@item %@{|@code{S}:@code{X}@}
-Like %@{@code{S}:@code{X}@}, but if no @code{S} switch, substitute @samp{-}.
-
-@item %@{|!@code{S}:@code{X}@}
-Like %@{!@code{S}:@code{X}@}, but if there is an @code{S} switch, substitute @samp{-}.
@item %@{.@code{S}:@code{X}@}
Substitutes @code{X}, but only if processing a file with suffix @code{S}.
===================================================================
Index: doc/tm.texi
--- doc/tm.texi 17 Sep 2002 21:36:29 -0000 1.171
+++ doc/tm.texi 18 Sep 2002 05:18:06 -0000
@@ -216,6 +216,19 @@ an example of this.
Do not define this macro if it does not need to do anything.
+@findex AS_NEEDS_DASH_FOR_PIPED_INPUT
+@item AS_NEEDS_DASH_FOR_PIPED_INPUT
+Define this macro, with no value, if the driver should give the assembler
+an argument consisting of a single dash, @option{-}, to instruct it to
+read from its standard input (which will be a pipe connected to the
+output of the compiler proper). This argument is given after any
+@option{-o} option specifying the name of the output file.
+
+If you do not define this macro, the assembler is assumed to read its
+standard input if given no non-option arguments. If your assembler
+cannot read standard input at all, use a @samp{%@{pipe:%e@}} construct;
+see @file{mips.h} for instance.
+
@findex LINK_SPEC
@item LINK_SPEC
A C string constant that tells the GCC driver program options to
===================================================================
Index: f/lang-specs.h
--- f/lang-specs.h 20 Jun 2002 20:34:04 -0000 1.33
+++ f/lang-specs.h 18 Sep 2002 05:18:06 -0000
@@ -30,14 +30,14 @@ the Free Software Foundation, 59 Temple
{"@f77-cpp-input",
"cc1 -E -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
%{E|M|MM:%(cpp_debug_options)}\
- %{!M:%{!MM:%{!E:%{!pipe:%g.f} |\n\
- f771 %{!pipe:%g.f} %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}}}", 0},
+ %{!M:%{!MM:%{!E: %|.f |\n\
+ f771 %|.f %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}}}", 0},
{".r", "@ratfor", 0},
{"@ratfor",
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
ratfor %{C} %{CC} %{v} %i %{E:%W{o*}} %{!E: %{!pipe:-o %g.f} |\n\
- f771 %{!pipe:%g.f} %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}", 0},
+ f771 %m.f %(cc1_options) %{I*} %{!fsyntax-only:%(invoke_as)}}", 0},
{".f", "@f77", 0},
{".for", "@f77", 0},
{".FOR", "@f77", 0},
===================================================================
Index: java/jvspec.c
--- java/jvspec.c 23 Apr 2002 22:58:09 -0000 1.56
+++ java/jvspec.c 18 Sep 2002 05:18:06 -0000
@@ -55,28 +55,28 @@ int lang_specific_extra_outfiles = 0;
int shared_libgcc = 1;
static const char jvgenmain_spec[] =
- "jvgenmain %{D*} %b %{!pipe:%u.i} |\n\
- cc1 %{!pipe:%U.i} %1 \
+ "jvgenmain %{D*} %b %m.i |\n\
+ cc1 %m.i %1 \
%{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
%{g*} %{O*} \
%{v:-version} %{pg:-p} %{p}\
- %{<fbounds-check} %{<fno-bounds-check}\
- %{<fassume-compiled} %{<fno-assume-compiled}\
- %{<fcompile-resource*}\
- %{<femit-class-file} %{<femit-class-files} %{<fencoding*}\
- %{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\
- %{<findirect-dispatch} \
- %{<fno-store-check} %{<foutput-class-dir}\
- %{<fclasspath*} %{<fCLASSPATH*} %{<fbootclasspath*}\
- %{<fextdirs*}\
- %{<fuse-divide-subroutine} %{<fno-use-divide-subroutine}\
- %{<fcheck-references} %{<fno-check-references}\
- %{<ffilelist-file}\
+ %<fbounds-check %<fno-bounds-check\
+ %<fassume-compiled %<fno-assume-compiled\
+ %<fcompile-resource*\
+ %<femit-class-file %<femit-class-files %<fencoding*\
+ %<fuse-boehm-gc %<fhash-synchronization %<fjni\
+ %<findirect-dispatch \
+ %<fno-store-check %<foutput-class-dir\
+ %<fclasspath* %<fCLASSPATH* %<fbootclasspath*\
+ %<fextdirs*\
+ %<fuse-divide-subroutine %<fno-use-divide-subroutine\
+ %<fcheck-references %<fno-check-references\
+ %<ffilelist-file\
%{f*} -fdollars-in-identifiers\
%{aux-info*}\
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
- %{!S:as %a %Y -o %d%w%u%O %{!pipe:%g.s} %A\n }";
+ %{S:%W{o*}%{!o*:-o %b.s}}\
+ %(invoke_as)";
/* Return full path name of spec file if it is in DIR, or NULL if
not. */