lto-streamer.h (LTO_major_version): Bump to 5.
[gcc.git] / gcc / gcc.c
index 186f0aef91b9d7a58f5a793f564cf085cde7eddd..0f29b7870fb0ca07059a5a905f1e4694121b548e 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -41,7 +41,6 @@ compilation is specified by a string called a "spec".  */
 #include "flags.h"
 #include "opts.h"
 #include "params.h"
-#include "vec.h"
 #include "filenames.h"
 
 /* By default there is no special suffix for target executables.  */
@@ -737,12 +736,57 @@ proper position among the other output files.  */
 #endif
 #endif
 
+#ifdef ENABLE_DEFAULT_PIE
+#define NO_PIE_SPEC            "no-pie|static"
+#define PIE_SPEC               NO_PIE_SPEC "|r|shared:;"
+#define NO_FPIE1_SPEC          "fno-pie"
+#define FPIE1_SPEC             NO_FPIE1_SPEC ":;"
+#define NO_FPIE2_SPEC          "fno-PIE"
+#define FPIE2_SPEC             NO_FPIE2_SPEC ":;"
+#define NO_FPIE_SPEC           NO_FPIE1_SPEC "|" NO_FPIE2_SPEC
+#define FPIE_SPEC              NO_FPIE_SPEC ":;"
+#define NO_FPIC1_SPEC          "fno-pic"
+#define FPIC1_SPEC             NO_FPIC1_SPEC ":;"
+#define NO_FPIC2_SPEC          "fno-PIC"
+#define FPIC2_SPEC             NO_FPIC2_SPEC ":;"
+#define NO_FPIC_SPEC           NO_FPIC1_SPEC "|" NO_FPIC2_SPEC
+#define FPIC_SPEC              NO_FPIC_SPEC ":;"
+#define NO_FPIE1_AND_FPIC1_SPEC        NO_FPIE1_SPEC "|" NO_FPIC1_SPEC
+#define FPIE1_OR_FPIC1_SPEC    NO_FPIE1_AND_FPIC1_SPEC ":;"
+#define NO_FPIE2_AND_FPIC2_SPEC        NO_FPIE2_SPEC "|" NO_FPIC2_SPEC
+#define FPIE2_OR_FPIC2_SPEC    NO_FPIE2_AND_FPIC2_SPEC ":;"
+#define NO_FPIE_AND_FPIC_SPEC  NO_FPIE_SPEC "|" NO_FPIC_SPEC
+#define FPIE_OR_FPIC_SPEC      NO_FPIE_AND_FPIC_SPEC ":;"
+#else
+#define PIE_SPEC               "pie"
+#define NO_PIE_SPEC            PIE_SPEC "|r|shared:;"
+#define FPIE1_SPEC             "fpie"
+#define NO_FPIE1_SPEC          FPIE1_SPEC ":;"
+#define FPIE2_SPEC             "fPIE"
+#define NO_FPIE2_SPEC          FPIE2_SPEC ":;"
+#define FPIE_SPEC              FPIE1_SPEC "|" FPIE2_SPEC
+#define NO_FPIE_SPEC           FPIE_SPEC ":;"
+#define FPIC1_SPEC             "fpic"
+#define NO_FPIC1_SPEC          FPIC1_SPEC ":;"
+#define FPIC2_SPEC             "fPIC"
+#define NO_FPIC2_SPEC          FPIC2_SPEC ":;"
+#define FPIC_SPEC              FPIC1_SPEC "|" FPIC2_SPEC
+#define NO_FPIC_SPEC           FPIC_SPEC ":;"
+#define FPIE1_OR_FPIC1_SPEC    FPIE1_SPEC "|" FPIC1_SPEC
+#define NO_FPIE1_AND_FPIC1_SPEC        FPIE1_OR_FPIC1_SPEC ":;"
+#define FPIE2_OR_FPIC2_SPEC    FPIE2_SPEC "|" FPIC2_SPEC
+#define NO_FPIE2_AND_FPIC2_SPEC        FPIE1_OR_FPIC2_SPEC ":;"
+#define FPIE_OR_FPIC_SPEC      FPIE_SPEC "|" FPIC_SPEC
+#define NO_FPIE_AND_FPIC_SPEC  FPIE_OR_FPIC_SPEC ":;"
+#endif
+
 #ifndef LINK_PIE_SPEC
 #ifdef HAVE_LD_PIE
-#define LINK_PIE_SPEC "%{pie:-pie} "
+#define LD_PIE_SPEC "-pie"
 #else
-#define LINK_PIE_SPEC "%{pie:} "
+#define LD_PIE_SPEC ""
 #endif
+#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} "
 #endif
 
 #ifndef LINK_BUILDID_SPEC
@@ -771,12 +815,12 @@ proper position among the other output files.  */
 #define PLUGIN_COND_CLOSE ""
 #endif
 #define LINK_PLUGIN_SPEC \
