This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix optimizationa and target options of merged global constructors/destructors


Hi,
current merged global constructors and destructors are built without
any OPTIMIZATION and TARGET attributes. Unforutnately for Firefox 64
this leads to a binary that crashes at startup because it gets
autovectoried AVX instructions (and my CPU doesn't support them).

This is result of option merging in libwrapper picking them up because
Firefox contains a module build with avx enabled (some video decoding I
think).

This is fixed by copying optimization and target option from the first
constructor called. Bootstrapped/regtested x86_64-linux and commited to
mainline and gcc-8 branch. I will backport it to gcc-7 as well.

Honza

	* ipa.c (cgraph_build_static_cdtor_1): Add OPTIMIZATION and TARGET
	parameters.
	(cgraph_build_static_cdtor): Update.
	(build_cdtor): Use OPTIMIZATION and TARGET of the first real cdtor
	callsed.

Index: ipa.c
===================================================================
--- ipa.c	(revision 267141)
+++ ipa.c	(working copy)
@@ -854,7 +854,9 @@ ipa_discover_readonly_nonaddressable_var
    be produced. */
 
 static void
-cgraph_build_static_cdtor_1 (char which, tree body, int priority, bool final)
+cgraph_build_static_cdtor_1 (char which, tree body, int priority, bool final,
+			     tree optimization,
+			     tree target)
 {
   static int counter = 0;
   char which_buf[16];
@@ -885,6 +887,8 @@ cgraph_build_static_cdtor_1 (char which,
 
   TREE_STATIC (decl) = 1;
   TREE_USED (decl) = 1;
+  DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl) = optimization;
+  DECL_FUNCTION_SPECIFIC_TARGET (decl) = target;
   DECL_ARTIFICIAL (decl) = 1;
   DECL_IGNORED_P (decl) = 1;
   DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
@@ -949,7 +953,7 @@ cgraph_build_static_cdtor_1 (char which,
 void
 cgraph_build_static_cdtor (char which, tree body, int priority)
 {
-  cgraph_build_static_cdtor_1 (which, body, priority, false);
+  cgraph_build_static_cdtor_1 (which, body, priority, false, NULL, NULL);
 }
 
 /* When target does not have ctors and dtors, we call all constructor
@@ -1031,7 +1035,9 @@ build_cdtor (bool ctor_p, const vec<tree
       gcc_assert (body != NULL_TREE);
       /* Generate a function to call all the function of like
 	 priority.  */
-      cgraph_build_static_cdtor_1 (ctor_p ? 'I' : 'D', body, priority, true);
+      cgraph_build_static_cdtor_1 (ctor_p ? 'I' : 'D', body, priority, true,
+				   DECL_FUNCTION_SPECIFIC_OPTIMIZATION (cdtors[0]),
+				   DECL_FUNCTION_SPECIFIC_TARGET (cdtors[0]));
     }
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]