diff mbox series

S/390: Fix PR91628

Message ID 0afe1b58-2544-98c2-b056-a724f1a5fa6d@linux.ibm.com
State New
Headers show
Series S/390: Fix PR91628 | expand

Commit Message

Li, Pan2 via Gcc-patches March 23, 2020, 5:04 p.m. UTC
Hi,

this patch picks up Robin Dapps patch __tls_get_offset-in-separate.S.
See "Bugzilla 91628 - libdruntime uses glibc internal symbol on s390"
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91628)

The original purpose was to get rid of the usage of the glibc-internal 
symbol __tls_get_addr_internal.

The patch has not applied as is, therefore I've just regenerated the
configure and Makefiles.

Furthermore if build with multilib, the file
gcc/libphobos/libdruntime/config/systemz/get_tls_offset.S is used
for both configurations: systemz and s390.
Therefore both implementations are now in the systemz file which
uses an "#ifdef __s390x__" in order to distinguish both cases.
The s390 file is just including the systemz one.

Bye,
Stefan

--

libphobos/ChangeLog:

2019-11-27  Robin Dapp  <rdapp@linux.ibm.com>
2020-03-23  Stefan Liebler  <stli@linux.ibm.com>

	* configure: Regenerate.
	* libdruntime/Makefile.am: Add s390x and s390.
	* libdruntime/Makefile.in: Regenerate.
	* libdruntime/config/s390/get_tls_offset.S: New file.
	* libdruntime/config/systemz/get_tls_offset.S: New file.
	* libdruntime/gcc/sections/elf_shared.d: Use ibmz_get_tls_offset.
	* m4/druntime/cpu.m4: Add s390x and s390.

Comments

Li, Pan2 via Gcc-patches April 1, 2020, 6:28 a.m. UTC | #1
ping

On 3/23/20 6:04 PM, Stefan Liebler wrote:
> Hi,
> 
> this patch picks up Robin Dapps patch __tls_get_offset-in-separate.S.
> See "Bugzilla 91628 - libdruntime uses glibc internal symbol on s390"
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91628)
> 
> The original purpose was to get rid of the usage of the glibc-internal 
> symbol __tls_get_addr_internal.
> 
> The patch has not applied as is, therefore I've just regenerated the
> configure and Makefiles.
> 
> Furthermore if build with multilib, the file
> gcc/libphobos/libdruntime/config/systemz/get_tls_offset.S is used
> for both configurations: systemz and s390.
> Therefore both implementations are now in the systemz file which
> uses an "#ifdef __s390x__" in order to distinguish both cases.
> The s390 file is just including the systemz one.
> 
> Bye,
> Stefan
> 
> -- 
> 
> libphobos/ChangeLog:
> 
> 2019-11-27  Robin Dapp  <rdapp@linux.ibm.com>
> 2020-03-23  Stefan Liebler  <stli@linux.ibm.com>
> 
>      * configure: Regenerate.
>      * libdruntime/Makefile.am: Add s390x and s390.
>      * libdruntime/Makefile.in: Regenerate.
>      * libdruntime/config/s390/get_tls_offset.S: New file.
>      * libdruntime/config/systemz/get_tls_offset.S: New file.
>      * libdruntime/gcc/sections/elf_shared.d: Use ibmz_get_tls_offset.
>      * m4/druntime/cpu.m4: Add s390x and s390.
Li, Pan2 via Gcc-patches April 1, 2020, 10:50 a.m. UTC | #2
On 01/04/2020 08:28, Stefan Liebler wrote:
> ping
> 

Hi Stefan,

As I've already said, I think that the name should be __ibmz_get_tls_offset to make clear that it is an internal function.

Other than that, looks good to me.

Iain.
Li, Pan2 via Gcc-patches April 1, 2020, 4:20 p.m. UTC | #3
On 4/1/20 12:50 PM, Iain Buclaw wrote:
> 
> 
> On 01/04/2020 08:28, Stefan Liebler wrote:
>> ping
>>
> 
> Hi Stefan,
> 
> As I've already said, I think that the name should be __ibmz_get_tls_offset to make clear that it is an internal function.
> 
> Other than that, looks good to me.
> 
> Iain.
> 

