diff --git a/cross/gcc-aarch64/0026-ada-musl-support-fixes.patch b/cross/gcc-aarch64/0026-ada-musl-support-fixes.patch index 98b7f90eb7e64009ca4b972f7ee258886680cd3c..91a8268ab8b0ea6d0526ea15d017fc3dbc45e141 100644 --- a/cross/gcc-aarch64/0026-ada-musl-support-fixes.patch +++ b/cross/gcc-aarch64/0026-ada-musl-support-fixes.patch @@ -4,17 +4,17 @@ Date: Fri, 21 Aug 2020 07:07:48 +0000 Subject: [PATCH 26/35] ada: musl support fixes --- - gcc/ada/Makefile.rtl | 10 +++++----- + gcc/ada/Makefile.rtl | 16 ++++++++-------- gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- gcc/ada/adaint.h | 10 ++++------ gcc/ada/terminals.c | 8 ++++---- - 4 files changed, 32 insertions(+), 30 deletions(-) + 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl -index 96306f8cc9a..090b6770ae5 100644 +index 32cbdb692..463028fbe 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl -@@ -1549,7 +1549,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) +@@ -1558,7 +1558,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) s-intman.adb<libgnarl/s-intman__posix.adb \ s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -23,7 +23,16 @@ index 96306f8cc9a..090b6770ae5 100644 a-exetim.adb<libgnarl/a-exetim__posix.adb \ a-exetim.ads<libgnarl/a-exetim__default.ads \ s-linux.ads<libgnarl/s-linux.ads \ -@@ -2174,7 +2174,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) +@@ -2144,7 +2144,7 @@ ifeq ($(strip $(filter-out loongarch% linux%,$(target_cpu) $(target_os))),) + g-sercom.adb<libgnat/g-sercom__linux.adb \ + $(TRASYM_DWARF_UNIX_PAIRS) \ + $(GNATRTL_128BIT_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.ads<libgnat/system-linux-loongarch.ads +@@ -2232,7 +2232,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) s-tasinf.adb<libgnarl/s-tasinf__linux.adb \ s-taspri.ads<libgnarl/s-taspri__posix.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -32,7 +41,7 @@ index 96306f8cc9a..090b6770ae5 100644 $(ATOMICS_TARGET_PAIRS) \ $(ATOMICS_BUILTINS_TARGET_PAIRS) \ system.ads<libgnat/system-linux-ppc.ads -@@ -2205,7 +2205,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) +@@ -2267,7 +2267,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) endif # ARM linux, GNU eabi @@ -50,7 +59,7 @@ index 96306f8cc9a..090b6770ae5 100644 s-mudido.adb<libgnarl/s-mudido__affinity.adb \ s-osinte.ads<libgnarl/s-osinte__linux.ads \ s-osinte.adb<libgnarl/s-osinte__posix.adb \ -@@ -2420,7 +2420,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) +@@ -2488,7 +2488,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -59,7 +68,16 @@ index 96306f8cc9a..090b6770ae5 100644 $(ATOMICS_TARGET_PAIRS) \ $(ATOMICS_BUILTINS_TARGET_PAIRS) \ $(GNATRTL_128BIT_PAIRS) \ -@@ -2524,7 +2524,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) +@@ -2592,7 +2592,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + s-taspri.ads<libgnarl/s-taspri__posix.ads \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(X86_64_TARGET_PAIRS) \ + $(SIMD_PATH_TARGET_PAIRS) \ +@@ -2637,7 +2637,7 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),) s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ s-taspri.ads<libgnarl/s-taspri__posix.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -69,10 +87,10 @@ index 96306f8cc9a..090b6770ae5 100644 $(X86_64_TARGET_PAIRS) \ $(SIMD_PATH_TARGET_PAIRS) \ diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c -index 8522094164e..92b230a462b 100644 +index 74aa3c412..ef6118f37 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c -@@ -91,6 +91,11 @@ +@@ -94,6 +94,11 @@ #include <sys/param.h> #include <sys/pstat.h> #endif @@ -84,7 +102,7 @@ index 8522094164e..92b230a462b 100644 #ifdef __PikeOS__ #define __BSD_VISIBLE 1 -@@ -3438,7 +3443,6 @@ __gnat_lwp_self (void) +@@ -3465,7 +3470,6 @@ __gnat_lwp_self (void) #endif #if defined (__linux__) @@ -92,7 +110,7 @@ index 8522094164e..92b230a462b 100644 /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static -@@ -3448,7 +3452,7 @@ __gnat_lwp_self (void) +@@ -3475,7 +3479,7 @@ __gnat_lwp_self (void) /* Dynamic cpu sets */ @@ -101,7 +119,7 @@ index 8522094164e..92b230a462b 100644 __gnat_cpu_alloc (size_t count) { return CPU_ALLOC (count); -@@ -3461,33 +3465,33 @@ __gnat_cpu_alloc_size (size_t count) +@@ -3488,33 +3492,33 @@ __gnat_cpu_alloc_size (size_t count) } void @@ -143,7 +161,7 @@ index 8522094164e..92b230a462b 100644 } size_t -@@ -3497,23 +3501,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) +@@ -3524,23 +3528,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) } void @@ -173,7 +191,7 @@ index 8522094164e..92b230a462b 100644 #endif /* !CPU_ALLOC */ #endif /* __linux__ */ diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h -index 987432c9307..4d782f07de9 100644 +index 0cbfd0e15..f97ed905b 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -319,13 +319,11 @@ extern void *__gnat_lwp_self (void); @@ -195,10 +213,10 @@ index 987432c9307..4d782f07de9 100644 #if defined (_WIN32) diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c -index c0ee4a16bb1..ed796a48c1b 100644 +index 05af82c27..626ac35bc 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c -@@ -1127,7 +1127,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, +@@ -1134,7 +1134,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, /* POSIX does not specify how to open the master side of a terminal.Several methods are available (system specific): 1- using a cloning device (USE_CLONE_DEVICE) @@ -207,7 +225,7 @@ index c0ee4a16bb1..ed796a48c1b 100644 3- openpty (USE_OPENPTY) When using the cloning device method, the macro USE_CLONE_DEVICE should -@@ -1141,7 +1141,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, +@@ -1148,7 +1148,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, #if defined (__APPLE__) || defined (BSD) #define USE_OPENPTY #elif defined (__linux__) @@ -216,7 +234,7 @@ index c0ee4a16bb1..ed796a48c1b 100644 #elif defined (__sun__) #define USE_CLONE_DEVICE "/dev/ptmx" #elif defined (_AIX) -@@ -1190,8 +1190,8 @@ allocate_pty_desc (pty_desc **desc) { +@@ -1197,8 +1197,8 @@ allocate_pty_desc (pty_desc **desc) { int master_fd = -1; char *slave_name = NULL; @@ -227,6 +245,3 @@ index c0ee4a16bb1..ed796a48c1b 100644 #elif defined (USE_OPENPTY) status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); #elif defined (USE_CLONE_DEVICE) --- -2.41.0 - diff --git a/cross/gcc-aarch64/0036-libphobos-add-riscv64-and-loongarch64-support.patch b/cross/gcc-aarch64/0036-libphobos-add-riscv64-and-loongarch64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..ba8377b1dda7ba1d5253d194996f4c79d974a3b1 --- /dev/null +++ b/cross/gcc-aarch64/0036-libphobos-add-riscv64-and-loongarch64-support.patch @@ -0,0 +1,87 @@ +From: Celeste <cielesti@protonmail.com> +Date: Mon, 2 Sep 2024 02:54:17 +0000 +Subject: [PATCH] libphobos: add riscv64 and loongarch64 support + +Add musl support for these 2 architectures based on fenv.h and signal.h from: + +https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits?h=v1.2.5 + +https://git.musl-libc.org/cgit/musl/tree/arch/loongarch64/bits?h=v1.2.5 +--- + libphobos/libdruntime/core/stdc/fenv.d | 13 +++++++++++++ + libphobos/libdruntime/core/sys/posix/signal.d | 10 ++++++++++ + 2 files changed, 23 insertions(+) + +diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d +index a7364c0a..5b327e4a 100644 +--- a/libphobos/libdruntime/core/stdc/fenv.d ++++ b/libphobos/libdruntime/core/stdc/fenv.d +@@ -436,20 +436,33 @@ else version (CRuntime_Musl) + ushort __cs_selector; + ushort __opcode; + uint __data_offset; + ushort __data_selector; + ushort __unused5; + version (X86_64) + uint __mxcsr; + } + alias ushort fexcept_t; + } ++ else version (RISCV64) ++ { ++ alias uint fenv_t; ++ alias uint fexcept_t; ++ } ++ else version (LoongArch64) ++ { ++ struct fenv_t ++ { ++ uint __cw; ++ } ++ alias uint fexcept_t; ++ } + else + { + static assert(false, "Architecture not supported."); + } + } + else version (CRuntime_Newlib) + { + version (AArch64) + { + alias fenv_t = ulong; +diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d +index a8b7f751..78d8b3cd 100644 +--- a/libphobos/libdruntime/core/sys/posix/signal.d ++++ b/libphobos/libdruntime/core/sys/posix/signal.d +@@ -2751,20 +2751,30 @@ else version (CRuntime_Musl) + else version (PPC_Any) + { + enum MINSIGSTKSZ = 4096; + enum SIGSTKSZ = 10240; + } + else version (X86_Any) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } ++ else version (RISCV64) ++ { ++ enum MINSIGSTKSZ = 2048; ++ enum SIGSTKSZ = 8192; ++ } ++ else version (LoongArch64) ++ { ++ enum MINSIGSTKSZ = 4096; ++ enum SIGSTKSZ = 16384; ++ } + else + static assert(0, "unimplemented"); + + //ucontext_t (defined in core.sys.posix.ucontext) + //mcontext_t (defined in core.sys.posix.ucontext) + + version (MIPS_Any) + { + struct stack_t + { diff --git a/cross/gcc-aarch64/APKBUILD b/cross/gcc-aarch64/APKBUILD index 353ba7202f43ad406e01777d8bdbc9e2436fca1f..65b4d553085580c34b43c050f7ea47f27b85a063 100644 --- a/cross/gcc-aarch64/APKBUILD +++ b/cross/gcc-aarch64/APKBUILD @@ -34,7 +34,7 @@ _pkgsnap="${pkgver##*_git}" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname=gcc-aarch64 -pkgrel=2 +pkgrel=3 pkgdesc="Stage2 cross-compiler for aarch64" url="https://gcc.gnu.org" arch="x86_64" @@ -64,6 +64,7 @@ _libitm=true if [ "$CHOST" != "$CTARGET" ]; then if [ "$BOOTSTRAP" = nolibc ]; then LANG_CXX=false + LANG_D=false LANG_ADA=false _libgcc=false _builddir="$srcdir/build-cross-pass2" @@ -73,7 +74,6 @@ if [ "$CHOST" != "$CTARGET" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LANG_D=false LANG_JIT=false _libgomp=false _libatomic=false @@ -115,7 +115,6 @@ elif [ "$CBUILD" != "$CHOST" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LANG_D=false LANG_JIT=false STRIP_FOR_TARGET=${CROSS_COMPILE}strip @@ -140,11 +139,11 @@ else export BOOT_LDFLAGS="$LDFLAGS" fi -case "$CARCH" in +case "$CTARGET_ARCH" in # GDC hasn't been ported to PowerPC # See libphobos/configure.tgt in GCC sources for supported targets # riscv fails with: error: static assert "unimplemented" -ppc64le|riscv64|loongarch64) LANG_D=false ;; +ppc64le|riscv64) LANG_D=false ;; # GDC does currently not work on 32-bit musl architectures. # This is a known upstream issue. # See: https://github.com/dlang/druntime/pull/3383 @@ -171,7 +170,7 @@ esac # currently on x86, x86_64 and ia64 _libquadmath=$LANG_FORTRAN case "$CTARGET_ARCH" in -x86 | x86_64) _libquadmath=$LANG_FORTRAN ;; +x86 | x86_64 | ppc64le) _libquadmath=$LANG_FORTRAN ;; *) _libquadmath=false ;; esac @@ -184,13 +183,8 @@ if $_libgomp; then subpackages="$subpackages libgomp::$CTARGET_ARCH" fi -case "$CARCH" in -riscv64) -LANG_ADA=false;; -esac - case "$CTARGET_ARCH" in -loongarch64) +riscv64|loongarch64) LANG_ADA=false;; esac @@ -199,9 +193,17 @@ if $LANG_CXX; then _languages="$_languages,c++" fi if $LANG_D; then - subpackages="$subpackages libgphobos::$CTARGET_ARCH gcc-gdc$_target:gdc" + subpackages="$subpackages gcc-gdc$_target:gdc" _languages="$_languages,d" - makedepends_build="$makedepends_build libucontext-dev gcc-gdc-bootstrap" + makedepends_build="$makedepends_build libucontext-dev" + if [ "$CBUILD" = "$CTARGET" ]; then + makedepends_build="$makedepends_build gcc-gdc-bootstrap" + subpackages="$subpackages libgphobos::$CTARGET_ARCH" + else + # shared libgphobos is for D programs to link against, so + # skip building that while cross-compiling the GDC compiler + makedepends_build="$makedepends_build gcc-gdc gcc-gdc$_cross" + fi fi if $LANG_OBJC; then subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc" @@ -278,7 +280,9 @@ source="https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkg 0033-libphobos-do-not-use-LFS64-symbols.patch 0034-libgo-fix-lfs64-use.patch 0035-loongarch-disable-multilib-support.patch + 0036-libphobos-add-riscv64-and-loongarch64-support.patch fix-arm64.patch + ppc64le-quadmath.patch " # secfixes: @@ -339,7 +343,7 @@ build() { i586-*-*-*) _arch_configure="--with-arch=pentium-m --with-fpmath=sse --with-tune=generic --enable-cld";; s390x-*-*-*) _arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";; riscv64-*-*-*) _arch_configure="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic";; - loongarch64-*-*-*) _arch_configure="--with-arch=loongarch64 --with-abi=lp64d --with-tls=trad";; + loongarch64-*-*-*) _arch_configure="--with-arch=loongarch64 --with-abi=lp64d";; esac case "$CTARGET_ARCH" in @@ -360,20 +364,23 @@ build() { case "$BOOTSTRAP" in nolibc) _bootstrap_configure="--with-newlib --disable-shared --enable-threads=no" ;; - *) _bootstrap_configure="--enable-shared --enable-threads --enable-tls" ;; + *) + # cross-bootstrap GDC with a static libphobos: due to GCC's + # ./configure not having a --disable-shared=libphobos option, + # we have to use --enable-shared with everything else instead. + if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then + _bootstrap_configure="--enable-shared=libgcc,libstdc++,libffi,zlib,boehm-gc,ada,libada,libgo,libobjc,libatomic,libgomp,libitm,libgfortran,libquadmath" + else + _bootstrap_configure="--enable-shared" + fi + _bootstrap_configure="$_bootstrap_configure --enable-threads --enable-tls" + ;; esac $_libgomp || _bootstrap_configure="$_bootstrap_configure --disable-libgomp" $_libatomic || _bootstrap_configure="$_bootstrap_configure --disable-libatomic" $_libitm || _bootstrap_configure="$_bootstrap_configure --disable-libitm" - if ! $_libquadmath; then - _arch_configure="$_arch_configure --disable-libquadmath" - # ppc64le needs both --disable-libquadmath{,-support} - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116007 - [ "$CARCH" = "ppc64le" ] && - _arch_configure="$_arch_configure - --disable-libquadmath-support" - fi + $_libquadmath || _arch_configure="$_arch_configure --disable-libquadmath" msg "Building the following:" echo "" @@ -427,6 +434,10 @@ build() { --with-pkgversion="$version" msg "building gcc" + if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then + # cross-compiling libphobos with parallel make fails + make all-target-libphobos + fi make # we build gccjit separate to not build all of gcc with --enable-host-shared @@ -667,9 +678,9 @@ libgphobos() { gdc() { pkgdesc="GCC-based D language compiler" - depends="gcc=$_gccrel libgphobos=$_gccrel musl-dev" - depends="$depends libucontext-dev" - provides="gcc-gdc-bootstrap=$_gccrel" + depends="gcc$_target=$_gccrel musl-dev libucontext-dev" + [ "$CBUILD" = "$CTARGET" ] && depends="$depends libgphobos=$_gccrel" + [ "$CHOST" = "$CTARGET" ] && provides="gcc-gdc-bootstrap=$_gccrel" mkdir -p "$subpkgdir/$_gcclibexec" \ "$subpkgdir"/$_gcclibdir/include/d/ \ @@ -680,13 +691,25 @@ gdc() { # without installing the compiler mv "$pkgdir/$_gcclibexec/d21" "$subpkgdir/$_gcclibexec/" mv "$pkgdir"/$_gcclibdir/include/d/* "$subpkgdir"/$_gcclibdir/include/d/ - mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + if [ "$CBUILD" = "$CTARGET" ]; then + mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ + fi + if [ "$CHOST" = "$CTARGET" ]; then + mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ + else + mkdir -p "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgdruntime.a \ + "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgphobos.a \ + "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgphobos.spec \ + "$subpkgdir"/usr/$CTARGET/lib/ + fi mv "$pkgdir"/usr/bin/$CTARGET-gdc "$subpkgdir"/usr/bin/ - mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ } libgo() { @@ -828,7 +851,7 @@ f382eb5f7c2c60c5a23fac587c9629a3059d7be0898e97a1feaf9b9cbe1ef4693cc1177eb29333e8 abf845792433a21fed5dd06167b9f6cf5e8f8026a409acce93824e466c5148e192bf5f404a271931fe4b65283499329bf67bb01019f2f3e02501f20619404e6c 0023-riscv-disable-multilib-support.patch ab88a2f63e3545bbc36537aa9a86f2c6c35e41bbf702d6e13743a405cdac4f901eed5737189b780da96647fea9f5d863fdc76373f25a00064106dcb5514d6d87 0024-always-build-libgcc_eh.a.patch 8fdbe0c8bf4ca60f458a33e59027de03d15ac91933fe46d8ca62119346d20b9bc2447c0bf22bceb63d0cf8613ab61512d9197f4e6c2224af473b63ef9f254295 0025-ada-libgnarl-compatibility-for-musl.patch -5fd23a506b55c88d4f000e01c539eb25d6da2516949c9d7a1c9ee20f4c6b627e4788541284d9c14c33bafa7cb43ce2e0469dd91006152f00e30815107150320f 0026-ada-musl-support-fixes.patch +684bf2db12aa45e8db7a895ab0f227b4e4351f611b4fcc6e1745d7ad94d31b3554f39d8cf9e2203520b3c6ee35cf309b417d4a842e7a8cd55a2b2accb23f2f24 0026-ada-musl-support-fixes.patch 3f9a406d7d2ce34951215ffbcadb49a45e55ad5c24ab9097c0e5e92383e43b876872ccd2a7e7def2833ab204975ee5733f8bcf90934db9fa9c4f6f56c62081f6 0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch 720a4001f9a1fa4122e456077ecff8d3eb8af7c83d0a81f9da6a6cca05b23664206a82a349e34482c48bfe40e99aa5f21567613d0913f6a24f282bc84a994496 0028-configure-fix-detection-of-atomic-builtins-in-libato.patch 2044c23b23726965c0a6fd39f616cc464badd650947cb40495eeabd906a3af629878c1d28b403b8eb46b30a1a0ba39083023290d62f0c99ccf070063226e3f8f 0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch @@ -838,5 +861,7 @@ b325035cb7122d79c6b42ca6d3fc9e02319ed2f7cddb0639dff25d2798d2ce63812cd623462cdf95 c474f34e6f9a4239d486a65141a133dbe8ce91427d502a57a9fd6eb403478a2b5715ba74f24c1cc0761e16eec77ba2c1ca921fb7d7bc1e040fc3703fc9559e75 0033-libphobos-do-not-use-LFS64-symbols.patch c4482ffc36e7894b2140800159f4cbc9a3e9011e43a69b69f4fa92d5a11e2ee645c7e21df4423dd1e0636e8890849a5719647bfbdf84f951d638f8f488cb718c 0034-libgo-fix-lfs64-use.patch 65df1d489e8d07a811f39e27fd29e3b2b4164fbc2c5fdc16a5142886d94a96e3fb28ccf4f20dd297ba6540ef8ea1ac3eb65a4279494639bf2f0f8376a3896cc3 0035-loongarch-disable-multilib-support.patch +06f64544fd8bc4b6c8b06410c5198aa8fb4e82c232afc0cad83b2c69ac5d39399968206defa78297222700cd18e7fd7e8244afa76d343406a01f657c86306453 0036-libphobos-add-riscv64-and-loongarch64-support.patch 00319c9770362520e8e93bd03fda1769dfa3622eba77d620e11d8af45a38e6d804a5e924046ae388e1cfaea605696e89c343fca507aaaa5edd58d80744fff14f fix-arm64.patch +815265826742400f86336f0c2d3e4edc37398dbc6505ee81107c0103c13ac0f406cff851438d2323033c6c6d0c0323765ee15b975eab8d1dd465f9e988168fb9 ppc64le-quadmath.patch " diff --git a/cross/gcc-aarch64/ppc64le-quadmath.patch b/cross/gcc-aarch64/ppc64le-quadmath.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf5f726a1a1f18ed8ef42eb39171996a1d800034 --- /dev/null +++ b/cross/gcc-aarch64/ppc64le-quadmath.patch @@ -0,0 +1,56 @@ +Patch-Source: https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=3fe5720430a9ba61ed7562aac4d758cc77d49a28 +-- +From 3fe5720430a9ba61ed7562aac4d758cc77d49a28 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek <jakub@redhat.com> +Date: Sat, 3 Aug 2024 20:37:54 +0200 +Subject: [PATCH] libquadmath: Fix up libquadmath/math/sqrtq.c compilation in + some powerpc* configurations [PR116007] + +My PR114623 change started using soft-fp.h and quad.h for the sqrtq implementation. +Unfortunately, that seems to fail building in some powerpc* configurations, where +TFmode isn't available. +quad.h has: + #ifndef TFtype + typedef float TFtype __attribute__ ((mode (TF))); + #endif +and uses TFtype. quad.h has: + /* Define the complex type corresponding to __float128 + ("_Complex __float128" is not allowed) */ + #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) + typedef _Complex float __attribute__((mode(TC))) __complex128; + #else + typedef _Complex float __attribute__((mode(KC))) __complex128; + #endif +with the conditional and KCmode use added during porting of libquadmath +to powerpc*, so I've just defined TFtype for powerpc when __LONG_DOUBLE_IEEE128__ +isn't defined; I could define it to float __attribute__ ((mode (KF))) but it +seemed easier to just define it to __float128 which should do the same thing. + +2024-08-03 Jakub Jelinek <jakub@redhat.com> + + PR target/116007 + * math/sqrtq.c (TFtype): For PowerPC without __LONG_DOUBLE_IEEE128__ + define to __float128 before including soft-fp.h and quad.h. + +(cherry picked from commit 3ac02e67503ccffa3dfeeffc0a60fce6bdaca43b) +--- + libquadmath/math/sqrtq.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libquadmath/math/sqrtq.c b/libquadmath/math/sqrtq.c +index 8ca2828d42ce..a58998a06670 100644 +--- a/libquadmath/math/sqrtq.c ++++ b/libquadmath/math/sqrtq.c +@@ -9,6 +9,9 @@ + && defined(FE_TOWARDZERO) \ + && defined(FE_INEXACT) + #define USE_SOFT_FP 1 ++#if defined(_ARCH_PPC) && !defined(__LONG_DOUBLE_IEEE128__) ++#define TFtype __float128 ++#endif + #include "../../libgcc/soft-fp/soft-fp.h" + #include "../../libgcc/soft-fp/quad.h" + #endif +-- +2.43.5 + diff --git a/cross/gcc-armhf/0026-ada-musl-support-fixes.patch b/cross/gcc-armhf/0026-ada-musl-support-fixes.patch index 98b7f90eb7e64009ca4b972f7ee258886680cd3c..91a8268ab8b0ea6d0526ea15d017fc3dbc45e141 100644 --- a/cross/gcc-armhf/0026-ada-musl-support-fixes.patch +++ b/cross/gcc-armhf/0026-ada-musl-support-fixes.patch @@ -4,17 +4,17 @@ Date: Fri, 21 Aug 2020 07:07:48 +0000 Subject: [PATCH 26/35] ada: musl support fixes --- - gcc/ada/Makefile.rtl | 10 +++++----- + gcc/ada/Makefile.rtl | 16 ++++++++-------- gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- gcc/ada/adaint.h | 10 ++++------ gcc/ada/terminals.c | 8 ++++---- - 4 files changed, 32 insertions(+), 30 deletions(-) + 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl -index 96306f8cc9a..090b6770ae5 100644 +index 32cbdb692..463028fbe 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl -@@ -1549,7 +1549,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) +@@ -1558,7 +1558,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) s-intman.adb<libgnarl/s-intman__posix.adb \ s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -23,7 +23,16 @@ index 96306f8cc9a..090b6770ae5 100644 a-exetim.adb<libgnarl/a-exetim__posix.adb \ a-exetim.ads<libgnarl/a-exetim__default.ads \ s-linux.ads<libgnarl/s-linux.ads \ -@@ -2174,7 +2174,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) +@@ -2144,7 +2144,7 @@ ifeq ($(strip $(filter-out loongarch% linux%,$(target_cpu) $(target_os))),) + g-sercom.adb<libgnat/g-sercom__linux.adb \ + $(TRASYM_DWARF_UNIX_PAIRS) \ + $(GNATRTL_128BIT_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.ads<libgnat/system-linux-loongarch.ads +@@ -2232,7 +2232,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) s-tasinf.adb<libgnarl/s-tasinf__linux.adb \ s-taspri.ads<libgnarl/s-taspri__posix.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -32,7 +41,7 @@ index 96306f8cc9a..090b6770ae5 100644 $(ATOMICS_TARGET_PAIRS) \ $(ATOMICS_BUILTINS_TARGET_PAIRS) \ system.ads<libgnat/system-linux-ppc.ads -@@ -2205,7 +2205,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) +@@ -2267,7 +2267,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) endif # ARM linux, GNU eabi @@ -50,7 +59,7 @@ index 96306f8cc9a..090b6770ae5 100644 s-mudido.adb<libgnarl/s-mudido__affinity.adb \ s-osinte.ads<libgnarl/s-osinte__linux.ads \ s-osinte.adb<libgnarl/s-osinte__posix.adb \ -@@ -2420,7 +2420,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) +@@ -2488,7 +2488,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -59,7 +68,16 @@ index 96306f8cc9a..090b6770ae5 100644 $(ATOMICS_TARGET_PAIRS) \ $(ATOMICS_BUILTINS_TARGET_PAIRS) \ $(GNATRTL_128BIT_PAIRS) \ -@@ -2524,7 +2524,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) +@@ -2592,7 +2592,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + s-taspri.ads<libgnarl/s-taspri__posix.ads \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(X86_64_TARGET_PAIRS) \ + $(SIMD_PATH_TARGET_PAIRS) \ +@@ -2637,7 +2637,7 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),) s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ s-taspri.ads<libgnarl/s-taspri__posix.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -69,10 +87,10 @@ index 96306f8cc9a..090b6770ae5 100644 $(X86_64_TARGET_PAIRS) \ $(SIMD_PATH_TARGET_PAIRS) \ diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c -index 8522094164e..92b230a462b 100644 +index 74aa3c412..ef6118f37 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c -@@ -91,6 +91,11 @@ +@@ -94,6 +94,11 @@ #include <sys/param.h> #include <sys/pstat.h> #endif @@ -84,7 +102,7 @@ index 8522094164e..92b230a462b 100644 #ifdef __PikeOS__ #define __BSD_VISIBLE 1 -@@ -3438,7 +3443,6 @@ __gnat_lwp_self (void) +@@ -3465,7 +3470,6 @@ __gnat_lwp_self (void) #endif #if defined (__linux__) @@ -92,7 +110,7 @@ index 8522094164e..92b230a462b 100644 /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static -@@ -3448,7 +3452,7 @@ __gnat_lwp_self (void) +@@ -3475,7 +3479,7 @@ __gnat_lwp_self (void) /* Dynamic cpu sets */ @@ -101,7 +119,7 @@ index 8522094164e..92b230a462b 100644 __gnat_cpu_alloc (size_t count) { return CPU_ALLOC (count); -@@ -3461,33 +3465,33 @@ __gnat_cpu_alloc_size (size_t count) +@@ -3488,33 +3492,33 @@ __gnat_cpu_alloc_size (size_t count) } void @@ -143,7 +161,7 @@ index 8522094164e..92b230a462b 100644 } size_t -@@ -3497,23 +3501,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) +@@ -3524,23 +3528,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) } void @@ -173,7 +191,7 @@ index 8522094164e..92b230a462b 100644 #endif /* !CPU_ALLOC */ #endif /* __linux__ */ diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h -index 987432c9307..4d782f07de9 100644 +index 0cbfd0e15..f97ed905b 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -319,13 +319,11 @@ extern void *__gnat_lwp_self (void); @@ -195,10 +213,10 @@ index 987432c9307..4d782f07de9 100644 #if defined (_WIN32) diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c -index c0ee4a16bb1..ed796a48c1b 100644 +index 05af82c27..626ac35bc 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c -@@ -1127,7 +1127,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, +@@ -1134,7 +1134,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, /* POSIX does not specify how to open the master side of a terminal.Several methods are available (system specific): 1- using a cloning device (USE_CLONE_DEVICE) @@ -207,7 +225,7 @@ index c0ee4a16bb1..ed796a48c1b 100644 3- openpty (USE_OPENPTY) When using the cloning device method, the macro USE_CLONE_DEVICE should -@@ -1141,7 +1141,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, +@@ -1148,7 +1148,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, #if defined (__APPLE__) || defined (BSD) #define USE_OPENPTY #elif defined (__linux__) @@ -216,7 +234,7 @@ index c0ee4a16bb1..ed796a48c1b 100644 #elif defined (__sun__) #define USE_CLONE_DEVICE "/dev/ptmx" #elif defined (_AIX) -@@ -1190,8 +1190,8 @@ allocate_pty_desc (pty_desc **desc) { +@@ -1197,8 +1197,8 @@ allocate_pty_desc (pty_desc **desc) { int master_fd = -1; char *slave_name = NULL; @@ -227,6 +245,3 @@ index c0ee4a16bb1..ed796a48c1b 100644 #elif defined (USE_OPENPTY) status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); #elif defined (USE_CLONE_DEVICE) --- -2.41.0 - diff --git a/cross/gcc-armhf/0036-libphobos-add-riscv64-and-loongarch64-support.patch b/cross/gcc-armhf/0036-libphobos-add-riscv64-and-loongarch64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..ba8377b1dda7ba1d5253d194996f4c79d974a3b1 --- /dev/null +++ b/cross/gcc-armhf/0036-libphobos-add-riscv64-and-loongarch64-support.patch @@ -0,0 +1,87 @@ +From: Celeste <cielesti@protonmail.com> +Date: Mon, 2 Sep 2024 02:54:17 +0000 +Subject: [PATCH] libphobos: add riscv64 and loongarch64 support + +Add musl support for these 2 architectures based on fenv.h and signal.h from: + +https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits?h=v1.2.5 + +https://git.musl-libc.org/cgit/musl/tree/arch/loongarch64/bits?h=v1.2.5 +--- + libphobos/libdruntime/core/stdc/fenv.d | 13 +++++++++++++ + libphobos/libdruntime/core/sys/posix/signal.d | 10 ++++++++++ + 2 files changed, 23 insertions(+) + +diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d +index a7364c0a..5b327e4a 100644 +--- a/libphobos/libdruntime/core/stdc/fenv.d ++++ b/libphobos/libdruntime/core/stdc/fenv.d +@@ -436,20 +436,33 @@ else version (CRuntime_Musl) + ushort __cs_selector; + ushort __opcode; + uint __data_offset; + ushort __data_selector; + ushort __unused5; + version (X86_64) + uint __mxcsr; + } + alias ushort fexcept_t; + } ++ else version (RISCV64) ++ { ++ alias uint fenv_t; ++ alias uint fexcept_t; ++ } ++ else version (LoongArch64) ++ { ++ struct fenv_t ++ { ++ uint __cw; ++ } ++ alias uint fexcept_t; ++ } + else + { + static assert(false, "Architecture not supported."); + } + } + else version (CRuntime_Newlib) + { + version (AArch64) + { + alias fenv_t = ulong; +diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d +index a8b7f751..78d8b3cd 100644 +--- a/libphobos/libdruntime/core/sys/posix/signal.d ++++ b/libphobos/libdruntime/core/sys/posix/signal.d +@@ -2751,20 +2751,30 @@ else version (CRuntime_Musl) + else version (PPC_Any) + { + enum MINSIGSTKSZ = 4096; + enum SIGSTKSZ = 10240; + } + else version (X86_Any) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } ++ else version (RISCV64) ++ { ++ enum MINSIGSTKSZ = 2048; ++ enum SIGSTKSZ = 8192; ++ } ++ else version (LoongArch64) ++ { ++ enum MINSIGSTKSZ = 4096; ++ enum SIGSTKSZ = 16384; ++ } + else + static assert(0, "unimplemented"); + + //ucontext_t (defined in core.sys.posix.ucontext) + //mcontext_t (defined in core.sys.posix.ucontext) + + version (MIPS_Any) + { + struct stack_t + { diff --git a/cross/gcc-armhf/APKBUILD b/cross/gcc-armhf/APKBUILD index adca679c9fe6dec0b271fc1d7ab01a5c07ca2d4a..ea7e0af3fb085f14f0e5f0c400e681953b3d90a9 100644 --- a/cross/gcc-armhf/APKBUILD +++ b/cross/gcc-armhf/APKBUILD @@ -34,7 +34,7 @@ _pkgsnap="${pkgver##*_git}" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname=gcc-armhf -pkgrel=2 +pkgrel=3 pkgdesc="Stage2 cross-compiler for armhf" url="https://gcc.gnu.org" arch="x86_64" @@ -64,6 +64,7 @@ _libitm=true if [ "$CHOST" != "$CTARGET" ]; then if [ "$BOOTSTRAP" = nolibc ]; then LANG_CXX=false + LANG_D=false LANG_ADA=false _libgcc=false _builddir="$srcdir/build-cross-pass2" @@ -73,7 +74,6 @@ if [ "$CHOST" != "$CTARGET" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LANG_D=false LANG_JIT=false _libgomp=false _libatomic=false @@ -115,7 +115,6 @@ elif [ "$CBUILD" != "$CHOST" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LANG_D=false LANG_JIT=false STRIP_FOR_TARGET=${CROSS_COMPILE}strip @@ -140,11 +139,11 @@ else export BOOT_LDFLAGS="$LDFLAGS" fi -case "$CARCH" in +case "$CTARGET_ARCH" in # GDC hasn't been ported to PowerPC # See libphobos/configure.tgt in GCC sources for supported targets # riscv fails with: error: static assert "unimplemented" -ppc64le|riscv64|loongarch64) LANG_D=false ;; +ppc64le|riscv64) LANG_D=false ;; # GDC does currently not work on 32-bit musl architectures. # This is a known upstream issue. # See: https://github.com/dlang/druntime/pull/3383 @@ -171,7 +170,7 @@ esac # currently on x86, x86_64 and ia64 _libquadmath=$LANG_FORTRAN case "$CTARGET_ARCH" in -x86 | x86_64) _libquadmath=$LANG_FORTRAN ;; +x86 | x86_64 | ppc64le) _libquadmath=$LANG_FORTRAN ;; *) _libquadmath=false ;; esac @@ -184,13 +183,8 @@ if $_libgomp; then subpackages="$subpackages libgomp::$CTARGET_ARCH" fi -case "$CARCH" in -riscv64) -LANG_ADA=false;; -esac - case "$CTARGET_ARCH" in -loongarch64) +riscv64|loongarch64) LANG_ADA=false;; esac @@ -199,9 +193,17 @@ if $LANG_CXX; then _languages="$_languages,c++" fi if $LANG_D; then - subpackages="$subpackages libgphobos::$CTARGET_ARCH gcc-gdc$_target:gdc" + subpackages="$subpackages gcc-gdc$_target:gdc" _languages="$_languages,d" - makedepends_build="$makedepends_build libucontext-dev gcc-gdc-bootstrap" + makedepends_build="$makedepends_build libucontext-dev" + if [ "$CBUILD" = "$CTARGET" ]; then + makedepends_build="$makedepends_build gcc-gdc-bootstrap" + subpackages="$subpackages libgphobos::$CTARGET_ARCH" + else + # shared libgphobos is for D programs to link against, so + # skip building that while cross-compiling the GDC compiler + makedepends_build="$makedepends_build gcc-gdc gcc-gdc$_cross" + fi fi if $LANG_OBJC; then subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc" @@ -278,7 +280,9 @@ source="https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkg 0033-libphobos-do-not-use-LFS64-symbols.patch 0034-libgo-fix-lfs64-use.patch 0035-loongarch-disable-multilib-support.patch + 0036-libphobos-add-riscv64-and-loongarch64-support.patch fix-arm64.patch + ppc64le-quadmath.patch " # secfixes: @@ -339,7 +343,7 @@ build() { i586-*-*-*) _arch_configure="--with-arch=pentium-m --with-fpmath=sse --with-tune=generic --enable-cld";; s390x-*-*-*) _arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";; riscv64-*-*-*) _arch_configure="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic";; - loongarch64-*-*-*) _arch_configure="--with-arch=loongarch64 --with-abi=lp64d --with-tls=trad";; + loongarch64-*-*-*) _arch_configure="--with-arch=loongarch64 --with-abi=lp64d";; esac case "$CTARGET_ARCH" in @@ -360,20 +364,23 @@ build() { case "$BOOTSTRAP" in nolibc) _bootstrap_configure="--with-newlib --disable-shared --enable-threads=no" ;; - *) _bootstrap_configure="--enable-shared --enable-threads --enable-tls" ;; + *) + # cross-bootstrap GDC with a static libphobos: due to GCC's + # ./configure not having a --disable-shared=libphobos option, + # we have to use --enable-shared with everything else instead. + if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then + _bootstrap_configure="--enable-shared=libgcc,libstdc++,libffi,zlib,boehm-gc,ada,libada,libgo,libobjc,libatomic,libgomp,libitm,libgfortran,libquadmath" + else + _bootstrap_configure="--enable-shared" + fi + _bootstrap_configure="$_bootstrap_configure --enable-threads --enable-tls" + ;; esac $_libgomp || _bootstrap_configure="$_bootstrap_configure --disable-libgomp" $_libatomic || _bootstrap_configure="$_bootstrap_configure --disable-libatomic" $_libitm || _bootstrap_configure="$_bootstrap_configure --disable-libitm" - if ! $_libquadmath; then - _arch_configure="$_arch_configure --disable-libquadmath" - # ppc64le needs both --disable-libquadmath{,-support} - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116007 - [ "$CARCH" = "ppc64le" ] && - _arch_configure="$_arch_configure - --disable-libquadmath-support" - fi + $_libquadmath || _arch_configure="$_arch_configure --disable-libquadmath" msg "Building the following:" echo "" @@ -427,6 +434,10 @@ build() { --with-pkgversion="$version" msg "building gcc" + if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then + # cross-compiling libphobos with parallel make fails + make all-target-libphobos + fi make # we build gccjit separate to not build all of gcc with --enable-host-shared @@ -667,9 +678,9 @@ libgphobos() { gdc() { pkgdesc="GCC-based D language compiler" - depends="gcc=$_gccrel libgphobos=$_gccrel musl-dev" - depends="$depends libucontext-dev" - provides="gcc-gdc-bootstrap=$_gccrel" + depends="gcc$_target=$_gccrel musl-dev libucontext-dev" + [ "$CBUILD" = "$CTARGET" ] && depends="$depends libgphobos=$_gccrel" + [ "$CHOST" = "$CTARGET" ] && provides="gcc-gdc-bootstrap=$_gccrel" mkdir -p "$subpkgdir/$_gcclibexec" \ "$subpkgdir"/$_gcclibdir/include/d/ \ @@ -680,13 +691,25 @@ gdc() { # without installing the compiler mv "$pkgdir/$_gcclibexec/d21" "$subpkgdir/$_gcclibexec/" mv "$pkgdir"/$_gcclibdir/include/d/* "$subpkgdir"/$_gcclibdir/include/d/ - mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + if [ "$CBUILD" = "$CTARGET" ]; then + mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ + fi + if [ "$CHOST" = "$CTARGET" ]; then + mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ + else + mkdir -p "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgdruntime.a \ + "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgphobos.a \ + "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgphobos.spec \ + "$subpkgdir"/usr/$CTARGET/lib/ + fi mv "$pkgdir"/usr/bin/$CTARGET-gdc "$subpkgdir"/usr/bin/ - mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ } libgo() { @@ -828,7 +851,7 @@ f382eb5f7c2c60c5a23fac587c9629a3059d7be0898e97a1feaf9b9cbe1ef4693cc1177eb29333e8 abf845792433a21fed5dd06167b9f6cf5e8f8026a409acce93824e466c5148e192bf5f404a271931fe4b65283499329bf67bb01019f2f3e02501f20619404e6c 0023-riscv-disable-multilib-support.patch ab88a2f63e3545bbc36537aa9a86f2c6c35e41bbf702d6e13743a405cdac4f901eed5737189b780da96647fea9f5d863fdc76373f25a00064106dcb5514d6d87 0024-always-build-libgcc_eh.a.patch 8fdbe0c8bf4ca60f458a33e59027de03d15ac91933fe46d8ca62119346d20b9bc2447c0bf22bceb63d0cf8613ab61512d9197f4e6c2224af473b63ef9f254295 0025-ada-libgnarl-compatibility-for-musl.patch -5fd23a506b55c88d4f000e01c539eb25d6da2516949c9d7a1c9ee20f4c6b627e4788541284d9c14c33bafa7cb43ce2e0469dd91006152f00e30815107150320f 0026-ada-musl-support-fixes.patch +684bf2db12aa45e8db7a895ab0f227b4e4351f611b4fcc6e1745d7ad94d31b3554f39d8cf9e2203520b3c6ee35cf309b417d4a842e7a8cd55a2b2accb23f2f24 0026-ada-musl-support-fixes.patch 3f9a406d7d2ce34951215ffbcadb49a45e55ad5c24ab9097c0e5e92383e43b876872ccd2a7e7def2833ab204975ee5733f8bcf90934db9fa9c4f6f56c62081f6 0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch 720a4001f9a1fa4122e456077ecff8d3eb8af7c83d0a81f9da6a6cca05b23664206a82a349e34482c48bfe40e99aa5f21567613d0913f6a24f282bc84a994496 0028-configure-fix-detection-of-atomic-builtins-in-libato.patch 2044c23b23726965c0a6fd39f616cc464badd650947cb40495eeabd906a3af629878c1d28b403b8eb46b30a1a0ba39083023290d62f0c99ccf070063226e3f8f 0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch @@ -838,5 +861,7 @@ b325035cb7122d79c6b42ca6d3fc9e02319ed2f7cddb0639dff25d2798d2ce63812cd623462cdf95 c474f34e6f9a4239d486a65141a133dbe8ce91427d502a57a9fd6eb403478a2b5715ba74f24c1cc0761e16eec77ba2c1ca921fb7d7bc1e040fc3703fc9559e75 0033-libphobos-do-not-use-LFS64-symbols.patch c4482ffc36e7894b2140800159f4cbc9a3e9011e43a69b69f4fa92d5a11e2ee645c7e21df4423dd1e0636e8890849a5719647bfbdf84f951d638f8f488cb718c 0034-libgo-fix-lfs64-use.patch 65df1d489e8d07a811f39e27fd29e3b2b4164fbc2c5fdc16a5142886d94a96e3fb28ccf4f20dd297ba6540ef8ea1ac3eb65a4279494639bf2f0f8376a3896cc3 0035-loongarch-disable-multilib-support.patch +06f64544fd8bc4b6c8b06410c5198aa8fb4e82c232afc0cad83b2c69ac5d39399968206defa78297222700cd18e7fd7e8244afa76d343406a01f657c86306453 0036-libphobos-add-riscv64-and-loongarch64-support.patch 00319c9770362520e8e93bd03fda1769dfa3622eba77d620e11d8af45a38e6d804a5e924046ae388e1cfaea605696e89c343fca507aaaa5edd58d80744fff14f fix-arm64.patch +815265826742400f86336f0c2d3e4edc37398dbc6505ee81107c0103c13ac0f406cff851438d2323033c6c6d0c0323765ee15b975eab8d1dd465f9e988168fb9 ppc64le-quadmath.patch " diff --git a/cross/gcc-armhf/ppc64le-quadmath.patch b/cross/gcc-armhf/ppc64le-quadmath.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf5f726a1a1f18ed8ef42eb39171996a1d800034 --- /dev/null +++ b/cross/gcc-armhf/ppc64le-quadmath.patch @@ -0,0 +1,56 @@ +Patch-Source: https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=3fe5720430a9ba61ed7562aac4d758cc77d49a28 +-- +From 3fe5720430a9ba61ed7562aac4d758cc77d49a28 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek <jakub@redhat.com> +Date: Sat, 3 Aug 2024 20:37:54 +0200 +Subject: [PATCH] libquadmath: Fix up libquadmath/math/sqrtq.c compilation in + some powerpc* configurations [PR116007] + +My PR114623 change started using soft-fp.h and quad.h for the sqrtq implementation. +Unfortunately, that seems to fail building in some powerpc* configurations, where +TFmode isn't available. +quad.h has: + #ifndef TFtype + typedef float TFtype __attribute__ ((mode (TF))); + #endif +and uses TFtype. quad.h has: + /* Define the complex type corresponding to __float128 + ("_Complex __float128" is not allowed) */ + #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) + typedef _Complex float __attribute__((mode(TC))) __complex128; + #else + typedef _Complex float __attribute__((mode(KC))) __complex128; + #endif +with the conditional and KCmode use added during porting of libquadmath +to powerpc*, so I've just defined TFtype for powerpc when __LONG_DOUBLE_IEEE128__ +isn't defined; I could define it to float __attribute__ ((mode (KF))) but it +seemed easier to just define it to __float128 which should do the same thing. + +2024-08-03 Jakub Jelinek <jakub@redhat.com> + + PR target/116007 + * math/sqrtq.c (TFtype): For PowerPC without __LONG_DOUBLE_IEEE128__ + define to __float128 before including soft-fp.h and quad.h. + +(cherry picked from commit 3ac02e67503ccffa3dfeeffc0a60fce6bdaca43b) +--- + libquadmath/math/sqrtq.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libquadmath/math/sqrtq.c b/libquadmath/math/sqrtq.c +index 8ca2828d42ce..a58998a06670 100644 +--- a/libquadmath/math/sqrtq.c ++++ b/libquadmath/math/sqrtq.c +@@ -9,6 +9,9 @@ + && defined(FE_TOWARDZERO) \ + && defined(FE_INEXACT) + #define USE_SOFT_FP 1 ++#if defined(_ARCH_PPC) && !defined(__LONG_DOUBLE_IEEE128__) ++#define TFtype __float128 ++#endif + #include "../../libgcc/soft-fp/soft-fp.h" + #include "../../libgcc/soft-fp/quad.h" + #endif +-- +2.43.5 + diff --git a/cross/gcc-armv7/0026-ada-musl-support-fixes.patch b/cross/gcc-armv7/0026-ada-musl-support-fixes.patch index 98b7f90eb7e64009ca4b972f7ee258886680cd3c..91a8268ab8b0ea6d0526ea15d017fc3dbc45e141 100644 --- a/cross/gcc-armv7/0026-ada-musl-support-fixes.patch +++ b/cross/gcc-armv7/0026-ada-musl-support-fixes.patch @@ -4,17 +4,17 @@ Date: Fri, 21 Aug 2020 07:07:48 +0000 Subject: [PATCH 26/35] ada: musl support fixes --- - gcc/ada/Makefile.rtl | 10 +++++----- + gcc/ada/Makefile.rtl | 16 ++++++++-------- gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- gcc/ada/adaint.h | 10 ++++------ gcc/ada/terminals.c | 8 ++++---- - 4 files changed, 32 insertions(+), 30 deletions(-) + 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl -index 96306f8cc9a..090b6770ae5 100644 +index 32cbdb692..463028fbe 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl -@@ -1549,7 +1549,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) +@@ -1558,7 +1558,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) s-intman.adb<libgnarl/s-intman__posix.adb \ s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -23,7 +23,16 @@ index 96306f8cc9a..090b6770ae5 100644 a-exetim.adb<libgnarl/a-exetim__posix.adb \ a-exetim.ads<libgnarl/a-exetim__default.ads \ s-linux.ads<libgnarl/s-linux.ads \ -@@ -2174,7 +2174,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) +@@ -2144,7 +2144,7 @@ ifeq ($(strip $(filter-out loongarch% linux%,$(target_cpu) $(target_os))),) + g-sercom.adb<libgnat/g-sercom__linux.adb \ + $(TRASYM_DWARF_UNIX_PAIRS) \ + $(GNATRTL_128BIT_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.ads<libgnat/system-linux-loongarch.ads +@@ -2232,7 +2232,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) s-tasinf.adb<libgnarl/s-tasinf__linux.adb \ s-taspri.ads<libgnarl/s-taspri__posix.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -32,7 +41,7 @@ index 96306f8cc9a..090b6770ae5 100644 $(ATOMICS_TARGET_PAIRS) \ $(ATOMICS_BUILTINS_TARGET_PAIRS) \ system.ads<libgnat/system-linux-ppc.ads -@@ -2205,7 +2205,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) +@@ -2267,7 +2267,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) endif # ARM linux, GNU eabi @@ -50,7 +59,7 @@ index 96306f8cc9a..090b6770ae5 100644 s-mudido.adb<libgnarl/s-mudido__affinity.adb \ s-osinte.ads<libgnarl/s-osinte__linux.ads \ s-osinte.adb<libgnarl/s-osinte__posix.adb \ -@@ -2420,7 +2420,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) +@@ -2488,7 +2488,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -59,7 +68,16 @@ index 96306f8cc9a..090b6770ae5 100644 $(ATOMICS_TARGET_PAIRS) \ $(ATOMICS_BUILTINS_TARGET_PAIRS) \ $(GNATRTL_128BIT_PAIRS) \ -@@ -2524,7 +2524,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) +@@ -2592,7 +2592,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) + s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ + s-taspri.ads<libgnarl/s-taspri__posix.ads \ + $(TRASYM_DWARF_UNIX_PAIRS) \ +- s-tsmona.adb<libgnat/s-tsmona__linux.adb \ ++ s-tsmona.adb<libgnat/s-tsmona.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(X86_64_TARGET_PAIRS) \ + $(SIMD_PATH_TARGET_PAIRS) \ +@@ -2637,7 +2637,7 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),) s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ s-taspri.ads<libgnarl/s-taspri__posix.ads \ $(TRASYM_DWARF_UNIX_PAIRS) \ @@ -69,10 +87,10 @@ index 96306f8cc9a..090b6770ae5 100644 $(X86_64_TARGET_PAIRS) \ $(SIMD_PATH_TARGET_PAIRS) \ diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c -index 8522094164e..92b230a462b 100644 +index 74aa3c412..ef6118f37 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c -@@ -91,6 +91,11 @@ +@@ -94,6 +94,11 @@ #include <sys/param.h> #include <sys/pstat.h> #endif @@ -84,7 +102,7 @@ index 8522094164e..92b230a462b 100644 #ifdef __PikeOS__ #define __BSD_VISIBLE 1 -@@ -3438,7 +3443,6 @@ __gnat_lwp_self (void) +@@ -3465,7 +3470,6 @@ __gnat_lwp_self (void) #endif #if defined (__linux__) @@ -92,7 +110,7 @@ index 8522094164e..92b230a462b 100644 /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static -@@ -3448,7 +3452,7 @@ __gnat_lwp_self (void) +@@ -3475,7 +3479,7 @@ __gnat_lwp_self (void) /* Dynamic cpu sets */ @@ -101,7 +119,7 @@ index 8522094164e..92b230a462b 100644 __gnat_cpu_alloc (size_t count) { return CPU_ALLOC (count); -@@ -3461,33 +3465,33 @@ __gnat_cpu_alloc_size (size_t count) +@@ -3488,33 +3492,33 @@ __gnat_cpu_alloc_size (size_t count) } void @@ -143,7 +161,7 @@ index 8522094164e..92b230a462b 100644 } size_t -@@ -3497,23 +3501,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) +@@ -3524,23 +3528,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) } void @@ -173,7 +191,7 @@ index 8522094164e..92b230a462b 100644 #endif /* !CPU_ALLOC */ #endif /* __linux__ */ diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h -index 987432c9307..4d782f07de9 100644 +index 0cbfd0e15..f97ed905b 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -319,13 +319,11 @@ extern void *__gnat_lwp_self (void); @@ -195,10 +213,10 @@ index 987432c9307..4d782f07de9 100644 #if defined (_WIN32) diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c -index c0ee4a16bb1..ed796a48c1b 100644 +index 05af82c27..626ac35bc 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c -@@ -1127,7 +1127,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, +@@ -1134,7 +1134,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, /* POSIX does not specify how to open the master side of a terminal.Several methods are available (system specific): 1- using a cloning device (USE_CLONE_DEVICE) @@ -207,7 +225,7 @@ index c0ee4a16bb1..ed796a48c1b 100644 3- openpty (USE_OPENPTY) When using the cloning device method, the macro USE_CLONE_DEVICE should -@@ -1141,7 +1141,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, +@@ -1148,7 +1148,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, #if defined (__APPLE__) || defined (BSD) #define USE_OPENPTY #elif defined (__linux__) @@ -216,7 +234,7 @@ index c0ee4a16bb1..ed796a48c1b 100644 #elif defined (__sun__) #define USE_CLONE_DEVICE "/dev/ptmx" #elif defined (_AIX) -@@ -1190,8 +1190,8 @@ allocate_pty_desc (pty_desc **desc) { +@@ -1197,8 +1197,8 @@ allocate_pty_desc (pty_desc **desc) { int master_fd = -1; char *slave_name = NULL; @@ -227,6 +245,3 @@ index c0ee4a16bb1..ed796a48c1b 100644 #elif defined (USE_OPENPTY) status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); #elif defined (USE_CLONE_DEVICE) --- -2.41.0 - diff --git a/cross/gcc-armv7/0036-libphobos-add-riscv64-and-loongarch64-support.patch b/cross/gcc-armv7/0036-libphobos-add-riscv64-and-loongarch64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..ba8377b1dda7ba1d5253d194996f4c79d974a3b1 --- /dev/null +++ b/cross/gcc-armv7/0036-libphobos-add-riscv64-and-loongarch64-support.patch @@ -0,0 +1,87 @@ +From: Celeste <cielesti@protonmail.com> +Date: Mon, 2 Sep 2024 02:54:17 +0000 +Subject: [PATCH] libphobos: add riscv64 and loongarch64 support + +Add musl support for these 2 architectures based on fenv.h and signal.h from: + +https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits?h=v1.2.5 + +https://git.musl-libc.org/cgit/musl/tree/arch/loongarch64/bits?h=v1.2.5 +--- + libphobos/libdruntime/core/stdc/fenv.d | 13 +++++++++++++ + libphobos/libdruntime/core/sys/posix/signal.d | 10 ++++++++++ + 2 files changed, 23 insertions(+) + +diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d +index a7364c0a..5b327e4a 100644 +--- a/libphobos/libdruntime/core/stdc/fenv.d ++++ b/libphobos/libdruntime/core/stdc/fenv.d +@@ -436,20 +436,33 @@ else version (CRuntime_Musl) + ushort __cs_selector; + ushort __opcode; + uint __data_offset; + ushort __data_selector; + ushort __unused5; + version (X86_64) + uint __mxcsr; + } + alias ushort fexcept_t; + } ++ else version (RISCV64) ++ { ++ alias uint fenv_t; ++ alias uint fexcept_t; ++ } ++ else version (LoongArch64) ++ { ++ struct fenv_t ++ { ++ uint __cw; ++ } ++ alias uint fexcept_t; ++ } + else + { + static assert(false, "Architecture not supported."); + } + } + else version (CRuntime_Newlib) + { + version (AArch64) + { + alias fenv_t = ulong; +diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d +index a8b7f751..78d8b3cd 100644 +--- a/libphobos/libdruntime/core/sys/posix/signal.d ++++ b/libphobos/libdruntime/core/sys/posix/signal.d +@@ -2751,20 +2751,30 @@ else version (CRuntime_Musl) + else version (PPC_Any) + { + enum MINSIGSTKSZ = 4096; + enum SIGSTKSZ = 10240; + } + else version (X86_Any) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } ++ else version (RISCV64) ++ { ++ enum MINSIGSTKSZ = 2048; ++ enum SIGSTKSZ = 8192; ++ } ++ else version (LoongArch64) ++ { ++ enum MINSIGSTKSZ = 4096; ++ enum SIGSTKSZ = 16384; ++ } + else + static assert(0, "unimplemented"); + + //ucontext_t (defined in core.sys.posix.ucontext) + //mcontext_t (defined in core.sys.posix.ucontext) + + version (MIPS_Any) + { + struct stack_t + { diff --git a/cross/gcc-armv7/APKBUILD b/cross/gcc-armv7/APKBUILD index 1b7e6def3bb6c861b5a4e51aad5c822c73d64fa0..3ec4c4d1237f70f740f89df71679d44d86901241 100644 --- a/cross/gcc-armv7/APKBUILD +++ b/cross/gcc-armv7/APKBUILD @@ -34,7 +34,7 @@ _pkgsnap="${pkgver##*_git}" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname=gcc-armv7 -pkgrel=2 +pkgrel=3 pkgdesc="Stage2 cross-compiler for armv7" url="https://gcc.gnu.org" arch="x86_64" @@ -64,6 +64,7 @@ _libitm=true if [ "$CHOST" != "$CTARGET" ]; then if [ "$BOOTSTRAP" = nolibc ]; then LANG_CXX=false + LANG_D=false LANG_ADA=false _libgcc=false _builddir="$srcdir/build-cross-pass2" @@ -73,7 +74,6 @@ if [ "$CHOST" != "$CTARGET" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LANG_D=false LANG_JIT=false _libgomp=false _libatomic=false @@ -115,7 +115,6 @@ elif [ "$CBUILD" != "$CHOST" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LANG_D=false LANG_JIT=false STRIP_FOR_TARGET=${CROSS_COMPILE}strip @@ -140,11 +139,11 @@ else export BOOT_LDFLAGS="$LDFLAGS" fi -case "$CARCH" in +case "$CTARGET_ARCH" in # GDC hasn't been ported to PowerPC # See libphobos/configure.tgt in GCC sources for supported targets # riscv fails with: error: static assert "unimplemented" -ppc64le|riscv64|loongarch64) LANG_D=false ;; +ppc64le|riscv64) LANG_D=false ;; # GDC does currently not work on 32-bit musl architectures. # This is a known upstream issue. # See: https://github.com/dlang/druntime/pull/3383 @@ -171,7 +170,7 @@ esac # currently on x86, x86_64 and ia64 _libquadmath=$LANG_FORTRAN case "$CTARGET_ARCH" in -x86 | x86_64) _libquadmath=$LANG_FORTRAN ;; +x86 | x86_64 | ppc64le) _libquadmath=$LANG_FORTRAN ;; *) _libquadmath=false ;; esac @@ -184,13 +183,8 @@ if $_libgomp; then subpackages="$subpackages libgomp::$CTARGET_ARCH" fi -case "$CARCH" in -riscv64) -LANG_ADA=false;; -esac - case "$CTARGET_ARCH" in -loongarch64) +riscv64|loongarch64) LANG_ADA=false;; esac @@ -199,9 +193,17 @@ if $LANG_CXX; then _languages="$_languages,c++" fi if $LANG_D; then - subpackages="$subpackages libgphobos::$CTARGET_ARCH gcc-gdc$_target:gdc" + subpackages="$subpackages gcc-gdc$_target:gdc" _languages="$_languages,d" - makedepends_build="$makedepends_build libucontext-dev gcc-gdc-bootstrap" + makedepends_build="$makedepends_build libucontext-dev" + if [ "$CBUILD" = "$CTARGET" ]; then + makedepends_build="$makedepends_build gcc-gdc-bootstrap" + subpackages="$subpackages libgphobos::$CTARGET_ARCH" + else + # shared libgphobos is for D programs to link against, so + # skip building that while cross-compiling the GDC compiler + makedepends_build="$makedepends_build gcc-gdc gcc-gdc$_cross" + fi fi if $LANG_OBJC; then subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc" @@ -278,7 +280,9 @@ source="https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkg 0033-libphobos-do-not-use-LFS64-symbols.patch 0034-libgo-fix-lfs64-use.patch 0035-loongarch-disable-multilib-support.patch + 0036-libphobos-add-riscv64-and-loongarch64-support.patch fix-arm64.patch + ppc64le-quadmath.patch " # secfixes: @@ -339,7 +343,7 @@ build() { i586-*-*-*) _arch_configure="--with-arch=pentium-m --with-fpmath=sse --with-tune=generic --enable-cld";; s390x-*-*-*) _arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";; riscv64-*-*-*) _arch_configure="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic";; - loongarch64-*-*-*) _arch_configure="--with-arch=loongarch64 --with-abi=lp64d --with-tls=trad";; + loongarch64-*-*-*) _arch_configure="--with-arch=loongarch64 --with-abi=lp64d";; esac case "$CTARGET_ARCH" in @@ -360,20 +364,23 @@ build() { case "$BOOTSTRAP" in nolibc) _bootstrap_configure="--with-newlib --disable-shared --enable-threads=no" ;; - *) _bootstrap_configure="--enable-shared --enable-threads --enable-tls" ;; + *) + # cross-bootstrap GDC with a static libphobos: due to GCC's + # ./configure not having a --disable-shared=libphobos option, + # we have to use --enable-shared with everything else instead. + if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then + _bootstrap_configure="--enable-shared=libgcc,libstdc++,libffi,zlib,boehm-gc,ada,libada,libgo,libobjc,libatomic,libgomp,libitm,libgfortran,libquadmath" + else + _bootstrap_configure="--enable-shared" + fi + _bootstrap_configure="$_bootstrap_configure --enable-threads --enable-tls" + ;; esac $_libgomp || _bootstrap_configure="$_bootstrap_configure --disable-libgomp" $_libatomic || _bootstrap_configure="$_bootstrap_configure --disable-libatomic" $_libitm || _bootstrap_configure="$_bootstrap_configure --disable-libitm" - if ! $_libquadmath; then - _arch_configure="$_arch_configure --disable-libquadmath" - # ppc64le needs both --disable-libquadmath{,-support} - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116007 - [ "$CARCH" = "ppc64le" ] && - _arch_configure="$_arch_configure - --disable-libquadmath-support" - fi + $_libquadmath || _arch_configure="$_arch_configure --disable-libquadmath" msg "Building the following:" echo "" @@ -427,6 +434,10 @@ build() { --with-pkgversion="$version" msg "building gcc" + if $LANG_D && [ "$CBUILD" != "$CTARGET" ]; then + # cross-compiling libphobos with parallel make fails + make all-target-libphobos + fi make # we build gccjit separate to not build all of gcc with --enable-host-shared @@ -667,9 +678,9 @@ libgphobos() { gdc() { pkgdesc="GCC-based D language compiler" - depends="gcc=$_gccrel libgphobos=$_gccrel musl-dev" - depends="$depends libucontext-dev" - provides="gcc-gdc-bootstrap=$_gccrel" + depends="gcc$_target=$_gccrel musl-dev libucontext-dev" + [ "$CBUILD" = "$CTARGET" ] && depends="$depends libgphobos=$_gccrel" + [ "$CHOST" = "$CTARGET" ] && provides="gcc-gdc-bootstrap=$_gccrel" mkdir -p "$subpkgdir/$_gcclibexec" \ "$subpkgdir"/$_gcclibdir/include/d/ \ @@ -680,13 +691,25 @@ gdc() { # without installing the compiler mv "$pkgdir/$_gcclibexec/d21" "$subpkgdir/$_gcclibexec/" mv "$pkgdir"/$_gcclibdir/include/d/* "$subpkgdir"/$_gcclibdir/include/d/ - mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ - mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + if [ "$CBUILD" = "$CTARGET" ]; then + mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ + fi + if [ "$CHOST" = "$CTARGET" ]; then + mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ + else + mkdir -p "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgdruntime.a \ + "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgphobos.a \ + "$subpkgdir"/usr/$CTARGET/lib/ + mv "$pkgdir"/usr/$CTARGET/lib/libgphobos.spec \ + "$subpkgdir"/usr/$CTARGET/lib/ + fi mv "$pkgdir"/usr/bin/$CTARGET-gdc "$subpkgdir"/usr/bin/ - mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ } libgo() { @@ -828,7 +851,7 @@ f382eb5f7c2c60c5a23fac587c9629a3059d7be0898e97a1feaf9b9cbe1ef4693cc1177eb29333e8 abf845792433a21fed5dd06167b9f6cf5e8f8026a409acce93824e466c5148e192bf5f404a271931fe4b65283499329bf67bb01019f2f3e02501f20619404e6c 0023-riscv-disable-multilib-support.patch ab88a2f63e3545bbc36537aa9a86f2c6c35e41bbf702d6e13743a405cdac4f901eed5737189b780da96647fea9f5d863fdc76373f25a00064106dcb5514d6d87 0024-always-build-libgcc_eh.a.patch 8fdbe0c8bf4ca60f458a33e59027de03d15ac91933fe46d8ca62119346d20b9bc2447c0bf22bceb63d0cf8613ab61512d9197f4e6c2224af473b63ef9f254295 0025-ada-libgnarl-compatibility-for-musl.patch -5fd23a506b55c88d4f000e01c539eb25d6da2516949c9d7a1c9ee20f4c6b627e4788541284d9c14c33bafa7cb43ce2e0469dd91006152f00e30815107150320f 0026-ada-musl-support-fixes.patch +684bf2db12aa45e8db7a895ab0f227b4e4351f611b4fcc6e1745d7ad94d31b3554f39d8cf9e2203520b3c6ee35cf309b417d4a842e7a8cd55a2b2accb23f2f24 0026-ada-musl-support-fixes.patch 3f9a406d7d2ce34951215ffbcadb49a45e55ad5c24ab9097c0e5e92383e43b876872ccd2a7e7def2833ab204975ee5733f8bcf90934db9fa9c4f6f56c62081f6 0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch 720a4001f9a1fa4122e456077ecff8d3eb8af7c83d0a81f9da6a6cca05b23664206a82a349e34482c48bfe40e99aa5f21567613d0913f6a24f282bc84a994496 0028-configure-fix-detection-of-atomic-builtins-in-libato.patch 2044c23b23726965c0a6fd39f616cc464badd650947cb40495eeabd906a3af629878c1d28b403b8eb46b30a1a0ba39083023290d62f0c99ccf070063226e3f8f 0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch @@ -838,5 +861,7 @@ b325035cb7122d79c6b42ca6d3fc9e02319ed2f7cddb0639dff25d2798d2ce63812cd623462cdf95 c474f34e6f9a4239d486a65141a133dbe8ce91427d502a57a9fd6eb403478a2b5715ba74f24c1cc0761e16eec77ba2c1ca921fb7d7bc1e040fc3703fc9559e75 0033-libphobos-do-not-use-LFS64-symbols.patch c4482ffc36e7894b2140800159f4cbc9a3e9011e43a69b69f4fa92d5a11e2ee645c7e21df4423dd1e0636e8890849a5719647bfbdf84f951d638f8f488cb718c 0034-libgo-fix-lfs64-use.patch 65df1d489e8d07a811f39e27fd29e3b2b4164fbc2c5fdc16a5142886d94a96e3fb28ccf4f20dd297ba6540ef8ea1ac3eb65a4279494639bf2f0f8376a3896cc3 0035-loongarch-disable-multilib-support.patch +06f64544fd8bc4b6c8b06410c5198aa8fb4e82c232afc0cad83b2c69ac5d39399968206defa78297222700cd18e7fd7e8244afa76d343406a01f657c86306453 0036-libphobos-add-riscv64-and-loongarch64-support.patch 00319c9770362520e8e93bd03fda1769dfa3622eba77d620e11d8af45a38e6d804a5e924046ae388e1cfaea605696e89c343fca507aaaa5edd58d80744fff14f fix-arm64.patch +815265826742400f86336f0c2d3e4edc37398dbc6505ee81107c0103c13ac0f406cff851438d2323033c6c6d0c0323765ee15b975eab8d1dd465f9e988168fb9 ppc64le-quadmath.patch " diff --git a/cross/gcc-armv7/ppc64le-quadmath.patch b/cross/gcc-armv7/ppc64le-quadmath.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf5f726a1a1f18ed8ef42eb39171996a1d800034 --- /dev/null +++ b/cross/gcc-armv7/ppc64le-quadmath.patch @@ -0,0 +1,56 @@ +Patch-Source: https://gcc.gnu.org/git/?p=gcc.git;a=patch;h=3fe5720430a9ba61ed7562aac4d758cc77d49a28 +-- +From 3fe5720430a9ba61ed7562aac4d758cc77d49a28 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek <jakub@redhat.com> +Date: Sat, 3 Aug 2024 20:37:54 +0200 +Subject: [PATCH] libquadmath: Fix up libquadmath/math/sqrtq.c compilation in + some powerpc* configurations [PR116007] + +My PR114623 change started using soft-fp.h and quad.h for the sqrtq implementation. +Unfortunately, that seems to fail building in some powerpc* configurations, where +TFmode isn't available. +quad.h has: + #ifndef TFtype + typedef float TFtype __attribute__ ((mode (TF))); + #endif +and uses TFtype. quad.h has: + /* Define the complex type corresponding to __float128 + ("_Complex __float128" is not allowed) */ + #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) + typedef _Complex float __attribute__((mode(TC))) __complex128; + #else + typedef _Complex float __attribute__((mode(KC))) __complex128; + #endif +with the conditional and KCmode use added during porting of libquadmath +to powerpc*, so I've just defined TFtype for powerpc when __LONG_DOUBLE_IEEE128__ +isn't defined; I could define it to float __attribute__ ((mode (KF))) but it +seemed easier to just define it to __float128 which should do the same thing. + +2024-08-03 Jakub Jelinek <jakub@redhat.com> + + PR target/116007 + * math/sqrtq.c (TFtype): For PowerPC without __LONG_DOUBLE_IEEE128__ + define to __float128 before including soft-fp.h and quad.h. + +(cherry picked from commit 3ac02e67503ccffa3dfeeffc0a60fce6bdaca43b) +--- + libquadmath/math/sqrtq.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libquadmath/math/sqrtq.c b/libquadmath/math/sqrtq.c +index 8ca2828d42ce..a58998a06670 100644 +--- a/libquadmath/math/sqrtq.c ++++ b/libquadmath/math/sqrtq.c +@@ -9,6 +9,9 @@ + && defined(FE_TOWARDZERO) \ + && defined(FE_INEXACT) + #define USE_SOFT_FP 1 ++#if defined(_ARCH_PPC) && !defined(__LONG_DOUBLE_IEEE128__) ++#define TFtype __float128 ++#endif + #include "../../libgcc/soft-fp/soft-fp.h" + #include "../../libgcc/soft-fp/quad.h" + #endif +-- +2.43.5 + diff --git a/cross/musl-aarch64/APKBUILD b/cross/musl-aarch64/APKBUILD index f62332dc40a3ede06af2555b3214dd0096ecded1..e78f37ce162f0d772a5f38ff51c69aab56ff33a0 100644 --- a/cross/musl-aarch64/APKBUILD +++ b/cross/musl-aarch64/APKBUILD @@ -8,7 +8,7 @@ fi pkgname=musl-aarch64 pkgver=1.2.5 -pkgrel=2 +pkgrel=3 arch="x86_64" subpackages="musl-dev-aarch64:package_dev" @@ -57,6 +57,6 @@ package_dev() { } sha512sums=" -a3c660153e2cd1859a83e692c4d1c9f92bb442948ec4ed63412ac1d75502fa40a5a383bb548c8ac98d83fdd27f067304e876be1e15f41eaa09f1414cf5d4e189 musl-1.2.5-r2-aarch64-edge.apk -6e921c1a761125e768e78e072585b226180c1447f04a4d5fc50564787b30f9c1520b3bfe90d835cfba1716fc4672d3df95a0883187adb50627eed9a3c4249a04 musl-dev-1.2.5-r2-aarch64-edge.apk +30c20d050028bbe9a2203a0db0bb1453d921ac381fc3a7dc2c79c535a7ac25ecf65d7ee367b17178a37aa0e26d028a860d03567e9662c6251171c53bf2562893 musl-1.2.5-r3-aarch64-edge.apk +43ef19c8698e98eb473116e7c21dbb9e66d994bd1cd63837d0f0c43ceaf1ce4f1db582e48b22478574ef7fe4bc309aa7bb387af2f99d8d88bcecfaf7763ec82c musl-dev-1.2.5-r3-aarch64-edge.apk " diff --git a/cross/musl-armhf/APKBUILD b/cross/musl-armhf/APKBUILD index 7a7959794eab0de002e5e3a4f80b467ca8c9b66f..96132fea77e223239d8d6b5ef4edc9d288e6497d 100644 --- a/cross/musl-armhf/APKBUILD +++ b/cross/musl-armhf/APKBUILD @@ -8,7 +8,7 @@ fi pkgname=musl-armhf pkgver=1.2.5 -pkgrel=2 +pkgrel=3 arch="x86_64" subpackages="musl-dev-armhf:package_dev" @@ -57,6 +57,6 @@ package_dev() { } sha512sums=" -20f07f25e5267acac97f7f7bf98763869c9a193bf44d1ef2b79f46f2e854aeabe2baa74d0311057541fb99179addbd43c08c56d1361ed349ae22973141f639c5 musl-1.2.5-r2-armhf-edge.apk -4afb4520885704849bec649f5488add0a3a7b25005172d69f03337cf5b0a82d9f564cba11bbfa84a43a9386e027a8516fcc4573210b4e1fe340cc295a7f52499 musl-dev-1.2.5-r2-armhf-edge.apk +b98e17b30e5968ca8f6c963e8752544112337b641186c269dbc4dd4b0a9496de9f4a549deb1bbf03e419b145b86b0c48fd22db1b8dff188bd3b451632b8c2b3f musl-1.2.5-r3-armhf-edge.apk +0e9fa461b75f3a9832e26f8086c9397b9d5dbea9c5821cf7898c0ccf64281f603137265606ee97810cba988fdff967ea7ec240e4e59c1d87da7e001cd4bf719a musl-dev-1.2.5-r3-armhf-edge.apk " diff --git a/cross/musl-armv7/APKBUILD b/cross/musl-armv7/APKBUILD index 19f2892a88aedbff4ff9064a20186bc90c12ff4e..6b9af362077a3c4ff93ec790e32d79148a9db260 100644 --- a/cross/musl-armv7/APKBUILD +++ b/cross/musl-armv7/APKBUILD @@ -8,7 +8,7 @@ fi pkgname=musl-armv7 pkgver=1.2.5 -pkgrel=2 +pkgrel=3 arch="x86_64" subpackages="musl-dev-armv7:package_dev" @@ -57,6 +57,6 @@ package_dev() { } sha512sums=" -0a542c678cfc7ed0cc4246985bd1ecce63247ca4db0ea9fde7c1ee2b30f683b46d7c4011b21931d19fc7c3faeb787413d243580417ec90f745b77534277a6f68 musl-1.2.5-r2-armv7-edge.apk -26516f5ffc1f04223cce8bae2122a2eab17ec59ce1ef0c1d2382394d9dd0e014ac77336639592f24d15f0ec5120ea7b8329febab1bbbaf3dfecb777b944d6337 musl-dev-1.2.5-r2-armv7-edge.apk +05d888f66cb8bb75fcf767327068aff0152c32c97d6de680f7df0b9b11bbf99fefd8f2b7c1b92de8489e0f051d536e0d708faa3c5aaff783565e6c0e05d34c3b musl-1.2.5-r3-armv7-edge.apk +2c8775a37f2f7d5730857dcf7a7f038a1b0838a775a03e05ce299807f3608a112e95c61b776b32152434c27ee23b999915357b4e89e6559eb89e820666e36d97 musl-dev-1.2.5-r3-armv7-edge.apk "