From 47d8b3cc32b42f9b593acee0d56c7d4530aaeca2 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Thu, 17 Oct 2024 16:31:42 -0400 Subject: [PATCH] Add s390x (#102) * attempt s390x * fix matrix * set mcpu * use cross compiler ld * use system cross compilers * fix syntax * add crossbuild-essential-s390x * set openssl flags * set CHOST * remove linker workaround for cross gcc * add qemu shim * make executable * skip zig workaround for system cross compiler * link to cross libc * Revert "link to cross libc" This reverts commit db7e168595c1d90d251b4aeeb8fd6d5e2835baaf. * Revert "skip zig workaround for system cross compiler" This reverts commit 8400985ef82c5e70a36c6bdc1b991198e73402a9. * Revert "remove linker workaround for cross gcc" This reverts commit 27c62676539e6c551b79dd3bbb341d38f2e83995. * Revert "set CHOST" This reverts commit 97325b8cb9e1ccd3b1d9298ec20caef0c478cf65. * Revert "use system cross compilers" This reverts commit 1ca07e00c9124947d22d3a976f84913f4c68ddb4. * try override ld * ld-path flag * try using zld * Revert "try using zld" This reverts commit 17c7ebf7b4bf4dab250c19907ac60e3ea76a934d. * Revert "ld-path flag" This reverts commit b3122cd8848b45ee6adeb07c685d48b08cb2c1fa. * Revert "try override ld" This reverts commit 691fff57fd1b3fca3b024db6c44495c1aa4c7b49. * Revert "Revert "use system cross compilers"" This reverts commit 9e3fe8865ef510ce1a079d9d2c817ae33bbceac2. * Revert "Revert "set CHOST"" This reverts commit 793793dc6414e98460c13a85675457d74dbddbf9. * Revert "Revert "remove linker workaround for cross gcc"" This reverts commit fecbfc492ccd03b4cd13a69c8604d86ec2a42662. * Revert "Revert "skip zig workaround for system cross compiler"" This reverts commit d23fd5bbe97de71a17203cbca8fa61a1a3ea30d7. * Revert "Revert "link to cross libc"" This reverts commit 0ba652d703de07df8bbf2260ed688d9ba7415994. * Revert "link to cross libc" This reverts commit db7e168595c1d90d251b4aeeb8fd6d5e2835baaf. * use CMAKE_LIBRARY_PATH * bump zig to 05.08.2024 snapshot * bump zig to 05.14.2024 snapshot * use zig for s390x * fix missing else clause * compile for z10 * use z196 to match debian * try z13 * try z14 * try z16 * use development build of zig * Use newer zig * fix derp * riscv patches no longer needed * Use newer zig * Delete zigshim/patches/01-arm-xstatver.h.patch * No more patches * s390x openssl * Update zig * update zig * try libffi fork * rename fork branch * Link with xcb * Disable date macro warning * Xau * lib64 openssl * bash appears to already be installed --- .github/workflows/build_python.yml | 11 +- .github/workflows/build_python_on_branch.yml | 2 +- scripts/build_linux_zig.sh | 40 +++++-- scripts/qemu_s390x_interpreter | 4 + zigshim/patches/01-arm-xstatver.h.patch | 19 ---- zigshim/patches/02-riscv64.patch | 108 ------------------- 6 files changed, 40 insertions(+), 144 deletions(-) create mode 100755 scripts/qemu_s390x_interpreter delete mode 100644 zigshim/patches/01-arm-xstatver.h.patch delete mode 100644 zigshim/patches/02-riscv64.patch diff --git a/.github/workflows/build_python.yml b/.github/workflows/build_python.yml index 4d084b4c..58ee475a 100644 --- a/.github/workflows/build_python.yml +++ b/.github/workflows/build_python.yml @@ -9,7 +9,7 @@ on: platforms: required: true type: string - default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64" + default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,linux-s390x,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64" buildsystem_branch: required: false type: string @@ -52,7 +52,7 @@ env: DEBUG_CI: ${{ inputs.debug }} VERBOSE_CI: ${{ inputs.verbose }} PORTABLE_PYTHON_BUILDSYSTEM_BRANCH: ${{ inputs.buildsystem_branch || 'portable-python' }} - image_map: '{"x86_64": "amd64/ubuntu:18.04", "i386": "i386/ubuntu:18.04", "aarch64": "arm64v8/ubuntu:18.04", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid"}' + image_map: '{"x86_64": "amd64/ubuntu:18.04", "i386": "i386/ubuntu:18.04", "aarch64": "arm64v8/ubuntu:18.04", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid", "s390x": "s390x/debian:bullseye"}' freebsd_release_map: '{"14": "14.0", "13": "13.2"}' jobs: @@ -63,7 +63,7 @@ jobs: strategy: fail-fast: false matrix: - arch: [x86_64, i386, aarch64, arm, riscv64] + arch: [x86_64, i386, aarch64, arm, riscv64, s390x] distribution: [full, headless] exclude: - arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }} @@ -71,6 +71,7 @@ jobs: - arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }} - arch: ${{ !contains(inputs.platforms, 'linux-arm') && 'arm' || '' }} - arch: ${{ !contains(inputs.platforms, 'linux-riscv64') && 'riscv64' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-s390x') && 's390x' || '' }} steps: - name: Parse image @@ -82,7 +83,7 @@ jobs: - name: Set up zig uses: goto-bus-stop/setup-zig@v2 with: - version: 0.13.0 + version: 0.14.0-dev.1917+ecd5878b7 - name: Checkout uses: actions/checkout@v4 @@ -542,8 +543,6 @@ jobs: envs: 'RUN_TESTS DEBUG_CI VERBOSE_CI PORTABLE_PYTHON_BUILDSYSTEM_BRANCH' usesh: true copyback: false - prepare: | - /usr/sbin/pkg_add bash run: | cat > /tmp/test.sh < -Date: Sat, 3 Feb 2024 21:07:15 -0800 -Subject: [PATCH] glibc: add changes to make riscv64-linux-gnu works - ---- - lib/libc/glibc/csu/elf-init-2.33.c | 1 + - lib/libc/glibc/sysdeps/generic/elf-initfini.h | 1 + - lib/libc/glibc/sysdeps/generic/sysdep.h | 6 +++++ - lib/libc/glibc/sysdeps/riscv/start-2.33.S | 2 +- - lib/libc/glibc/sysdeps/riscv/start.S | 2 +- - .../riscv64-linux-gnu/gnu/stubs-lp64d.h | 24 +++++++++++++++++++ - 6 files changed, 34 insertions(+), 2 deletions(-) - create mode 100644 lib/libc/glibc/sysdeps/generic/elf-initfini.h - create mode 100644 lib/libc/include/riscv64-linux-gnu/gnu/stubs-lp64d.h - -diff --git a/lib/libc/glibc/csu/elf-init-2.33.c b/lib/libc/glibc/csu/elf-init-2.33.c -index b713c8b0fb50..42ce6583fece 100644 ---- a/lib/libc/glibc/csu/elf-init-2.33.c -+++ b/lib/libc/glibc/csu/elf-init-2.33.c -@@ -34,6 +34,7 @@ - . */ - - #include -+#include - - - /* These magic symbols are provided by the linker. */ -diff --git a/lib/libc/glibc/sysdeps/generic/elf-initfini.h b/lib/libc/glibc/sysdeps/generic/elf-initfini.h -new file mode 100644 -index 000000000000..6630cc8de92e ---- /dev/null -+++ b/lib/libc/glibc/sysdeps/generic/elf-initfini.h -@@ -0,0 +1 @@ -+#define NO_INITFINI 1 -diff --git a/lib/libc/glibc/sysdeps/generic/sysdep.h b/lib/libc/glibc/sysdeps/generic/sysdep.h -index e77be376f7a8..7caa7d76a95c 100644 ---- a/lib/libc/glibc/sysdeps/generic/sysdep.h -+++ b/lib/libc/glibc/sysdeps/generic/sysdep.h -@@ -56,6 +56,12 @@ - # define cfi_personality(enc, exp) .cfi_personality enc, exp - # define cfi_lsda(enc, exp) .cfi_lsda enc, exp - -+# ifndef __clang__ -+# define cfi_label(label) .cfi_label label -+# else -+# define cfi_label(label) -+# endif -+ - #else /* ! ASSEMBLER */ - - # define CFI_STRINGIFY(Name) CFI_STRINGIFY2 (Name) -diff --git a/lib/libc/glibc/sysdeps/riscv/start-2.33.S b/lib/libc/glibc/sysdeps/riscv/start-2.33.S -index 09511b1ef823..8057b4d464ae 100644 ---- a/lib/libc/glibc/sysdeps/riscv/start-2.33.S -+++ b/lib/libc/glibc/sysdeps/riscv/start-2.33.S -@@ -45,7 +45,7 @@ - ENTRY (ENTRY_POINT) - /* Terminate call stack by noting ra is undefined. Use a dummy - .cfi_label to force starting the FDE. */ -- .cfi_label .Ldummy -+ cfi_label (.Ldummy) - cfi_undefined (ra) - call load_gp - mv a5, a0 /* rtld_fini. */ -diff --git a/lib/libc/glibc/sysdeps/riscv/start.S b/lib/libc/glibc/sysdeps/riscv/start.S -index 6dfe65273f2e..837031148630 100644 ---- a/lib/libc/glibc/sysdeps/riscv/start.S -+++ b/lib/libc/glibc/sysdeps/riscv/start.S -@@ -45,7 +45,7 @@ - ENTRY (ENTRY_POINT) - /* Terminate call stack by noting ra is undefined. Use a dummy - .cfi_label to force starting the FDE. */ -- .cfi_label .Ldummy -+ cfi_label (.Ldummy) - cfi_undefined (ra) - call load_gp - mv a5, a0 /* rtld_fini. */ -diff --git a/lib/libc/include/riscv64-linux-gnu/gnu/stubs-lp64d.h b/lib/libc/include/riscv64-linux-gnu/gnu/stubs-lp64d.h -new file mode 100644 -index 000000000000..0ba0dd8b5434 ---- /dev/null -+++ b/lib/libc/include/riscv64-linux-gnu/gnu/stubs-lp64d.h -@@ -0,0 +1,24 @@ -+/* This file is automatically generated. -+ It defines a symbol `__stub_FUNCTION' for each function -+ in the C library which is a stub, meaning it will fail -+ every time called, usually setting errno to ENOSYS. */ -+ -+#ifdef _LIBC -+# error Applications may not define the macro _LIBC -+#endif -+ -+#define __stub___compat_bdflush -+#define __stub___compat_create_module -+#define __stub___compat_get_kernel_syms -+#define __stub___compat_query_module -+#define __stub___compat_uselib -+#define __stub_chflags -+#define __stub_fchflags -+#define __stub_fedisableexcept -+#define __stub_feenableexcept -+#define __stub_fegetexcept -+#define __stub_gtty -+#define __stub_revoke -+#define __stub_setlogin -+#define __stub_sigreturn -+#define __stub_stty