Re: [libphobos] Work around Solaris ld bug linking __tls_get_addr on 64-bit x86

2019-04-13 Thread Iain Buclaw
On Tue, 9 Apr 2019 at 21:36, Rainer Orth  wrote:
>
> Rainer Orth  writes:
>
> > Here's the patch I mentioned in
> >
> >   https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01661.html
> >
> > to work around an amd64 Solaris ld bug.  I'm just posting it for
> > reference now: until it's clear if a fix will make it into Solaris 11.5
> > or not, there's no point in applying it yet.
> >
> > Still, review comments are appreciated.
>
> With the revised patch for non-dlpi_tls_modid versions of Solaris
>
> https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00354.html
>
> __tls_get_addr will always be called and thus this workaround is needed
> unconditionally, even should the ld bug be fixed in Solaris 11.5.
>
> This revision adjusts the patch accordingly and was tested together with
> the other one on Solaris 11.[345]/x86.
>
> Ok for mainline?
>

OK

-- 
Iain


Re: [libphobos] Work around Solaris ld bug linking __tls_get_addr on 64-bit x86

2019-04-09 Thread Rainer Orth
Rainer Orth  writes:

> Here's the patch I mentioned in
>
>   https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01661.html
>
> to work around an amd64 Solaris ld bug.  I'm just posting it for
> reference now: until it's clear if a fix will make it into Solaris 11.5
> or not, there's no point in applying it yet.
>
> Still, review comments are appreciated.

With the revised patch for non-dlpi_tls_modid versions of Solaris

https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00354.html

__tls_get_addr will always be called and thus this workaround is needed
unconditionally, even should the ld bug be fixed in Solaris 11.5.

This revision adjusts the patch accordingly and was tested together with
the other one on Solaris 11.[345]/x86.

Ok for mainline?

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


2019-01-28  Rainer Orth  

* m4/druntime/os.m4 (DRUNTIME_OS_LINK_SPEC): New macro.
* configure.ac: Call it.
* configure: Regenerate.
* src/libgphobos.spec.in (*link): Append OS_LINK_SPEC.

# HG changeset patch
# Parent  bfb51574f91b2eaceb6cc39883f8c6bd7cf7f885
Work around Solaris ld bug linking __tls_get_addr on 64-bit x86

diff --git a/libphobos/configure.ac b/libphobos/configure.ac
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -126,6 +126,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/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4
--- 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/libgphobos.spec.in b/libphobos/src/libgphobos.spec.in
--- 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)


[libphobos] Work around Solaris ld bug linking __tls_get_addr on 64-bit x86

2019-01-29 Thread Rainer Orth
Here's the patch I mentioned in

https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01661.html

to work around an amd64 Solaris ld bug.  I'm just posting it for
reference now: until it's clear if a fix will make it into Solaris 11.5
or not, there's no point in applying it yet.

Still, review comments are appreciated.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


2019-01-28  Rainer Orth  

* m4/druntime/os.m4 (DRUNTIME_OS_LINK_SPEC): New macro.
* configure.ac: Call it.
* configure: Regenerate.
* src/libgphobos.spec.in (*link): Append OS_LINK_SPEC.

# HG changeset patch
# Parent  4dadb62112e1e735535bc37fe31e14c82340a1b4
Work around Solaris ld bug linking __tls_get_addr on 64-bit x86

diff --git a/libphobos/configure.ac b/libphobos/configure.ac
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -126,6 +126,7 @@ DRUNTIME_OS_SOURCES
 DRUNTIME_OS_THREAD_MODEL
 DRUNTIME_OS_ARM_EABI_UNWINDER
 DRUNTIME_OS_MINFO_BRACKETING
+DRUNTIME_OS_LINK_SPEC
 
 WITH_LOCAL_DRUNTIME([
   AC_LANG_PUSH([D])
diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4
--- a/libphobos/m4/druntime/os.m4
+++ b/libphobos/m4/druntime/os.m4
@@ -182,3 +182,27 @@ AC_DEFUN([DRUNTIME_OS_MINFO_BRACKETING],
   AC_SUBST(DCFG_MINFO_BRACKETING)
   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.
+  if test $DCFG_DLPI_TLS_MODID = true; then
+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
+  fi
+  ;;
+  esac
+  AC_SUBST(OS_LINK_SPEC)
+])
diff --git a/libphobos/src/libgphobos.spec.in b/libphobos/src/libgphobos.spec.in
--- a/libphobos/src/libgphobos.spec.in
+++ b/libphobos/src/libgphobos.spec.in
@@ -4,5 +4,8 @@
 # order.
 #
 
+%rename link linkorig_gdc_renamed
+*link: %(linkorig_gdc_renamed) @OS_LINK_SPEC@
+
 %rename lib liborig_gdc_renamed
 *lib: @SPEC_PHOBOS_DEPS@ %(liborig_gdc_renamed)