On Sat, 27 Apr 2019 at 12:24, Jakub Jelinek <ja...@redhat.com> wrote: > > On Sat, Apr 27, 2019 at 11:26:15AM +0200, Matthias Klose wrote: > > On 15.03.19 16:49, Robin Dapp wrote: > > > during the last few days I tried to get D running on s390x (apparently > > > the first Big Endian platform to try it?). I did not yet go through the > > > code systematically and add a version(SystemZ) in every place where it > > > might be needed but rather tried to fix test failures as they arose. > > > > this now fails on trunk and the gcc-9-branch with a multilib build: > > > > > > /<<PKGBUILDDIR>>/src/libphobos/libdruntime/core/sys/posix/ucontext.d:769:9: > > error: static assert "unimpleme > > nted" > > 769 | static assert(0, "unimplemented"); > > | ^ > > make[10]: *** [Makefile:2149: core/thread.lo] Error 1 > > make[10]: Leaving directory > > '/<<PKGBUILDDIR>>/build/s390x-linux-gnu/32/libphobos/libdruntime' > > make[9]: *** [Makefile:473: all-recursive] Error 1 > > make[10]: *** [Makefile:2149: core/thread.lo] Error 1 > > make[10]: Leaving directory > > '/<<PKGBUILDDIR>>/build/s390x-linux-gnu/32/libphobos/libdruntime' > > make[9]: *** [Makefile:473: all-recursive] Error 1 > > Ugh, can we disable D for GCC 9.1 on s390x then, on the trunk look through > all files that only use version (SystemZ) and don't use version (S390) at > least > find -type f | xargs grep -l SystemZ | xargs grep -L S390 > ./src/std/uni.d > ./src/std/math.d > ./src/std/experimental/allocator/building_blocks/region.d > ./libdruntime/gcc/sections/elf_shared.d > ./libdruntime/core/sys/linux/link.d > ./libdruntime/core/sys/posix/setjmp.d > ./libdruntime/core/sys/posix/ucontext.d > ./libdruntime/core/sys/posix/sys/stat.d > and make sure it works also for s390 31-bit and finally backport to 9.2? > > E.g. in src/std/math.d I wonder if it just shouldn't be done through > version (S390) version = IBMZ_Any; > version (SystemZ) version = IBMZ_Any; > and using later version (IBMZ_Any) instead of version (SystemZ). Guess > in various other spots, except for those where structure sizes are needed. > > Robin, have you been testing with --disable-multilib or something similar? >
I built all compilers last night from config-list.mk, so I had a ready cross compiler available. With the following patch, all compiles successfully with -fsyntax-only for both s390x-linux and s390-linux, though checking on native hardware would be preferred. -- Iain ---
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/std/math.d b/libphobos/src/std/math.d index 6dec9cee9a0..7bc94220fc7 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; @@ -5235,7 +5237,7 @@ struct FloatingPointControl | inexactException, } } - else version (SystemZ) + else version (IBMZ_Any) { enum : ExceptionMask { @@ -5373,7 +5375,7 @@ private: { alias ControlState = ulong; } - else version (SystemZ) + else version (IBMZ_Any) { alias ControlState = uint; }