Hi!

On Tue, Jan 26, 2016 at 09:54:18PM +0100, Jakub Jelinek wrote:
> On Tue, Jan 26, 2016 at 04:44:39PM +0100, Jakub Jelinek wrote:
> > 2016-01-26  Jakub Jelinek  <ja...@redhat.com>
> > 
> >     PR lto/69254
> >     * lto-opts.c (lto_write_options): Write also -f{,no-}sanitize=
> >     options.
> >     * lto-wrapper.c (struct lto_decoded_options): New type.
> >     (append_option, merge_and_complain, append_compiler_options,
> >     append_linker_options, append_offload_options,
> >     compile_offload_image, compile_images_for_offload_targets,
> >     find_and_merge_options): Pass around options
> >     in struct lto_decoded_options instead of struct cl_decoded_option
> >     pointer and count pair.
> >     (get_options_from_collect_gcc_options): Likewise.  Parse -fsanitize=
> >     options and if in the end any ub sanitizers are enabled, set
> >     decoded_opts->sanitize_undefined to true.
> >     (run_gcc): Adjust callers of these functions.  If
> >     fdecoded_options.sanitize_undefined is true, append
> >     -fsanitize=shift after the linker options.
> 
> Now successfully bootstrapped/regtested on x86_64-linux and i686-linux.

After IRC discussions, I've bootstrapped/regtested following patch instead
and Richard pre-approved it on IRC, thus I've committed it to trunk:

2016-01-27  Jakub Jelinek  <ja...@redhat.com>

        PR lto/69254
        * sanitizer.def: Add BEGIN_SANITIZER_BUILTINS and
        END_SANITIZER_BUILTINS markers using DEF_BUILTIN_STUB.
        * asan.c (DEF_BUILTIN_STUB): Temporarily define.
        * tree-streamer-in.c: Include asan.h.
        (streamer_get_builtin_tree): For builtins in sanitizer
        range call initialize_sanitizer_builtins and retry.

--- gcc/sanitizer.def.jj        2016-01-04 14:55:53.000000000 +0100
+++ gcc/sanitizer.def   2016-01-27 16:12:47.285764673 +0100
@@ -20,12 +20,16 @@ along with GCC; see the file COPYING3.
 
 /* Before including this file, you should define a macro:
 
+     DEF_BUILTIN_STUB(ENUM, NAME)
      DEF_SANITIZER_BUILTIN (ENUM, NAME, TYPE, ATTRS)
 
    See builtins.def for details.
    The builtins are created by the C-family of FEs in c-family/c-common.c,
    for other FEs by asan.c.  */
 
+/* This has to come before all the sanitizer builtins.  */
+DEF_BUILTIN_STUB(BEGIN_SANITIZER_BUILTINS, (const char *)0)
+
 /* Address Sanitizer */
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_INIT, "__asan_init",
                      BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
@@ -515,3 +519,6 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HAN
 DEF_SANITIZER_BUILTIN(BUILT_IN_SANITIZER_COV_TRACE_PC,
                      "__sanitizer_cov_trace_pc",
                      BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
+
+/* This has to come after all the sanitizer builtins.  */
+DEF_BUILTIN_STUB(END_SANITIZER_BUILTINS, (const char *)0)
--- gcc/asan.c.jj       2016-01-04 14:55:52.000000000 +0100
+++ gcc/asan.c  2016-01-27 16:20:06.304809636 +0100
@@ -2370,6 +2370,8 @@ initialize_sanitizer_builtins (void)
   /* ECF_COLD missing */ ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST
 #undef ATTR_PURE_NOTHROW_LEAF_LIST
 #define ATTR_PURE_NOTHROW_LEAF_LIST ECF_PURE | ATTR_NOTHROW_LEAF_LIST
+#undef DEF_BUILTIN_STUB
+#define DEF_BUILTIN_STUB(ENUM, NAME)
 #undef DEF_SANITIZER_BUILTIN
 #define DEF_SANITIZER_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
   decl = add_builtin_function ("__builtin_" NAME, TYPE, ENUM,          \
@@ -2389,6 +2391,7 @@ initialize_sanitizer_builtins (void)
                           ATTR_PURE_NOTHROW_LEAF_LIST)
 
 #undef DEF_SANITIZER_BUILTIN
+#undef DEF_BUILTIN_STUB
 }
 
 /* Called via htab_traverse.  Count number of emitted
--- gcc/tree-streamer-in.c.jj   2016-01-25 12:10:59.000000000 +0100
+++ gcc/tree-streamer-in.c      2016-01-27 16:20:40.294348588 +0100
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.
 #include "builtins.h"
 #include "ipa-chkp.h"
 #include "gomp-constants.h"
+#include "asan.h"
 
 
 /* Read a STRING_CST from the string table in DATA_IN using input
@@ -1136,13 +1137,21 @@ streamer_get_builtin_tree (struct lto_in
        fatal_error (input_location,
                     "machine independent builtin code out of range");
       result = builtin_decl_explicit (fcode);
-      if (!result
-         && fcode > BEGIN_CHKP_BUILTINS
-         && fcode < END_CHKP_BUILTINS)
+      if (!result)
        {
-         fcode = (enum built_in_function) (fcode - BEGIN_CHKP_BUILTINS - 1);
-         result = builtin_decl_explicit (fcode);
-         result = chkp_maybe_clone_builtin_fndecl (result);
+         if (fcode > BEGIN_CHKP_BUILTINS && fcode < END_CHKP_BUILTINS)
+           {
+             fcode = (enum built_in_function)
+                     (fcode - BEGIN_CHKP_BUILTINS - 1);
+             result = builtin_decl_explicit (fcode);
+             result = chkp_maybe_clone_builtin_fndecl (result);
+           }
+         else if (fcode > BEGIN_SANITIZER_BUILTINS
+                  && fcode < END_SANITIZER_BUILTINS)
+           {
+             initialize_sanitizer_builtins ();
+             result = builtin_decl_explicit (fcode);
+           }
        }
       gcc_assert (result);
     }


        Jakub

Reply via email to