Hi Iain,

Sorry. I've missed your comment in the bugzilla.
I've updated the name to __ibmz_get_this_offset.
Nothing else is changed in the attached patch.

Please commit the patch upstream.
Do you also close the bugzilla as soon as committed?

Regarding the mentioned musl-patch in your bugzilla comment:
Yes, the diff looks like not conflicting.

Thanks,
Stefan
Li, Pan2 via Gcc-patches April 7, 2020, 2:33 p.m. UTC | #4
On 4/1/20 6:20 PM, Stefan Liebler wrote:
> On 4/1/20 12:50 PM, Iain Buclaw wrote:
>>
>>
>> On 01/04/2020 08:28, Stefan Liebler wrote:
>>> ping
>>>
>>
>> Hi Stefan,
>>
>> As I've already said, I think that the name should be 
>> __ibmz_get_tls_offset to make clear that it is an internal function.
>>
>> Other than that, looks good to me.
>>
>> Iain.
>>
> 
> Hi Iain,
> 
> Sorry. I've missed your comment in the bugzilla.
> I've updated the name to __ibmz_get_this_offset.
> Nothing else is changed in the attached patch.
> 
> Please commit the patch upstream.
> Do you also close the bugzilla as soon as committed?
> 
> Regarding the mentioned musl-patch in your bugzilla comment:
> Yes, the diff looks like not conflicting.
> 
> Thanks,
> Stefan

Hi Iain,

