diff --git a/cpython-unix/build.cross-loongarch64.Dockerfile b/cpython-unix/build.cross-loongarch64.Dockerfile index 2e78250ef..d2c0cf359 100644 --- a/cpython-unix/build.cross-loongarch64.Dockerfile +++ b/cpython-unix/build.cross-loongarch64.Dockerfile @@ -33,13 +33,12 @@ RUN for s in debian_trixie debian_trixie-updates; do \ RUN apt-get update -# Host building. +# Build tools, same as in build.Dockerfile RUN apt-get install \ bzip2 \ ca-certificates \ curl \ - gcc \ - g++ \ + file \ libc6-dev \ libffi-dev \ make \ @@ -53,9 +52,16 @@ RUN apt-get install \ zlib1g-dev RUN apt-get install \ - g++-loongarch64-linux-gnu \ - gcc-loongarch64-linux-gnu \ - libc6-dev-loong64-cross + binutils-loongarch64-linux-gnu \ + libc6-loong64-cross \ + libc6-dev-loong64-cross \ + linux-libc-dev-loong64-cross \ + libgcc-s1-loong64-cross \ + libgcc-14-dev-loong64-cross + +# Target-specific symlinks to cross-compile using the external LLVM toolchain. +RUN ln -s /tools/llvm/bin/clang /usr/bin/loongarch64-linux-gnu-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/loongarch64-linux-gnu-clang++ RUN cd /tmp && \ curl -LO https://snapshot.debian.org/archive/debian-ports/20240812T192057Z/pool-loong64/main/libx/libxcrypt/libcrypt-dev_4.4.36-4_loong64.deb && \ diff --git a/cpython-unix/build.cross.Dockerfile b/cpython-unix/build.cross.Dockerfile index 3665f9ac2..50b70bfda 100644 --- a/cpython-unix/build.cross.Dockerfile +++ b/cpython-unix/build.cross.Dockerfile @@ -32,11 +32,12 @@ RUN for s in debian_stretch debian_stretch-updates debian-security_stretch/updat RUN apt-get update -# Host building. +# Build tools, same as in build.Dockerfile RUN apt-get install \ bzip2 \ - gcc \ - g++ \ + ca-certificates \ + curl \ + file \ libc6-dev \ libffi-dev \ make \ @@ -49,29 +50,56 @@ RUN apt-get install \ zip \ zlib1g-dev -# Cross-building. +# Target sysroots and host binutils for cross-compiling with the external LLVM +# toolchain. RUN apt-get install \ - g++-aarch64-linux-gnu \ - g++-arm-linux-gnueabi \ - g++-arm-linux-gnueabihf \ - g++-mips-linux-gnu \ - g++-mips64el-linux-gnuabi64 \ - g++-mipsel-linux-gnu \ - g++-powerpc64le-linux-gnu \ - g++-s390x-linux-gnu \ - gcc-aarch64-linux-gnu \ - gcc-arm-linux-gnueabi \ - gcc-arm-linux-gnueabihf \ - gcc-mips-linux-gnu \ - gcc-mips64el-linux-gnuabi64 \ - gcc-mipsel-linux-gnu \ - gcc-powerpc64le-linux-gnu \ - gcc-s390x-linux-gnu \ - libc6-dev-arm64-cross \ + binutils-arm-linux-gnueabi \ + binutils-arm-linux-gnueabihf \ + binutils-mips-linux-gnu \ + binutils-mipsel-linux-gnu \ + binutils-powerpc64le-linux-gnu \ + binutils-s390x-linux-gnu \ + libc6-armel-cross \ + libc6-armhf-cross \ + libc6-mips-cross \ + libc6-mipsel-cross \ + libc6-ppc64el-cross \ + libc6-s390x-cross \ libc6-dev-armel-cross \ libc6-dev-armhf-cross \ libc6-dev-mips-cross \ - libc6-dev-mips64el-cross \ libc6-dev-mipsel-cross \ libc6-dev-ppc64el-cross \ - libc6-dev-s390x-cross + libc6-dev-s390x-cross \ + linux-libc-dev-armel-cross \ + linux-libc-dev-armhf-cross \ + linux-libc-dev-mips-cross \ + linux-libc-dev-mipsel-cross \ + linux-libc-dev-ppc64el-cross \ + linux-libc-dev-s390x-cross \ + libgcc1-armel-cross \ + libgcc1-armhf-cross \ + libgcc1-mips-cross \ + libgcc1-mipsel-cross \ + libgcc1-ppc64el-cross \ + libgcc1-s390x-cross \ + libgcc-6-dev-armel-cross \ + libgcc-6-dev-armhf-cross \ + libgcc-6-dev-mips-cross \ + libgcc-6-dev-mipsel-cross \ + libgcc-6-dev-ppc64el-cross \ + libgcc-6-dev-s390x-cross + +# Target-specific symlinks to cross-compile using the external LLVM toolchain. +RUN ln -s /tools/llvm/bin/clang /usr/bin/arm-linux-gnueabi-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/arm-linux-gnueabi-clang++ && \ + ln -s /tools/llvm/bin/clang /usr/bin/arm-linux-gnueabihf-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/arm-linux-gnueabihf-clang++ && \ + ln -s /tools/llvm/bin/clang /usr/bin/mips-linux-gnu-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/mips-linux-gnu-clang++ && \ + ln -s /tools/llvm/bin/clang /usr/bin/mipsel-linux-gnu-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/mipsel-linux-gnu-clang++ && \ + ln -s /tools/llvm/bin/clang /usr/bin/powerpc64le-linux-gnu-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/powerpc64le-linux-gnu-clang++ && \ + ln -s /tools/llvm/bin/clang /usr/bin/s390x-linux-gnu-clang && \ + ln -s /tools/llvm/bin/clang++ /usr/bin/s390x-linux-gnu-clang++ diff --git a/cpython-unix/targets.yml b/cpython-unix/targets.yml index 16a65bc82..83f427e94 100644 --- a/cpython-unix/targets.yml +++ b/cpython-unix/targets.yml @@ -180,11 +180,12 @@ armv7-unknown-linux-gnueabi: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/arm-linux-gnueabi-gcc - target_cxx: /usr/bin/arm-linux-gnueabi-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/arm-linux-gnueabi-clang + target_cxx: /usr/bin/arm-linux-gnueabi-clang++ target_ldflags: # Hardening - '-Wl,-z,noexecstack' @@ -224,11 +225,12 @@ armv7-unknown-linux-gnueabihf: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/arm-linux-gnueabihf-gcc - target_cxx: /usr/bin/arm-linux-gnueabihf-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/arm-linux-gnueabihf-clang + target_cxx: /usr/bin/arm-linux-gnueabihf-clang++ target_ldflags: # Hardening - '-Wl,-z,noexecstack' @@ -268,11 +270,12 @@ loongarch64-unknown-linux-gnu: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross-loongarch64 - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/loongarch64-linux-gnu-gcc - target_cxx: /usr/bin/loongarch64-linux-gnu-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/loongarch64-linux-gnu-clang + target_cxx: /usr/bin/loongarch64-linux-gnu-clang++ target_ldflags: # Hardening - '-Wl,-z,noexecstack' @@ -313,11 +316,12 @@ mips-unknown-linux-gnu: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/mips-linux-gnu-gcc - target_cxx: /usr/bin/mips-linux-gnu-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/mips-linux-gnu-clang + target_cxx: /usr/bin/mips-linux-gnu-clang++ target_ldflags: # Hardening - '-Wl,-z,noexecstack' @@ -357,11 +361,12 @@ mipsel-unknown-linux-gnu: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/mipsel-linux-gnu-gcc - target_cxx: /usr/bin/mipsel-linux-gnu-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/mipsel-linux-gnu-clang + target_cxx: /usr/bin/mipsel-linux-gnu-clang++ target_ldflags: # Hardening - '-Wl,-z,noexecstack' @@ -401,11 +406,12 @@ ppc64le-unknown-linux-gnu: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/powerpc64le-linux-gnu-gcc - target_cxx: /usr/bin/powerpc64le-linux-gnu-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/powerpc64le-linux-gnu-clang + target_cxx: /usr/bin/powerpc64le-linux-gnu-clang++ target_ldflags: # Hardening - '-Wl,-z,noexecstack' @@ -490,11 +496,12 @@ s390x-unknown-linux-gnu: - '3.13' - '3.14' - '3.15' + needs_toolchain: true docker_image_suffix: .cross - host_cc: /usr/bin/x86_64-linux-gnu-gcc - host_cxx: /usr/bin/x86_64-linux-gnu-g++ - target_cc: /usr/bin/s390x-linux-gnu-gcc - target_cxx: /usr/bin/s390x-linux-gnu-g++ + host_cc: clang + host_cxx: clang++ + target_cc: /usr/bin/s390x-linux-gnu-clang + target_cxx: /usr/bin/s390x-linux-gnu-clang++ target_cflags: # set the minimum compatibility level to z10 (released 2008) - '-march=z10'