]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tm.texi (DRIVER_SELF_SPECS): Document.
authorRichard Sandiford <rsandifo@redhat.com>
Mon, 14 Oct 2002 07:15:39 +0000 (07:15 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 14 Oct 2002 07:15:39 +0000 (07:15 +0000)
* doc/tm.texi (DRIVER_SELF_SPECS): Document.
* gcc.c (driver_self_specs): New variable.
(do_self_spec): New function.
(main): Use it to process driver_self_specs.

From-SVN: r58109

gcc/ChangeLog
gcc/doc/tm.texi
gcc/gcc.c

index 7bde8dd690e8e63cff505641c53a50b2d6c16660..4268d240a7a3a9484b2c9b22dcd5ee1225f37f6d 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-14  Richard Sandiford  <rsandifo@redhat.com>
+
+       * doc/tm.texi (DRIVER_SELF_SPECS): Document.
+       * gcc.c (driver_self_specs): New variable.
+       (do_self_spec): New function.
+       (main): Use it to process driver_self_specs.
+
 2002-10-13  Richard Henderson  <rth@redhat.com>
 
        * rtl.c (shallow_copy_rtx): Use memcpy for the entire node.
index a0396bc696569a2fdedc8d0be5a32491f73b3fc9..bf94d584a884c960f7ff4de9e2e3765aadc5b38f 100644 (file)
@@ -163,6 +163,23 @@ multilibs.  Example nonsensical definition, where @code{-malt-abi},
 @{ "-compat", "-EB -malign=4 -mspoo" @}
 @end smallexample
 
+@findex DRIVER_SELF_SPECS
+@item DRIVER_SELF_SPECS
+A list of specs for the driver itself.  It should be a suitable
+initializer for an array of strings, with no surrounding braces.
+
+The driver applies these specs to its own command line before choosing
+the multilib directory or running any subcommands.  It applies them in
+the order given, so each spec can depend on the options added by
+earlier ones.  It is also possible to remove options using
+@samp{%<@var{option}} in the usual way.
+
+This macro can be useful when a port has several interdependent target
+options.  It provides a way of standardizing the command line so
+that the other specs are easier to write.
+
+Do not define this macro if it does not need to do anything.
+
 @findex CPP_SPEC
 @item CPP_SPEC
 A C string constant that tells the GCC driver program options to
index 1018513f5c76ce64dc7099aa58fc3680ef776e8f..291712dcfa158b817189f64a4314cfdb6d863f78 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -296,6 +296,7 @@ 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 int do_spec_2           PARAMS ((const char *));
+static void do_self_spec       PARAMS ((const char *));
 static const char *find_file   PARAMS ((const char *));
 static int is_directory                PARAMS ((const char *, const char *, int));
 static void validate_switches  PARAMS ((const char *));
@@ -738,6 +739,12 @@ static const char *multilib_exclusions;
 
 static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS;
 
+#ifndef DRIVER_SELF_SPECS
+#define DRIVER_SELF_SPECS ""
+#endif
+
+static const char *const driver_self_specs[] = { DRIVER_SELF_SPECS };
+
 struct user_specs
 {
   struct user_specs *next;
@@ -4268,6 +4275,45 @@ do_spec_2 (spec)
   return do_spec_1 (spec, 0, NULL);
 }
 
+
+/* Process the given spec string and add any new options to the end
+   of the switches/n_switches array.  */
+
+static void
+do_self_spec (spec)
+     const char *spec;
+{
+  do_spec_2 (spec);
+  do_spec_1 (" ", 0, NULL);
+
+  if (argbuf_index > 0)
+    {
+      int i, first;
+
+      first = n_switches;
+      n_switches += argbuf_index;
+      switches = xrealloc (switches,
+                          sizeof (struct switchstr) * (n_switches + 1));
+
+      switches[n_switches] = switches[first];
+      for (i = 0; i < argbuf_index; i++)
+       {
+         struct switchstr *sw;
+
+         /* Each switch should start with '-'.  */
+         if (argbuf[i][0] != '-')
+           abort ();
+
+         sw = &switches[i + first];
+         sw->part1 = &argbuf[i][1];
+         sw->args = 0;
+         sw->live_cond = SWITCH_OK;
+         sw->validated = 0;
+         sw->ordering = 0;
+       }
+    }
+}
+
 /* Process the sub-spec SPEC as a portion of a larger spec.
    This is like processing a whole spec except that we do
    not initialize at the beginning and we do not supply a
@@ -5917,6 +5963,12 @@ main (argc, argv)
 
   process_command (argc, argv);
 
+  /* Process DRIVER_SELF_SPECS, adding any new options to the end
+     of the command line.  */
+
+  for (i = 0; i < ARRAY_SIZE (driver_self_specs); i++)
+    do_self_spec (driver_self_specs[i]);
+
   /* Initialize the vector of specs to just the default.
      This means one element containing 0s, as a terminator.  */