Andreas has just committed the other patch "S/390: Fix layout of struct 
sigaction_t" to gcc after your pull-request was merged 
(https://github.com/dlang/druntime/pull/3020).

To me it seems that this patch is not simply pull-request-able to 
https://github.com/dlang/druntime.
As you've already mentioned "Other than that, looks good to me.", is 
this gcc patch okay to commit from your side? Then Andreas can also 
commit it and we can close the bugzilla.

Bye,
Stefan
Li, Pan2 via Gcc-patches April 7, 2020, 4:26 p.m. UTC | #5
On 07/04/2020 16:33, Stefan Liebler wrote:
> On 4/1/20 6:20 PM, Stefan Liebler wrote:
>> On 4/1/20 12:50 PM, Iain Buclaw wrote:
>>>
>>>
>>> On 01/04/2020 08:28, Stefan Liebler wrote:
>>>> ping
>>>>
>>>
>>> Hi Stefan,
>>>
>>> As I've already said, I think that the name should be __ibmz_get_tls_offset to make clear that it is an internal function.
>>>
>>> Other than that, looks good to me.
>>>
>>> Iain.
>>>
>>
>> Hi Iain,
>>
>> Sorry. I've missed your comment in the bugzilla.
>> I've updated the name to __ibmz_get_this_offset.
>> Nothing else is changed in the attached patch.
>>
>> Please commit the patch upstream.
>> Do you also close the bugzilla as soon as committed?
>>
>> Regarding the mentioned musl-patch in your bugzilla comment:
>> Yes, the diff looks like not conflicting.
>>
>> Thanks,
>> Stefan
> 
> Hi Iain,
> 
> Andreas has just committed the other patch "S/390: Fix layout of struct sigaction_t" to gcc after your pull-request was merged (https://github.com/dlang/druntime/pull/3020).
> 
> To me it seems that this patch is not simply pull-request-able to https://github.com/dlang/druntime.

Correct, all sources touched are local to gcc only.

> As you've already mentioned "Other than that, looks good to me.", is this gcc patch okay to commit from your side? Then Andreas can also commit it and we can close the bugzilla.
> 

No problems with it being committed.

Regards
Iain.
Li, Pan2 via Gcc-patches April 7, 2020, 7:09 p.m. UTC | #6
On 07.04.20 18:26, Iain Buclaw wrote:
> 
> 
> On 07/04/2020 16:33, Stefan Liebler wrote:
>> On 4/1/20 6:20 PM, Stefan Liebler wrote:
>>> On 4/1/20 12:50 PM, Iain Buclaw wrote:
>>>>
>>>>
>>>> On 01/04/2020 08:28, Stefan Liebler wrote:
>>>>> ping
>>>>>
>>>>
>>>> Hi Stefan,
>>>>
>>>> As I've already said, I think that the name should be __ibmz_get_tls_offset to make clear that it is an internal function.
>>>>
>>>> Other than that, looks good to me.
>>>>
>>>> Iain.
>>>>
>>>
>>> Hi Iain,
>>>
>>> Sorry. I've missed your comment in the bugzilla.
>>> I've updated the name to __ibmz_get_this_offset.
>>> Nothing else is changed in the attached patch.
>>>
>>> Please commit the patch upstream.
>>> Do you also close the bugzilla as soon as committed?
>>>
>>> Regarding the mentioned musl-patch in your bugzilla comment:
>>> Yes, the diff looks like not conflicting.
>>>
>>> Thanks,
>>> Stefan
>>
>> Hi Iain,
>>
>> Andreas has just committed the other patch "S/390: Fix layout of struct sigaction_t" to gcc after your pull-request was merged (https://github.com/dlang/druntime/pull/3020).
>>
>> To me it seems that this patch is not simply pull-request-able to https://github.com/dlang/druntime.
> 
> Correct, all sources touched are local to gcc only.
> 
>> As you've already mentioned "Other than that, looks good to me.", is this gcc patch okay to commit from your side? Then Andreas can also commit it and we can close the bugzilla.
>>
> 
> No problems with it being committed.

Committed to mainline. Thanks!

Andreas

> 
> Regards
> Iain.
>
diff mbox series

Patch

commit db977cdbfc3449dfd730b639cd762588202cbb94
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Mon Mar 16 15:06:08 2020 +0100

    S/390: Fix PR91628
    
    This patch picks up Robin Dapps patch __tls_get_offset-in-separate.S.
    See "Bugzilla 91628 - libdruntime uses glibc internal symbol on s390"
    (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91628)
    
    The patch has not applied as is, therefore I've just regenerated the
    configure and Makefiles.
    
    Furthermore if build with multilib, the file
    gcc/libphobos/libdruntime/config/systemz/get_tls_offset.S is used
    for both configurations: systemz and s390.
    Therefore both implementations are now in the systemz file which
    uses an "#ifdef __s390x__" in order to distinguish both cases.
    The s390 file is just including the systemz one.
    
    libphobos/ChangeLog:
    
    2019-11-27  Robin Dapp  <rdapp@linux.ibm.com>
    2020-03-23  Stefan Liebler  <stli@linux.ibm.com>
    
            * configure: Regenerate.
            * libdruntime/Makefile.am: Add s390x and s390.
            * libdruntime/Makefile.in: Regenerate.
            * libdruntime/config/s390/get_tls_offset.S: New file.
            * libdruntime/config/systemz/get_tls_offset.S: New file.
            * libdruntime/gcc/sections/elf_shared.d: Use ibmz_get_tls_offset.
            * m4/druntime/cpu.m4: Add s390x and s390.

diff --git a/libphobos/configure b/libphobos/configure
index 9cad270b2eb..04a6e6aeb0f 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -683,6 +683,10 @@  DRUNTIME_OS_AIX_FALSE
 DRUNTIME_OS_AIX_TRUE
 DRUNTIME_OS_UNIX_FALSE
 DRUNTIME_OS_UNIX_TRUE
+DRUNTIME_CPU_S390_FALSE
+DRUNTIME_CPU_S390_TRUE
+DRUNTIME_CPU_SYSTEMZ_FALSE
+DRUNTIME_CPU_SYSTEMZ_TRUE
 DRUNTIME_CPU_X86_FALSE
 DRUNTIME_CPU_X86_TRUE
 DRUNTIME_CPU_POWERPC64_FALSE
@@ -11644,7 +11648,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11647 "configure"
+#line 11651 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11750,7 +11754,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11753 "configure"
+#line 11757 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14012,6 +14016,12 @@  fi
       i[34567]86|x86_64)
                druntime_target_cpu_parsed="x86"
                ;;
+      s390x)
+               druntime_target_cpu_parsed="s390x"
+               ;;
+      s390)
+               druntime_target_cpu_parsed="s390"
+               ;;
   esac
    if test "$druntime_target_cpu_parsed" = "aarch64"; then
   DRUNTIME_CPU_AARCH64_TRUE=