-    "%{"PLUGIN_COND": \
+    "%{" PLUGIN_COND": \
     -plugin %(linker_plugin_file) \
     -plugin-opt=%(lto_wrapper) \
     -plugin-opt=-fresolution=%u.res \
     %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \
-    }"PLUGIN_COND_CLOSE
+    }" PLUGIN_COND_CLOSE
 #else
 /* The linker used doesn't support -plugin, reject -fuse-linker-plugin.  */
 #define LINK_PLUGIN_SPEC "%{fuse-linker-plugin:\
@@ -812,6 +856,10 @@ proper position among the other output files.  */
     %{fvtable-verify=preinit: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}}"
 #endif
 
+#ifndef CHKP_SPEC
+#define CHKP_SPEC ""
+#endif
+
 /* -u* was put back because both BSD and SysV seem to support it.  */
 /* %{static:} simply prevents an error message if the target machine
    doesn't handle -static.  */
@@ -832,6 +880,7 @@ proper position among the other output files.  */
    "%X %{o*} %{e*} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \
     %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
+    " CHKP_SPEC " \
     %{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
     %{fcilkplus:%:include(libcilkrts.spec)%(link_cilkrts)}\
     %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
@@ -1126,12 +1175,14 @@ static const struct compiler default_compilers[] =
                %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
                    cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
                        %(cc1_options)\
-                        %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
-                        %W{o*:--output-pch=%*}}%V}\
+                       %{!fsyntax-only:-o %g.s \
+                           %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+                                              %W{o*:--output-pch=%*}}%V}}\
          %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
                cc1 %(cpp_unique_options) %(cc1_options)\
-                    %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
-                    %W{o*:--output-pch=%*}}%V}}}}}}", 0, 0, 0},
+                   %{!fsyntax-only:-o %g.s \
+                       %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+                                          %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0},
   {".i", "@cpp-output", 0, 0, 0},
   {"@cpp-output",
    "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
@@ -3842,6 +3893,11 @@ driver_handle_option (struct gcc_options *opts,
       save_switch ("-o", 1, &arg, validated, true);
       return true;
 
+#ifdef ENABLE_DEFAULT_PIE
+    case OPT_pie:
+      /* -pie is turned on by default.  */
+#endif
+
     case OPT_static_libgcc:
     case OPT_shared_libgcc:
     case OPT_static_libgfortran:
@@ -4696,6 +4752,8 @@ do_self_spec (const char *spec)
            }
        }
 
+      free (decoded_options);
+
       alloc_switch ();
       switches[n_switches].part1 = 0;
     }
@@ -6880,52 +6938,6 @@ compare_files (char *cmpfile[])
   return ret;
 }
 
-/* The top-level "main" within the driver would be ~1000 lines long.
-   This class breaks it up into smaller functions and contains some
-   state shared by them.  */
-
-class driver
-{
- public:
-  int main (int argc, char **argv);
-
- private:
-  void set_progname (const char *argv0) const;
-  void expand_at_files (int *argc, char ***argv) const;
-  void decode_argv (int argc, const char **argv);
-  void global_initializations ();
-  void build_multilib_strings () const;
-  void set_up_specs () const;
-  void putenv_COLLECT_GCC (const char *argv0) const;
-  void maybe_putenv_COLLECT_LTO_WRAPPER () const;
-  void maybe_putenv_OFFLOAD_TARGETS () const;
-  void handle_unrecognized_options () const;
-  int maybe_print_and_exit () const;
-  bool prepare_infiles ();
-  void do_spec_on_infiles () const;
-  void maybe_run_linker (const char *argv0) const;
-  void final_actions () const;
-  int get_exit_code () const;
-
- private:
-  char *explicit_link_files;
-  struct cl_decoded_option *decoded_options;
-  unsigned int decoded_options_count;
-};
-
-/* Implement the top-level "main" within the driver in terms of
-   driver::main.  */
-
-extern int main (int, char **);
-
-int
-main (int argc, char **argv)
-{
-  driver d;
-
-  return d.main (argc, argv);
-}
-
 /* driver::main is implemented as a series of driver:: method calls.  */
 
 int
@@ -9463,3 +9475,39 @@ convert_white_space (char *orig)
   else
     return orig;
 }
+
+/* PR jit/64810.
+   Targets can provide configure-time default options in
+   OPTION_DEFAULT_SPECS.  The jit needs to access these, but
+   they are expressed in the spec language.
+
+   Run just enough of the driver to be able to expand these
+   specs, and then call the callback CB on each
+   such option.  The options strings are *without* a leading
+   '-' character e.g. ("march=x86-64").  Finally, clean up.  */
+
+void
+driver_get_configure_time_options (void (*cb) (const char *option,
+                                              void *user_data),
+                                  void *user_data)
+{
+  size_t i;
+
+  obstack_init (&obstack);
+  gcc_obstack_init (&opts_obstack);
+  n_switches = 0;
+
+  for (i = 0; i < ARRAY_SIZE (option_default_specs); i++)
+    do_option_spec (option_default_specs[i].name,
+                   option_default_specs[i].spec);
+
+  for (i = 0; (int) i < n_switches; i++)
+    {
+      gcc_assert (switches[i].part1);
+      (*cb) (switches[i].part1, user_data);
+    }
+
+  obstack_free (&opts_obstack, NULL);
+  obstack_free (&obstack, NULL);
+  n_switches = 0;
+}