From: Rainer Orth Date: Fri, 7 Mar 2014 11:30:40 +0000 (+0000) Subject: Disable local dynamic TLS model on Solaris/x86 if as/ld cannot handle it X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=caa16d41773bf442acb6bb8768b1c9a829ca8cab;p=gcc.git Disable local dynamic TLS model on Solaris/x86 if as/ld cannot handle it * configure.ac (TLS_SECTION_ASM_FLAG): Save as tls_section_flag. (LIB_TLS_SPEC): Save as ld_tls_libs. (HAVE_AS_IX86_TLSLDMPLT): Define as 1/0. (HAVE_AS_IX86_TLSLDM): New test. * configure, config.in: Regenerate. * config/i386/i386.c (legitimize_tls_address): Fall back to TLS_MODEL_GLOBAL_DYNAMIC on 32-bit Solaris/x86 if tool chain cannot support TLS_MODEL_LOCAL_DYNAMIC. * config/i386/i386.md (*tls_local_dynamic_base_32_gnu): Use if instead of #ifdef in HAVE_AS_IX86_TLSLDMPLT test. From-SVN: r208398 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dca1085875d..feef2ce8d63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2014-03-07 Rainer Orth + + * configure.ac (TLS_SECTION_ASM_FLAG): Save as tls_section_flag. + (LIB_TLS_SPEC): Save as ld_tls_libs. + (HAVE_AS_IX86_TLSLDMPLT): Define as 1/0. + (HAVE_AS_IX86_TLSLDM): New test. + * configure, config.in: Regenerate. + * config/i386/i386.c (legitimize_tls_address): Fall back to + TLS_MODEL_GLOBAL_DYNAMIC on 32-bit Solaris/x86 if tool chain + cannot support TLS_MODEL_LOCAL_DYNAMIC. + * config/i386/i386.md (*tls_local_dynamic_base_32_gnu): Use if + instead of #ifdef in HAVE_AS_IX86_TLSLDMPLT test. + 2014-03-07 Paulo Matos * common.opt (fira-loop-pressure): Mark as optimization. diff --git a/gcc/config.in b/gcc/config.in index 5aa32213e7c..af02866dd33 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -369,7 +369,13 @@ #endif -/* Define if your assembler and linker support @tlsldmplt. */ +/* Define to 1 if your assembler and linker support @tlsldm. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_IX86_TLSLDM +#endif + + +/* Define to 1 if your assembler and linker support @tlsldmplt. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_IX86_TLSLDMPLT #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 38b41a93c22..9e33d5309fc 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13396,6 +13396,13 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov) enum machine_mode tp_mode = Pmode; int type; + /* Fall back to global dynamic model if tool chain cannot support local + dynamic. */ + if (TARGET_SUN_TLS && !TARGET_64BIT + && !HAVE_AS_IX86_TLSLDMPLT && !HAVE_AS_IX86_TLSLDM + && model == TLS_MODEL_LOCAL_DYNAMIC) + model = TLS_MODEL_GLOBAL_DYNAMIC; + switch (model) { case TLS_MODEL_GLOBAL_DYNAMIC: diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 4ccb3a5e6fe..ea1d85f76a5 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -12962,11 +12962,12 @@ output_asm_insn ("lea{l}\t{%&@tlsldm(%1), %0|%0, %&@tlsldm[%1]}", operands); if (TARGET_SUN_TLS) -#ifdef HAVE_AS_IX86_TLSLDMPLT - return "call\t%&@tlsldmplt"; -#else - return "call\t%p2@plt"; -#endif + { + if (HAVE_AS_IX86_TLSLDMPLT) + return "call\t%&@tlsldmplt"; + else + return "call\t%p2@plt"; + } return "call\t%P2"; } [(set_attr "type" "multi") diff --git a/gcc/configure b/gcc/configure index cab3e926d9f..297238daef3 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10970,6 +10970,10 @@ else force_sjlj_exceptions=yes enableval=yes ;; + lm32*-*-*) + force_sjlj_exceptions=yes + enableval=yes + ;; *) force_sjlj_exceptions=no ;; @@ -17923,7 +17927,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17926 "configure" +#line 17930 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18029,7 +18033,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18032 "configure" +#line 18036 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -23298,6 +23302,7 @@ foo: .long 25 .section .tdata,"awt",@progbits' tls_first_major=0 tls_first_minor=0 + tls_section_flag=t $as_echo "#define TLS_SECTION_ASM_FLAG 't'" >>confdefs.h @@ -23306,6 +23311,7 @@ $as_echo "#define TLS_SECTION_ASM_FLAG 't'" >>confdefs.h .section ".tdata","awT",@progbits' tls_first_major=2 tls_first_minor=14 + tls_section_flag=T tls_as_opt="--fatal-warnings" fi conftest_s="$conftest_s @@ -23336,6 +23342,7 @@ foo: .long 25 movq $foo@TPOFF, %rax' tls_first_major=2 tls_first_minor=14 + tls_section_flag=T tls_as_opt=--fatal-warnings ;; ia64-*-*) @@ -23782,6 +23789,7 @@ else set_have_as_tls=no fi + ld_tls_libs="$LIBS" # Clear LIBS if we cannot support TLS. if test $set_have_as_tls = no; then LIBS= @@ -25205,11 +25213,73 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_ix86_tlsldmplt" >&5 $as_echo "$gcc_cv_as_ix86_tlsldmplt" >&6; } -if test $gcc_cv_as_ix86_tlsldmplt = yes; then -$as_echo "#define HAVE_AS_IX86_TLSLDMPLT 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_AS_IX86_TLSLDMPLT `if test $gcc_cv_as_ix86_tlsldmplt = yes; then echo 1; else echo 0; fi` +_ACEOF + + + # Enforce 32-bit output with gas and gld. + if test x$gas = xyes; then + as_ix86_tls_ldm_opt="--32" + fi + if echo "$ld_ver" | grep GNU > /dev/null; then + if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then + ld_ix86_tls_ldm_opt="-melf_i386_sol2" + else + ld_ix86_tls_ldm_opt="-melf_i386" + fi + fi + conftest_s=' + .section .text,"ax",@progbits + .globl _start + .type _start, @function +_start: + leal value@tlsldm(%ebx), %eax + call ___tls_get_addr@plt + + .section .tdata,"aw'$tls_section_flag'",@progbits + .type value, @object +value:' + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for R_386_TLS_LDM reloc" >&5 +$as_echo_n "checking assembler for R_386_TLS_LDM reloc... " >&6; } +if test "${gcc_cv_as_ix86_tlsldm+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_ix86_tlsldm=no + if test x$gcc_cv_as != x; then + $as_echo "$conftest_s" > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags $as_ix86_tls_ldm_opt -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \ + && $gcc_cv_ld $ld_ix86_tls_ldm_opt -o conftest conftest.o $ld_tls_libs -lc > /dev/null 2>&1; then + if $gcc_cv_objdump -d conftest 2>/dev/null | grep nop > /dev/null \ + || dis conftest 2>/dev/null | grep nop > /dev/null; then + gcc_cv_as_ix86_tlsldm=yes + fi + fi + rm -f conftest + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_ix86_tlsldm" >&5 +$as_echo "$gcc_cv_as_ix86_tlsldm" >&6; } + + +cat >>confdefs.h <<_ACEOF +#define HAVE_AS_IX86_TLSLDM `if test $gcc_cv_as_ix86_tlsldm = yes; then echo 1; else echo 0; fi` +_ACEOF + ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index 3d7a5c871d6..156d46c2ad6 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2973,6 +2973,7 @@ foo: .long 25 .section .tdata,"awt",@progbits' tls_first_major=0 tls_first_minor=0 + tls_section_flag=t changequote([,])dnl AC_DEFINE(TLS_SECTION_ASM_FLAG, 't', [Define to the flag used to mark TLS sections if the default (`T') doesn't work.]) @@ -2982,6 +2983,7 @@ changequote(,)dnl .section ".tdata","awT",@progbits' tls_first_major=2 tls_first_minor=14 + tls_section_flag=T tls_as_opt="--fatal-warnings" fi conftest_s="$conftest_s @@ -3012,6 +3014,7 @@ foo: .long 25 movq $foo@TPOFF, %rax' tls_first_major=2 tls_first_minor=14 + tls_section_flag=T tls_as_opt=--fatal-warnings ;; ia64-*-*) @@ -3368,6 +3371,7 @@ case "$target" in # (32-bit x86) only lived in libthread, so check for that. Keep # set_have_as_tls if found, disable if not. AC_SEARCH_LIBS([$tga_func], [thread],, [set_have_as_tls=no]) + ld_tls_libs="$LIBS" # Clear LIBS if we cannot support TLS. if test $set_have_as_tls = no; then LIBS= @@ -3924,9 +3928,48 @@ foo: nop && $gcc_cv_ld -o conftest conftest.o -G > /dev/null 2>&1; then gcc_cv_as_ix86_tlsldmplt=yes fi - rm -f conftest], - [AC_DEFINE(HAVE_AS_IX86_TLSLDMPLT, 1, - [Define if your assembler and linker support @tlsldmplt.])]) + rm -f conftest]) + AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDMPLT, + [`if test $gcc_cv_as_ix86_tlsldmplt = yes; then echo 1; else echo 0; fi`], + [Define to 1 if your assembler and linker support @tlsldmplt.]) + + # Enforce 32-bit output with gas and gld. + if test x$gas = xyes; then + as_ix86_tls_ldm_opt="--32" + fi + if echo "$ld_ver" | grep GNU > /dev/null; then + if $gcc_cv_ld -V 2>/dev/null | grep elf_i386_sol2 > /dev/null; then + ld_ix86_tls_ldm_opt="-melf_i386_sol2" + else + ld_ix86_tls_ldm_opt="-melf_i386" + fi + fi + conftest_s=' + .section .text,"ax",@progbits + .globl _start + .type _start, @function +_start: + leal value@tlsldm(%ebx), %eax + call ___tls_get_addr@plt + + .section .tdata,"aw'$tls_section_flag'",@progbits + .type value, @object +value:' + gcc_GAS_CHECK_FEATURE([R_386_TLS_LDM reloc], + gcc_cv_as_ix86_tlsldm,, + [$as_ix86_tls_ldm_opt], + [$conftest_s], + [if test x$gcc_cv_ld != x && test x$gcc_cv_objdump != x \ + && $gcc_cv_ld $ld_ix86_tls_ldm_opt -o conftest conftest.o $ld_tls_libs -lc > /dev/null 2>&1; then + if $gcc_cv_objdump -d conftest 2>/dev/null | grep nop > /dev/null \ + || dis conftest 2>/dev/null | grep nop > /dev/null; then + gcc_cv_as_ix86_tlsldm=yes + fi + fi + rm -f conftest]) + AC_DEFINE_UNQUOTED(HAVE_AS_IX86_TLSLDM, + [`if test $gcc_cv_as_ix86_tlsldm = yes; then echo 1; else echo 0; fi`], + [Define to 1 if your assembler and linker support @tlsldm.]) ;;