@@ -14061,6 +14071,22 @@  else
   DRUNTIME_CPU_X86_FALSE=
 fi
 
+   if test "$druntime_target_cpu_parsed" = "s390x"; then
+  DRUNTIME_CPU_SYSTEMZ_TRUE=
+  DRUNTIME_CPU_SYSTEMZ_FALSE='#'
+else
+  DRUNTIME_CPU_SYSTEMZ_TRUE='#'
+  DRUNTIME_CPU_SYSTEMZ_FALSE=
+fi
+
+   if test "$druntime_target_cpu_parsed" = "s390"; then
+  DRUNTIME_CPU_S390_TRUE=
+  DRUNTIME_CPU_S390_FALSE='#'
+else
+  DRUNTIME_CPU_S390_TRUE='#'
+  DRUNTIME_CPU_S390_FALSE=
+fi
+
 
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for target OS" >&5
@@ -15561,6 +15587,14 @@  if test -z "${DRUNTIME_CPU_X86_TRUE}" && test -z "${DRUNTIME_CPU_X86_FALSE}"; th
   as_fn_error $? "conditional \"DRUNTIME_CPU_X86\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${DRUNTIME_CPU_SYSTEMZ_TRUE}" && test -z "${DRUNTIME_CPU_SYSTEMZ_FALSE}"; then
+  as_fn_error $? "conditional \"DRUNTIME_CPU_SYSTEMZ\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${DRUNTIME_CPU_S390_TRUE}" && test -z "${DRUNTIME_CPU_S390_FALSE}"; then
+  as_fn_error $? "conditional \"DRUNTIME_CPU_S390\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${DRUNTIME_OS_UNIX_TRUE}" && test -z "${DRUNTIME_OS_UNIX_FALSE}"; then
   as_fn_error $? "conditional \"DRUNTIME_OS_UNIX\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
index ef18fb14d0e..b6f43299064 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -98,6 +98,12 @@  else
     DRUNTIME_SOURCES_CONFIGURED += config/x86/switchcontext.S
 endif
 endif
+if DRUNTIME_CPU_SYSTEMZ
+    DRUNTIME_SOURCES_CONFIGURED += config/systemz/get_tls_offset.S
+endif
+if DRUNTIME_CPU_S390
+    DRUNTIME_SOURCES_CONFIGURED += config/s390/get_tls_offset.S
+endif
 
 # Provide __start_minfo, __stop_minfo if linker doesn't.
 if !DRUNTIME_OS_MINFO_BRACKETING
diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
index 44361f9c818..cbbe6298537 100644
--- a/libphobos/libdruntime/Makefile.in
+++ b/libphobos/libdruntime/Makefile.in
@@ -130,6 +130,8 @@  target_triplet = @target@
 @DRUNTIME_CPU_POWERPC64_TRUE@am__append_17 = config/powerpc64/callwithstack.S
 @DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__append_18 = config/mingw/switchcontext.S
 @DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__append_19 = config/x86/switchcontext.S
+@DRUNTIME_CPU_SYSTEMZ_TRUE@am__append_20 = config/systemz/get_tls_offset.S
+@DRUNTIME_CPU_S390_TRUE@am__append_21 = config/s390/get_tls_offset.S
 subdir = libdruntime
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
@@ -450,17 +452,19 @@  am__objects_25 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \
 @DRUNTIME_CPU_POWERPC64_TRUE@am__objects_31 = config/powerpc64/libgdruntime_la-callwithstack.lo
 @DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_32 = config/mingw/libgdruntime_la-switchcontext.lo
 @DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_33 = config/x86/libgdruntime_la-switchcontext.lo
