From ca0ddb398fb6173eb97c5d70265e79b9ea2bdc9d Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 29 Apr 2019 05:42:48 +0000 Subject: [PATCH] libphobos: Fix multilib builds for s390x-linux-gnu Merges upstream druntime aab44549, phobos 3dc363783. Reviewed-on: https://github.com/dlang/druntime/pull/2590 https://github.com/dlang/phobos/pull/6983 libphobos/ChangeLog: 2019-04-28 Iain Buclaw * libdruntime/gcc/sections/elf_shared.d (IBMZ_Any): Define when version S390 or SystemZ. Use condition instead of SystemZ. (getTLSRange): Return null on GNU_EMUTLS targets. From-SVN: r270639 --- libphobos/libdruntime/MERGE | 2 +- libphobos/libdruntime/core/sys/linux/link.d | 9 ++- libphobos/libdruntime/core/sys/posix/setjmp.d | 9 +++ .../libdruntime/core/sys/posix/sys/stat.d | 76 +++++++++++++++++++ .../libdruntime/core/sys/posix/ucontext.d | 4 +- .../libdruntime/gcc/sections/elf_shared.d | 35 +++++---- libphobos/src/MERGE | 2 +- libphobos/src/std/math.d | 6 +- 8 files changed, 122 insertions(+), 21 deletions(-) diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index d947097ec65..dec75f7cb33 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -1ca80e4e0cf460575752a0c157ca52c184f4b982 +aab44549221cb29434fe2feccaf1174af54dd79d The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/core/sys/linux/link.d b/libphobos/libdruntime/core/sys/linux/link.d index b57b5e5d00f..e242d2b2876 100644 --- a/libphobos/libdruntime/core/sys/linux/link.d +++ b/libphobos/libdruntime/core/sys/linux/link.d @@ -18,8 +18,10 @@ version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; +version (S390) version = IBMZ_Any; version (SPARC) version = SPARC_Any; version (SPARC64) version = SPARC_Any; +version (SystemZ) version = IBMZ_Any; version (X86) version = X86_Any; version (X86_64) version = X86_Any; @@ -71,11 +73,14 @@ else version (SPARC_Any) alias __WORDSIZE __ELF_NATIVE_CLASS; alias uint32_t Elf_Symndx; } -else version (SystemZ) +else version (IBMZ_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/elfclass.h alias __WORDSIZE __ELF_NATIVE_CLASS; - alias uint64_t Elf_Symndx; + static if (__WORDSIZE == 64) + alias uint64_t Elf_Symndx; + else + alias uint32_t Elf_Symndx; } else static assert(0, "unimplemented"); diff --git a/libphobos/libdruntime/core/sys/posix/setjmp.d b/libphobos/libdruntime/core/sys/posix/setjmp.d index 8b636683e3d..fcdbca496c4 100644 --- a/libphobos/libdruntime/core/sys/posix/setjmp.d +++ b/libphobos/libdruntime/core/sys/posix/setjmp.d @@ -153,6 +153,15 @@ version (CRuntime_Glibc) } alias __jmp_buf = __riscv_jmp_buf[1]; } + else version (S390) + { + struct __s390_jmp_buf + { + c_long[10] __gregs; + c_long[4] __fpregs; + } + alias __jmp_buf = __s390_jmp_buf[1]; + } else version (SystemZ) { struct __s390_jmp_buf diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index 963a241f076..76e4460550d 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -791,6 +791,82 @@ version (CRuntime_Glibc) } static assert(stat_t.sizeof == 144); } + else version (S390) + { + private + { + alias __dev_t = ulong; + alias __ino_t = c_ulong; + alias __ino64_t = ulong; + alias __mode_t = uint; + alias __nlink_t = uint; + alias __uid_t = uint; + alias __gid_t = uint; + alias __off_t = c_long; + alias __off64_t = long; + alias __blksize_t = c_long; + alias __blkcnt_t = c_long; + alias __blkcnt64_t = long; + alias __timespec = timespec; + alias __time_t = time_t; + } + struct stat_t + { + __dev_t st_dev; + uint __pad1; + static if (!__USE_FILE_OFFSET64) + __ino_t st_ino; + else + __ino_t __st_ino; + __mode_t st_mode; + __nlink_t st_nlink; + __uid_t st_uid; + __gid_t st_gid; + __dev_t st_rdev; + uint __pad2; + static if (!__USE_FILE_OFFSET64) + __off_t st_size; + else + __off64_t st_size; + __blksize_t st_blksize; + static if (!__USE_FILE_OFFSET64) + __blkcnt_t st_blocks; + else + __blkcnt64_t st_blocks; + static if (__USE_XOPEN2K8) + { + __timespec st_atim; + __timespec st_mtim; + __timespec st_ctim; + extern(D) + { + @property ref time_t st_atime() { return st_atim.tv_sec; } + @property ref time_t st_mtime() { return st_mtim.tv_sec; } + @property ref time_t st_ctime() { return st_ctim.tv_sec; } + } + } + else + { + __time_t st_atime; + c_ulong st_atimensec; + __time_t st_mtime; + c_ulong st_mtimensec; + __time_t st_ctime; + c_ulong st_ctimensec; + } + static if (!__USE_FILE_OFFSET64) + { + c_ulong __glibc_reserved4; + c_ulong __glibc_reserved5; + } + else + __ino64_t st_ino; + } + static if (__USE_FILE_OFFSET64) + static assert(stat_t.sizeof == 104); + else + static assert(stat_t.sizeof == 88); + } else version (SystemZ) { private diff --git a/libphobos/libdruntime/core/sys/posix/ucontext.d b/libphobos/libdruntime/core/sys/posix/ucontext.d index 6200bfc3fe2..d664f2e5e41 100644 --- a/libphobos/libdruntime/core/sys/posix/ucontext.d +++ b/libphobos/libdruntime/core/sys/posix/ucontext.d @@ -25,8 +25,10 @@ nothrow: version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; +version (S390) version = IBMZ_Any; version (SPARC) version = SPARC_Any; version (SPARC64) version = SPARC_Any; +version (SystemZ) version = IBMZ_Any; version (X86) version = X86_Any; version (X86_64) version = X86_Any; @@ -719,7 +721,7 @@ version (CRuntime_Glibc) alias greg_t = c_ulong; alias gregset_t = greg_t[NGREG]; } - else version (SystemZ) + else version (IBMZ_Any) { public import core.sys.posix.signal : sigset_t; diff --git a/libphobos/libdruntime/gcc/sections/elf_shared.d b/libphobos/libdruntime/gcc/sections/elf_shared.d index 1eafecdd322..7f9036bf505 100644 --- a/libphobos/libdruntime/gcc/sections/elf_shared.d +++ b/libphobos/libdruntime/gcc/sections/elf_shared.d @@ -24,6 +24,8 @@ module gcc.sections.elf_shared; version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; +version (S390) version = IBMZ_Any; +version (SystemZ) version = IBMZ_Any; version (CRuntime_Glibc) enum SharedELF = true; else version (CRuntime_Musl) enum SharedELF = true; @@ -1060,7 +1062,7 @@ else version (MIPS32) enum TLS_DTV_OFFSET = 0x8000; else version (MIPS64) enum TLS_DTV_OFFSET = 0x8000; -else version (SystemZ) +else version (IBMZ_Any) enum TLS_DTV_OFFSET = 0x0; else static assert( false, "Platform not supported." ); @@ -1070,20 +1072,25 @@ void[] getTLSRange(size_t mod, size_t sz) nothrow @nogc if (mod == 0) return null; - version (Solaris) + version (GNU_EMUTLS) + return null; // Handled in scanTLSRanges(). + else { - static if (!OS_Have_Dlpi_Tls_Modid) - mod -= 1; - } + version (Solaris) + { + static if (!OS_Have_Dlpi_Tls_Modid) + mod -= 1; + } - // base offset - auto ti = tls_index(mod, 0); - version (SystemZ) - { - auto idx = cast(void *)__tls_get_addr_internal(&ti) - + cast(ulong)__builtin_thread_pointer(); - return idx[0 .. sz]; + // base offset + 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]; + } + else + return (__tls_get_addr(&ti)-TLS_DTV_OFFSET)[0 .. sz]; } - else - return (__tls_get_addr(&ti)-TLS_DTV_OFFSET)[0 .. sz]; } diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index 685b4e65d24..cfac5c66b4e 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -b5e9661a089b6514e01fa5195c0f2bc9cc06eddd +3dc363783ea7b1e82336983486a14f3f44bbeadd The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d index 062b57035ca..7e6a97f1dcd 100644 --- a/libphobos/src/std/math.d +++ b/libphobos/src/std/math.d @@ -160,8 +160,10 @@ version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (AArch64) version = ARM_Any; version (ARM) version = ARM_Any; +version (S390) version = IBMZ_Any; version (SPARC) version = SPARC_Any; version (SPARC64) version = SPARC_Any; +version (SystemZ) version = IBMZ_Any; version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; @@ -5241,7 +5243,7 @@ struct FloatingPointControl | inexactException, } } - else version (SystemZ) + else version (IBMZ_Any) { enum : ExceptionMask { @@ -5379,7 +5381,7 @@ private: { alias ControlState = ulong; } - else version (SystemZ) + else version (IBMZ_Any) { alias ControlState = uint; } -- 2.30.2