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]

Re: [PATCH] Fix TLS support on SPARC/Solaris with native tools


> OTOH, it has been accepted in gas for about a year now, so I'd
> be comfortable updating binutils requirements.  Either you know
> tls_object or you don't get tls.  You just have to add that to
> the things checked by configure.

I'd rather not annoy 99% of the users with my private problems :-)

> > What about tweaks in sparc/sol2-bi.h and sparc/sol2-gas-bi.h instead?
>
> If you like.

Here is a simple patch.  Bootstrapped/regtested on various SPARC/Solaris and 
SPARC64/Solaris platforms, featuring or not TLS support (with Jan's patch 
reverted of course).

OK for mainline and 3.4 branch?


2004-01-17  Eric Botcazou  <ebotcazou@libertysurf.fr>

	* config/sparc/sol2-bi.h (ASM_DECLARE_OBJECT_NAME): New.
	Emit "tls_object" for thread-local objects.
	* config/sparc/sol2-gas-bi.h (ASM_DECLARE_OBJECT_NAME): New.
	Do no emit "tls_object" for thread-local objects.
        * config/sparc/sparc.c (sparc_elf_asm_named_section): Emit
        "#tls" for thread-local sections.
        * configure.ac (thread-local checks): Specify --fatal-warnings in
        every binutils-specific checks.  For sparc*-*-*, test whether the
        OS is Solaris and the tools are native and act accordingly.
        * configure: Rebuild.


2004-01-17  Eric Botcazou  <ebotcazou@libertysurf.fr>

        * gcc.dg/tls/alias-1.c: Add dg-warning for unsupported visibility
        attribute on sparc*-sun-solaris2.*.


-- 
Eric Botcazou
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.ac,v
retrieving revision 2.6
diff -u -r2.6 configure.ac
--- configure.ac	15 Jan 2004 04:02:11 -0000	2.6
+++ configure.ac	17 Jan 2004 04:22:13 -0000
@@ -2060,6 +2060,7 @@
 	lda	$4,foo($29)			!tprel'
 	tls_first_major=2
 	tls_first_minor=13
+	tls_as_opt=--fatal-warnings
 	;;
   i[34567]86-*-*)
     conftest_s='
@@ -2079,6 +2080,7 @@
 	leal	foo@NTPOFF(%ecx), %eax'
 	tls_first_major=2
 	tls_first_minor=14
+	tls_as_opt=--fatal-warnings
 	;;
   x86_64-*-*)
     conftest_s='
@@ -2093,6 +2095,7 @@
 	movq	$foo@TPOFF, %rax'
 	tls_first_major=2
 	tls_first_minor=14
+	tls_as_opt=--fatal-warnings
 	;;
   ia64-*-*)
     conftest_s='
@@ -2110,6 +2113,7 @@
 	movl	r24 = @tprel(foo#)'
 	tls_first_major=2
 	tls_first_minor=13
+	tls_as_opt=--fatal-warnings
 	;;
   powerpc-*-*)
     conftest_s='
@@ -2135,7 +2139,7 @@
 	addi 9,9,x2@tprel@l'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-a32
+	tls_as_opt="-a32 --fatal-warnings"
 	;;
   powerpc64-*-*)
     conftest_s='
@@ -2169,7 +2173,7 @@
 	nop'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-a64
+	tls_as_opt="-a64 --fatal-warnings"
 	;;
   s390-*-*)
     conftest_s='
@@ -2188,7 +2192,7 @@
 	bas	%r14,0(%r1,%r13):tls_ldcall:foo'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-m31
+	tls_as_opt="-m31 --fatal-warnings"
 	;;
   s390x-*-*)
     conftest_s='
@@ -2206,7 +2210,7 @@
 	brasl	%r14,__tls_get_offset@PLT:tls_ldcall:foo'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt="-m64 -Aesame"
+	tls_as_opt="-m64 -Aesame --fatal-warnings"
 	;;
   sh-*-* | sh[34]-*-*)
     conftest_s='
@@ -2220,9 +2224,44 @@
 	.long	foo@TPOFF'
 	tls_first_major=2
 	tls_first_minor=13
+	tls_as_opt=--fatal-warnings
 	;;
   sparc*-*-*)
-    conftest_s='
+    case "$target" in
+      sparc*-sun-solaris2.*)
+	on_solaris=yes
+	;;
+      *)
+	on_solaris=no
+	;;
+    esac
+    if test x$on_solaris = xyes && test x$gas_flag = xno; then
+      conftest_s='
+	.section ".tdata",#alloc,#write,#tls
+foo:	.long	25
+	.text
+	sethi	%tgd_hi22(foo), %o0
+	add	%o0, %tgd_lo10(foo), %o1
+	add	%l7, %o1, %o0, %tgd_add(foo)
+	call	__tls_get_addr, %tgd_call(foo)
+	sethi	%tldm_hi22(foo), %l1
+	add	%l1, %tldm_lo10(foo), %l2
+	add	%l7, %l2, %o0, %tldm_add(foo)
+	call	__tls_get_addr, %tldm_call(foo)
+	sethi	%tldo_hix22(foo), %l3
+	xor	%l3, %tldo_lox10(foo), %l4
+	add	%o0, %l4, %l5, %tldo_add(foo)
+	sethi	%tie_hi22(foo), %o3
+	add	%o3, %tie_lo10(foo), %o3
+	ld	[%l7 + %o3], %o2, %tie_ld(foo)
+	add	%g7, %o2, %o4, %tie_add(foo)
+	sethi	%tle_hix22(foo), %l1
+	xor	%l1, %tle_lox10(foo), %o5
+	ld	[%g7 + %o5], %o1'
+	tls_first_major=0
+	tls_first_minor=0
+    else
+      conftest_s='
 	.section ".tdata","awT",@progbits
 foo:	.long	25
 	.text