-am__objects_34 = $(am__objects_4) $(am__objects_6) $(am__objects_8) \
+@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_34 = config/systemz/libgdruntime_la-get_tls_offset.lo
+@DRUNTIME_CPU_S390_TRUE@am__objects_35 = config/s390/libgdruntime_la-get_tls_offset.lo
+am__objects_36 = $(am__objects_4) $(am__objects_6) $(am__objects_8) \
 	$(am__objects_10) $(am__objects_12) $(am__objects_14) \
 	$(am__objects_16) $(am__objects_18) $(am__objects_20) \
 	$(am__objects_22) $(am__objects_24) $(am__objects_26) \
 	$(am__objects_27) $(am__objects_28) $(am__objects_29) \
 	$(am__objects_30) $(am__objects_31) $(am__objects_32) \
-	$(am__objects_33)
-am__objects_35 = gcc/config.lo gcc/libbacktrace.lo
-am__objects_36 = $(am__objects_1) $(am__objects_2) $(am__objects_34) \
-	$(am__objects_35)
-am_libgdruntime_la_OBJECTS = $(am__objects_36)
+	$(am__objects_33) $(am__objects_34) $(am__objects_35)
+am__objects_37 = gcc/config.lo gcc/libbacktrace.lo
+am__objects_38 = $(am__objects_1) $(am__objects_2) $(am__objects_36) \
+	$(am__objects_37)
+am_libgdruntime_la_OBJECTS = $(am__objects_38)
 libgdruntime_la_OBJECTS = $(am_libgdruntime_la_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -729,7 +733,8 @@  DRUNTIME_SOURCES_CONFIGURED = $(am__append_1) $(am__append_2) \
 	$(am__append_9) $(am__append_10) $(am__append_11) \
 	$(am__append_12) $(am__append_13) $(am__append_14) \
 	$(am__append_15) $(am__append_16) $(am__append_17) \
-	$(am__append_18) $(am__append_19)
+	$(am__append_18) $(am__append_19) $(am__append_20) \
+	$(am__append_21)
 
 # Provide __start_minfo, __stop_minfo if linker doesn't.
 @DRUNTIME_OS_MINFO_BRACKETING_FALSE@DRTSTUFF = gcc/drtbegin.o gcc/drtend.o
@@ -1736,6 +1741,16 @@  config/x86/$(am__dirstamp):
 	@: > config/x86/$(am__dirstamp)
 config/x86/libgdruntime_la-switchcontext.lo:  \
 	config/x86/$(am__dirstamp)
+config/systemz/$(am__dirstamp):
+	@$(MKDIR_P) config/systemz
+	@: > config/systemz/$(am__dirstamp)
+config/systemz/libgdruntime_la-get_tls_offset.lo:  \
+	config/systemz/$(am__dirstamp)
+config/s390/$(am__dirstamp):
+	@$(MKDIR_P) config/s390
+	@: > config/s390/$(am__dirstamp)
+config/s390/libgdruntime_la-get_tls_offset.lo:  \
+	config/s390/$(am__dirstamp)
 gcc/config.lo: gcc/$(am__dirstamp)
 gcc/libbacktrace.lo: gcc/$(am__dirstamp)
 
@@ -1756,6 +1771,10 @@  mostlyclean-compile:
 	-rm -f config/powerpc/*.lo
 	-rm -f config/powerpc64/*.$(OBJEXT)
 	-rm -f config/powerpc64/*.lo
+	-rm -f config/s390/*.$(OBJEXT)
+	-rm -f config/s390/*.lo
+	-rm -f config/systemz/*.$(OBJEXT)
+	-rm -f config/systemz/*.lo
 	-rm -f config/x86/*.$(OBJEXT)
 	-rm -f config/x86/*.lo
 	-rm -f core/*.$(OBJEXT)
@@ -1876,6 +1895,12 @@  config/mingw/libgdruntime_la-switchcontext.lo: config/mingw/switchcontext.S
 config/x86/libgdruntime_la-switchcontext.lo: config/x86/switchcontext.S
 	$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/x86/libgdruntime_la-switchcontext.lo `test -f 'config/x86/switchcontext.S' || echo '$(srcdir)/'`config/x86/switchcontext.S
 
+config/systemz/libgdruntime_la-get_tls_offset.lo: config/systemz/get_tls_offset.S
+	$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/systemz/libgdruntime_la-get_tls_offset.lo `test -f 'config/systemz/get_tls_offset.S' || echo '$(srcdir)/'`config/systemz/get_tls_offset.S
+
+config/s390/libgdruntime_la-get_tls_offset.lo: config/s390/get_tls_offset.S
+	$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/s390/libgdruntime_la-get_tls_offset.lo `test -f 'config/s390/get_tls_offset.S' || echo '$(srcdir)/'`config/s390/get_tls_offset.S
+
 .c.o:
 	$(AM_V_CC)$(COMPILE) -c -o $@ $<
 
@@ -1899,6 +1924,8 @@  clean-libtool:
 	-rm -rf config/mips/.libs config/mips/_libs
 	-rm -rf config/powerpc/.libs config/powerpc/_libs
 	-rm -rf config/powerpc64/.libs config/powerpc64/_libs
+	-rm -rf config/s390/.libs config/s390/_libs
+	-rm -rf config/systemz/.libs config/systemz/_libs
 	-rm -rf config/x86/.libs config/x86/_libs
 	-rm -rf core/.libs core/_libs
 	-rm -rf core/internal/.libs core/internal/_libs
@@ -2054,6 +2081,8 @@  distclean-generic:
 	-rm -f config/mips/$(am__dirstamp)
 	-rm -f config/powerpc/$(am__dirstamp)
 	-rm -f config/powerpc64/$(am__dirstamp)
+	-rm -f config/s390/$(am__dirstamp)
+	-rm -f config/systemz/$(am__dirstamp)
 	-rm -f config/x86/$(am__dirstamp)
 	-rm -f core/$(am__dirstamp)
 	-rm -f core/internal/$(am__dirstamp)
diff --git a/libphobos/libdruntime/config/s390/get_tls_offset.S b/libphobos/libdruntime/config/s390/get_tls_offset.S
new file mode 100644
index 00000000000..aaca05cce07
--- /dev/null
+++ b/libphobos/libdruntime/config/s390/get_tls_offset.S
@@ -0,0 +1,25 @@ 
+/* IBM Z support code for TLS offsets.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "../systemz/get_tls_offset.S"
diff --git a/libphobos/libdruntime/config/systemz/get_tls_offset.S b/libphobos/libdruntime/config/systemz/get_tls_offset.S
new file mode 100644
index 00000000000..d45c97a803d
--- /dev/null
+++ b/libphobos/libdruntime/config/systemz/get_tls_offset.S
@@ -0,0 +1,79 @@ 
+/* IBM Z support code for TLS offsets.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* __tls_get_offset expects the GOT pointer in %r12 and adds
+   it to its argument in %r2.  In order to get the offset of
+   ti, we load it into %r2, subtract the current %r12 from %r2
+   so the addition will result in a nop (%r2 - %r12 + %r12).
+
+   Note: This file is shared between systemz and s390 as the
+	 same file is used in multilib case for s390x and s390.  */
+
+#include "../common/threadasm.S"
+
+    .text
+    .globl CSYM(ibmz_get_tls_offset)
+    .type CSYM(ibmz_get_tls_offset), @function
+    .align 8
+CSYM(ibmz_get_tls_offset):
+    .cfi_startproc
+
+#ifdef __s390x__
+     .machinemode zarch
+     stmg	%r14,%r15,112(%r15)
+     .cfi_offset 14, -48
+     .cfi_offset 15, -40
+     aghi	%r15,-160
+     .cfi_def_cfa_offset 320
+     sgr	%r2,%r12
+     brasl	%r14,__tls_get_offset@PLT
+     lg		%r4,272(%r15)
+     lmg	%r14,%r15,272(%r15)
+     .cfi_restore 15
+     .cfi_restore 14
+     .cfi_def_cfa_offset 160
+     br	%r4
+#else
+    .machinemode esa
+    stm	%r12,%r15,48(%r15)
+    .cfi_offset 12, -48
+    .cfi_offset 13, -44
+    .cfi_offset 14, -40
+    .cfi_offset 15, -36
+    ahi	%r15,-96
+    .cfi_def_cfa_offset 192
+    larl	%r12,_GLOBAL_OFFSET_TABLE_
+    sr		%r2,%r12
+    brasl	%r14,__tls_get_offset@PLT
+    l		%r4,152(%r15)
+    lm		%r12,%r15,144(%r15)
+    .cfi_restore 15
+    .cfi_restore 14
+    .cfi_restore 13
+    .cfi_restore 12
+    .cfi_def_cfa_offset 96
+    br	%r4
+#endif
+     .cfi_endproc
+     .size	ibmz_get_tls_offset, .-ibmz_get_tls_offset
diff --git a/libphobos/libdruntime/gcc/sections/elf_shared.d b/libphobos/libdruntime/gcc/sections/elf_shared.d
index b28c8dcb9eb..d2834d8b20d 100644
--- a/libphobos/libdruntime/gcc/sections/elf_shared.d
+++ b/libphobos/libdruntime/gcc/sections/elf_shared.d
@@ -1028,7 +1028,7 @@  struct tls_index
 }
 
 extern(C) void* __tls_get_addr(tls_index* ti) nothrow @nogc;
