From 5b79027a12c6bdcb9f2b3366273fb51130fb5b51 Mon Sep 17 00:00:00 2001 From: ro Date: Sun, 14 Apr 2019 09:24:26 +0000 Subject: [PATCH] Work around Solaris ld bug linking __tls_get_addr on 64-bit x86 * m4/druntime/os.m4 (DRUNTIME_OS_LINK_SPEC): New macro. * configure.ac: Call it. * configure: Regenerate. * Makefile.in, libdruntime/Makefile.in, src/Makefile.in, testsuite/Makefile.in: Regenerate. * src/libgphobos.spec.in (*link): Append OS_LINK_SPEC. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270346 138bc75d-0d04-0410-961f-82ee72b054a4 --- libphobos/ChangeLog | 7 +++++++ libphobos/Makefile.in | 1 + libphobos/configure | 22 ++++++++++++++++++++-- libphobos/configure.ac | 1 + libphobos/libdruntime/Makefile.in | 1 + libphobos/m4/druntime/os.m4 | 22 ++++++++++++++++++++++ libphobos/src/Makefile.in | 1 + libphobos/src/libgphobos.spec.in | 3 +++ libphobos/testsuite/Makefile.in | 1 + 9 files changed, 57 insertions(+), 2 deletions(-) diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index b70288b4064b..9c418dc8b7d3 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,5 +1,12 @@ 2019-04-14 Rainer Orth + * m4/druntime/os.m4 (DRUNTIME_OS_LINK_SPEC): New macro. + * configure.ac: Call it. + * configure: Regenerate. + * Makefile.in, libdruntime/Makefile.in, src/Makefile.in, + testsuite/Makefile.in: Regenerate. + * src/libgphobos.spec.in (*link): Append OS_LINK_SPEC. + PR d/88150 * libdruntime/gcc/sections/elf_shared.d [Solaris] (SharedELF): Set to true. diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in index 1cd4117f2ee0..127a62628cee 100644 --- a/libphobos/Makefile.in +++ b/libphobos/Makefile.in @@ -252,6 +252,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OS_LINK_SPEC = @OS_LINK_SPEC@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ diff --git a/libphobos/configure b/libphobos/configure index 48b78eb56dd2..4ebad782abf0 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -650,6 +650,7 @@ DCFG_HAVE_LIBATOMIC DCFG_HAVE_64BIT_ATOMICS DCFG_HAVE_ATOMIC_BUILTINS DCFG_HAVE_QSORT_R +OS_LINK_SPEC DRUNTIME_OS_MINFO_BRACKETING_FALSE DRUNTIME_OS_MINFO_BRACKETING_TRUE DCFG_MINFO_BRACKETING @@ -11495,7 +11496,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11498 "configure" +#line 11499 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11601,7 +11602,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11604 "configure" +#line 11605 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14118,6 +14119,23 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + case $target in + i?86-*-solaris2.* | x86_64-*-solaris2.*) + # 64-bit Solaris/x86 ld breaks calls to __tls_get_addr with non-TLS + # relocs. Work around by disabling TLS transitions. Not necessary + # on 32-bit x86, but cannot be distinguished reliably in specs. + druntime_ld_prog=`$CC -print-prog-name=ld` + if test -n "$druntime_ld_prog" \ + && $druntime_ld_prog -v 2>&1 | grep GNU > /dev/null 2>&1; then + : + else + OS_LINK_SPEC='-z relax=transtls' + fi + ;; + esac + + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' diff --git a/libphobos/configure.ac b/libphobos/configure.ac index f1ab556bec0f..8905252b0210 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -125,6 +125,7 @@ DRUNTIME_OS_SOURCES DRUNTIME_OS_THREAD_MODEL DRUNTIME_OS_ARM_EABI_UNWINDER DRUNTIME_OS_MINFO_BRACKETING +DRUNTIME_OS_LINK_SPEC DRUNTIME_LIBRARIES_CLIB WITH_LOCAL_DRUNTIME([ diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index efb1b952cf8e..0994fcd81329 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -566,6 +566,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OS_LINK_SPEC = @OS_LINK_SPEC@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4 index 92a2ba5cdf82..295926c43d30 100644 --- a/libphobos/m4/druntime/os.m4 +++ b/libphobos/m4/druntime/os.m4 @@ -183,3 +183,25 @@ AC_DEFUN([DRUNTIME_OS_MINFO_BRACKETING], AM_CONDITIONAL([DRUNTIME_OS_MINFO_BRACKETING], [test "$DCFG_MINFO_BRACKETING" = "true"]) AC_LANG_POP([C]) ]) + +# DRUNTIME_OS_LINK_SPEC +# --------------------- +# Add target-specific link options to link_spec. +AC_DEFUN([DRUNTIME_OS_LINK_SPEC], +[ + case $target in + i?86-*-solaris2.* | x86_64-*-solaris2.*) + # 64-bit Solaris/x86 ld breaks calls to __tls_get_addr with non-TLS + # relocs. Work around by disabling TLS transitions. Not necessary + # on 32-bit x86, but cannot be distinguished reliably in specs. + druntime_ld_prog=`$CC -print-prog-name=ld` + if test -n "$druntime_ld_prog" \ + && $druntime_ld_prog -v 2>&1 | grep GNU > /dev/null 2>&1; then + : + else + OS_LINK_SPEC='-z relax=transtls' + fi + ;; + esac + AC_SUBST(OS_LINK_SPEC) +]) diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index 0cc16ce1cf09..8fd6e5d38449 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -323,6 +323,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OS_LINK_SPEC = @OS_LINK_SPEC@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ diff --git a/libphobos/src/libgphobos.spec.in b/libphobos/src/libgphobos.spec.in index ff9389696f36..97a9ceaf48c8 100644 --- a/libphobos/src/libgphobos.spec.in +++ b/libphobos/src/libgphobos.spec.in @@ -6,5 +6,8 @@ @DRTSTUFF_SPEC@ +%rename link linkorig_gdc_renamed +*link: %(linkorig_gdc_renamed) @OS_LINK_SPEC@ + %rename lib liborig_gdc_renamed *lib: %{debuglib|defaultlib|nophoboslib: ; :@SPEC_PHOBOS_DEPS@} %(liborig_gdc_renamed) diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in index 9c509f377295..cacc03138f3a 100644 --- a/libphobos/testsuite/Makefile.in +++ b/libphobos/testsuite/Makefile.in @@ -196,6 +196,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OS_LINK_SPEC = @OS_LINK_SPEC@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ -- 2.39.2