@@ -2246,7 +2285,8 @@
 	ld	[%g7 + %o5], %o1'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-32
+	tls_as_opt="-32 --fatal-warnings"
+      fi
 	;;
 changequote([,])dnl
 esac
@@ -2254,8 +2294,7 @@
   : # If we don't have a check, assume no support.
 else
   gcc_GAS_CHECK_FEATURE(thread-local storage support, gcc_cv_as_tls,
-  [$tls_first_major,$tls_first_minor,0], [$tls_as_opt --fatal-warnings],
-  [$conftest_s],,
+  [$tls_first_major,$tls_first_minor,0], [$tls_as_opt], [$conftest_s],,
   [AC_DEFINE(HAVE_AS_TLS, 1,
 	    [Define if your assembler supports thread-local storage.])])
 fi
Index: configure
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure,v
retrieving revision 1.794
diff -u -r1.794 configure
--- configure	15 Jan 2004 04:02:11 -0000	1.794
+++ configure	17 Jan 2004 04:22:36 -0000
@@ -10138,6 +10138,7 @@
 	lda	$4,foo($29)			!tprel'
 	tls_first_major=2
 	tls_first_minor=13
+	tls_as_opt=--fatal-warnings
 	;;
   i[34567]86-*-*)
     conftest_s='
@@ -10157,6 +10158,7 @@
 	leal	foo@NTPOFF(%ecx), %eax'
 	tls_first_major=2
 	tls_first_minor=14
+	tls_as_opt=--fatal-warnings
 	;;
   x86_64-*-*)
     conftest_s='
@@ -10171,6 +10173,7 @@
 	movq	$foo@TPOFF, %rax'
 	tls_first_major=2
 	tls_first_minor=14
+	tls_as_opt=--fatal-warnings
 	;;
   ia64-*-*)
     conftest_s='
@@ -10188,6 +10191,7 @@
 	movl	r24 = @tprel(foo#)'
 	tls_first_major=2
 	tls_first_minor=13
+	tls_as_opt=--fatal-warnings
 	;;
   powerpc-*-*)
     conftest_s='
@@ -10213,7 +10217,7 @@
 	addi 9,9,x2@tprel@l'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-a32
+	tls_as_opt="-a32 --fatal-warnings"
 	;;
   powerpc64-*-*)
     conftest_s='
@@ -10247,7 +10251,7 @@
 	nop'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-a64
+	tls_as_opt="-a64 --fatal-warnings"
 	;;
   s390-*-*)
     conftest_s='
@@ -10266,7 +10270,7 @@
 	bas	%r14,0(%r1,%r13):tls_ldcall:foo'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-m31
+	tls_as_opt="-m31 --fatal-warnings"
 	;;
   s390x-*-*)
     conftest_s='
@@ -10284,7 +10288,7 @@
 	brasl	%r14,__tls_get_offset@PLT:tls_ldcall:foo'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt="-m64 -Aesame"
+	tls_as_opt="-m64 -Aesame --fatal-warnings"
 	;;
   sh-*-* | sh[34]-*-*)
     conftest_s='
@@ -10298,9 +10302,44 @@
 	.long	foo@TPOFF'
 	tls_first_major=2
 	tls_first_minor=13
+	tls_as_opt=--fatal-warnings
 	;;
   sparc*-*-*)
-    conftest_s='
+    case "$target" in
+      sparc*-sun-solaris2.*)
+	on_solaris=yes
+	;;
+      *)
+	on_solaris=no
+	;;
+    esac
+    if test x$on_solaris = xyes && test x$gas_flag = xno; then
+      conftest_s='
+	.section ".tdata",#alloc,#write,#tls
+foo:	.long	25
+	.text
+	sethi	%tgd_hi22(foo), %o0
+	add	%o0, %tgd_lo10(foo), %o1
+	add	%l7, %o1, %o0, %tgd_add(foo)
+	call	__tls_get_addr, %tgd_call(foo)
+	sethi	%tldm_hi22(foo), %l1
+	add	%l1, %tldm_lo10(foo), %l2
+	add	%l7, %l2, %o0, %tldm_add(foo)
+	call	__tls_get_addr, %tldm_call(foo)
+	sethi	%tldo_hix22(foo), %l3
+	xor	%l3, %tldo_lox10(foo), %l4
+	add	%o0, %l4, %l5, %tldo_add(foo)
+	sethi	%tie_hi22(foo), %o3
+	add	%o3, %tie_lo10(foo), %o3
+	ld	[%l7 + %o3], %o2, %tie_ld(foo)
+	add	%g7, %o2, %o4, %tie_add(foo)
+	sethi	%tle_hix22(foo), %l1
+	xor	%l1, %tle_lox10(foo), %o5
+	ld	[%g7 + %o5], %o1'
+	tls_first_major=0
+	tls_first_minor=0
+    else
+      conftest_s='
 	.section ".tdata","awT",@progbits
 foo:	.long	25
 	.text