-extern(C) void* __tls_get_addr_internal(tls_index* ti) nothrow @nogc;
+extern(C) void* ibmz_get_tls_offset(tls_index *ti) nothrow @nogc;
 
 /* The dynamic thread vector (DTV) pointers may point 0x8000 past the start of
  * each TLS block. This is at least true for PowerPC and Mips platforms.
@@ -1086,9 +1086,11 @@  void[] getTLSRange(size_t mod, size_t sz) nothrow @nogc
         auto ti = tls_index(mod, 0);
         version (IBMZ_Any)
         {
-            auto idx = cast(void *)__tls_get_addr_internal(&ti)
-                + cast(ulong)__builtin_thread_pointer();
-            return idx[0 .. sz];
+            // IBM Z only provides __tls_get_offset instead of __tls_get_addr
+            // which returns an offset relative to the thread pointer.
+            auto addr = ibmz_get_tls_offset(&ti);
+            addr = addr + cast(c_ulong)__builtin_thread_pointer();
+            return addr[0 .. sz];
         }
         else
             return (__tls_get_addr(&ti)-TLS_DTV_OFFSET)[0 .. sz];
diff --git a/libphobos/m4/druntime/cpu.m4 b/libphobos/m4/druntime/cpu.m4
index aa5b5ea08fc..4887248fd09 100644
--- a/libphobos/m4/druntime/cpu.m4
+++ b/libphobos/m4/druntime/cpu.m4
@@ -25,6 +25,12 @@  AC_DEFUN([DRUNTIME_CPU_SOURCES],
       i[[34567]]86|x86_64)
                druntime_target_cpu_parsed="x86"
                ;;
+      s390x)
+               druntime_target_cpu_parsed="s390x"
+               ;;
+      s390)
+               druntime_target_cpu_parsed="s390"
+               ;;
   esac
   AM_CONDITIONAL([DRUNTIME_CPU_AARCH64],
                  [test "$druntime_target_cpu_parsed" = "aarch64"])
@@ -38,6 +44,10 @@  AC_DEFUN([DRUNTIME_CPU_SOURCES],
                  [test "$druntime_target_cpu_parsed" = "powerpc64"])
   AM_CONDITIONAL([DRUNTIME_CPU_X86],
                  [test "$druntime_target_cpu_parsed" = "x86"])
+  AM_CONDITIONAL([DRUNTIME_CPU_SYSTEMZ],
+                 [test "$druntime_target_cpu_parsed" = "s390x"])
+  AM_CONDITIONAL([DRUNTIME_CPU_S390],
+                 [test "$druntime_target_cpu_parsed" = "s390"])
 ])