On Sat, Apr 27, 2019 at 02:08:06PM +0200, Iain Buclaw wrote:
> 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.

I can confirm s390x-linux with
--enable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto
fails to bootstrap on gcc-9-branch without this patch and succeeds to
bootstrap with this patch.
The patch is ok to backport to gcc-9-branch once you commit it to trunk
(would be nice if you could do it soon, so that we don't ship 9.1 broken on
s390x-linux).

> 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;
>      }


        Jakub

Reply via email to