@@ -10324,7 +10363,8 @@
 	ld	[%g7 + %o5], %o1'
 	tls_first_major=2
 	tls_first_minor=14
-	tls_as_opt=-32
+	tls_as_opt="-32 --fatal-warnings"
+      fi
 	;;
 esac
 if test -z "$tls_first_major"; then
@@ -10342,7 +10382,7 @@
 fi
   elif test x$gcc_cv_as != x; then
     echo "$conftest_s" > conftest.s
-    if { ac_try='$gcc_cv_as $tls_as_opt --fatal-warnings -o conftest.o conftest.s >&5'
+    if { ac_try='$gcc_cv_as $tls_as_opt -o conftest.o conftest.s >&5'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
Index: config/sparc/sol2-bi.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2-bi.h,v
retrieving revision 1.14
diff -u -r1.14 sol2-bi.h
--- config/sparc/sol2-bi.h	20 Dec 2003 07:40:22 -0000	1.14
+++ config/sparc/sol2-bi.h	17 Jan 2004 04:22:37 -0000
@@ -219,3 +219,30 @@
 #  define ASM_DEBUG_SPEC "%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}"
 # endif
 #endif
+
+/* The native TLS-enabled assembler requires the directive #tls_object
+   to be put on objects in TLS sections (as of v7.1) but early gas
+   versions don't support it.  */
+#undef ASM_DECLARE_OBJECT_NAME
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
+  do								\
+    {								\
+      HOST_WIDE_INT size;					\
+								\
+      if (DECL_THREAD_LOCAL (DECL))				\
+	ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_object");	\
+      else							\
+	ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");	\
+								\
+      size_directive_output = 0;				\
+      if (!flag_inhibit_size_directive				\
+	  && (DECL) && DECL_SIZE (DECL))			\
+	{							\
+	  size_directive_output = 1;				\
+	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
+	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
+	}							\
+								\
+      ASM_OUTPUT_LABEL (FILE, NAME);				\
+    }								\
+  while (0)
Index: config/sparc/sol2-gas-bi.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2-gas-bi.h,v
retrieving revision 1.4
diff -u -r1.4 sol2-gas-bi.h
--- config/sparc/sol2-gas-bi.h	17 Jun 2003 01:00:43 -0000	1.4
+++ config/sparc/sol2-gas-bi.h	17 Jan 2004 04:22:37 -0000
@@ -3,3 +3,25 @@
 
 #undef  AS_SPARC64_FLAG
 #define AS_SPARC64_FLAG	"-TSO -64 -Av9"
+
+/* See sol2-bi.h for the rationale.  */
+#undef ASM_DECLARE_OBJECT_NAME
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
+  do								\
+    {								\
+      HOST_WIDE_INT size;					\
+								\
+      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");		\
+								\
+      size_directive_output = 0;				\
+      if (!flag_inhibit_size_directive				\
+	  && (DECL) && DECL_SIZE (DECL))			\
+	{							\
+	  size_directive_output = 1;				\
+	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
+	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
+	}							\
+								\
+      ASM_OUTPUT_LABEL (FILE, NAME);				\
+    }								\
+  while (0)
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.271
diff -u -r1.271 sparc.c
--- config/sparc/sparc.c	10 Dec 2003 15:25:41 -0000	1.271
+++ config/sparc/sparc.c	17 Jan 2004 04:22:56 -0000
@@ -8478,6 +8478,8 @@
     fputs (",#alloc", asm_out_file);
   if (flags & SECTION_WRITE)
     fputs (",#write", asm_out_file);
+  if (flags & SECTION_TLS)
+    fputs (",#tls", asm_out_file);
   if (flags & SECTION_CODE)
     fputs (",#execinstr", asm_out_file);
 
Index: testsuite/gcc.dg/tls/alias-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tls/alias-1.c,v
retrieving revision 1.1
diff -u -r1.1 alias-1.c
--- testsuite/gcc.dg/tls/alias-1.c	6 Jan 2003 22:59:25 -0000	1.1
+++ testsuite/gcc.dg/tls/alias-1.c	17 Jan 2004 04:22:56 -0000
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-warning "visibility" "unsupported" { target sparc*-sun-solaris2.* } 22 } */
 /* Test that encode_section_info handles the change from externally
    defined to locally defined (via hidden).   Extracted from glibc.  */
 

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