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]

[PATCH] Fix PR41357


    Hi all,

  PR41357 is a bootstrap failure in libgomp.  There are undefined references
to the untransformed names of TLS emulation variables making their way into
the debug info, and this turns out to be because the thread-local status of
the decl is never reflected in the thread-local type bits of the derived
sym_ref's flags.  This ends up confusing the debug info generation, which
thinks that since the var is not thread-local it can predict the var's
constant value from the DECL_INITIAL.

  The obvious-seeming fix would be for default_encode_section_info to set
TLS_MODEL_EMULATED on sym_refs when the decl is thread-local and the backend
doesn't have_tls.  This certainly resolves the testcase and fixes bootstrap
with libgomp enabled on i686-pc-cygwin.  I'm now bootstrapping and testing it
on i686-pc-linux-gnu as well (since it takes several days for a full testsuite
run on cygwin).

  I'm not sure if I remember right, but isn't there a convention that we often
don't worry about adding testcases for bootstrap failures because the compiler
source itself acts as the testcase?  Otherwise there's a fairly reduced
testcase in the PR that I could add as a compile test; please advise.

gcc/ChangeLog:

	* varasm.c (default_encode_section_info): Set SYMBOL_REF_TLS_MODEL
	even for emulated tls.

  If there are no regressions, OK for HEAD?

    cheers,
      DaveK
Index: varasm.c
===================================================================
--- varasm.c	(revision 151703)
+++ varasm.c	(working copy)
@@ -6417,9 +6417,9 @@ default_encode_section_info (tree decl, rtx rtl, i
     flags |= SYMBOL_FLAG_FUNCTION;
   if (targetm.binds_local_p (decl))
     flags |= SYMBOL_FLAG_LOCAL;
-  if (targetm.have_tls && TREE_CODE (decl) == VAR_DECL
-      && DECL_THREAD_LOCAL_P (decl))
-    flags |= DECL_TLS_MODEL (decl) << SYMBOL_FLAG_TLS_SHIFT;
+  if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl))
+    flags |= (targetm.have_tls ? DECL_TLS_MODEL (decl) : TLS_MODEL_EMULATED)
+		<< SYMBOL_FLAG_TLS_SHIFT;
   else if (targetm.in_small_data_p (decl))
     flags |= SYMBOL_FLAG_SMALL;
   /* ??? Why is DECL_EXTERNAL ever set for non-PUBLIC names?  Without

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