diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c777bbc8df..d7e99a859e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,7 +97,7 @@ jobs: strategy: fail-fast: false matrix: - arch: [x64, x86, arm64, arm, mipsel, mips64el, riscv64] + arch: [x64, x86, arm64, arm, mipsel, mips64el, riscv64, ppc64] env: EXTRA_FLAGS: 'target_cpu="${{ matrix.arch }}"' BUNDLE: naiveproxy-${{ github.event.release.tag_name }}-${{ github.job }}-${{ matrix.arch }} @@ -141,6 +141,9 @@ jobs: sudo dpkg -i qemu-user-static*.deb # libc6-i386 interferes with x86 build sudo apt remove libc6-i386 + - name: Import Debian patches (ppc64el) + run: ./get-ppc64le-patches.sh + if: ${{ matrix.arch == 'ppc64' }} - run: ./get-clang.sh - run: ccache -z - run: ./build.sh diff --git a/src/base/allocator/partition_allocator/partition_alloc.gni b/src/base/allocator/partition_allocator/partition_alloc.gni index b97bba61d8..16ed68b950 100644 --- a/src/base/allocator/partition_allocator/partition_alloc.gni +++ b/src/base/allocator/partition_allocator/partition_alloc.gni @@ -17,7 +17,7 @@ if (is_nacl) { has_64_bit_pointers = false } else if (current_cpu == "x64" || current_cpu == "arm64" || current_cpu == "loong64" || current_cpu == "riscv64" || - current_cpu == "mips64el") { + current_cpu == "mips64el" || current_cpu == "ppc64") { has_64_bit_pointers = true } else if (current_cpu == "x86" || current_cpu == "arm" || current_cpu == "mipsel") { has_64_bit_pointers = false diff --git a/src/build/config/compiler/BUILD.gn b/src/build/config/compiler/BUILD.gn index a8119d15dd..3a98aa4eea 100644 --- a/src/build/config/compiler/BUILD.gn +++ b/src/build/config/compiler/BUILD.gn @@ -1365,6 +1365,10 @@ config("compiler_cpu_abi") { ldflags += [ "-mips64r2" ] } } else if (current_cpu == "ppc64") { + if (is_clang && custom_toolchain == "" && current_os != "openwrt") { + cflags += [ "--target=powerpc64le-linux-gnu" ] + ldflags += [ "--target=powerpc64le-linux-gnu" ] + } if (current_os == "aix") { cflags += [ "-maix64" ] ldflags += [ "-maix64" ] diff --git a/src/build/linux/sysroot_scripts/install-sysroot.py b/src/build/linux/sysroot_scripts/install-sysroot.py index 1195f64e73..bb3f3246bb 100755 --- a/src/build/linux/sysroot_scripts/install-sysroot.py +++ b/src/build/linux/sysroot_scripts/install-sysroot.py @@ -37,7 +37,7 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) URL_PREFIX = 'https://commondatastorage.googleapis.com' URL_PATH = 'chrome-linux-sysroot/toolchain' -VALID_ARCHS = ('amd64', 'i386', 'armhf', 'arm64', 'armel', 'mipsel', 'mips64el', 'riscv64') +VALID_ARCHS = ('amd64', 'i386', 'armhf', 'arm64', 'armel', 'mipsel', 'mips64el', 'riscv64', 'ppc64el') ARCH_TRANSLATIONS = { 'x64': 'amd64', @@ -45,6 +45,7 @@ ARCH_TRANSLATIONS = { 'arm': 'armhf', 'mips': 'mipsel', 'mips64': 'mips64el', + 'ppc64': 'ppc64el', } DEFAULT_TARGET_PLATFORM = 'bullseye' diff --git a/src/build/linux/sysroot_scripts/sysroot-creator.sh b/src/build/linux/sysroot_scripts/sysroot-creator.sh index de4bd63bec..b91ccbc6cd 100755 --- a/src/build/linux/sysroot_scripts/sysroot-creator.sh +++ b/src/build/linux/sysroot_scripts/sysroot-creator.sh @@ -99,6 +99,15 @@ DEBIAN_PACKAGES_MIPS64EL=" DEBIAN_PACKAGES_RISCV64=" " +DEBIAN_PACKAGES_PPC64EL=" + libasan6 + libitm1 + liblsan0 + libquadmath0 + libtsan0 + libubsan1 +" + readonly REQUIRED_TOOLS="curl xzcat" ###################################################################### @@ -221,6 +230,10 @@ SetEnvironmentVariables() { # RISCV64 has no support in bookworm APT_SOURCES_LIST=("https://snapshot.debian.org/archive/debian-ports/20230724T141507Z/ sid main") ;; + ppc64el) + TRIPLE=powerpc64le-linux-gnu + DEBIAN_PACKAGES_ARCH="${DEBIAN_PACKAGES_PPC64EL}" + ;; *) echo "ERROR: Unsupported architecture: $ARCH" Usage diff --git a/src/build/linux/sysroot_scripts/sysroots.json b/src/build/linux/sysroot_scripts/sysroots.json index e256d2c7c5..d8da7fe9fc 100644 --- a/src/build/linux/sysroot_scripts/sysroots.json +++ b/src/build/linux/sysroot_scripts/sysroots.json @@ -46,5 +46,11 @@ "Sha1Sum": "", "SysrootDir": "debian_bullseye_riscv64-sysroot", "Tarball": "debian_bullseye_riscv64_sysroot.tar.xz" + }, + "bullseye_ppc64el": { + "Key": "", + "Sha1Sum": "", + "SysrootDir": "debian_bullseye_ppc64el-sysroot", + "Tarball": "debian_bullseye_ppc64el_sysroot.tar.xz" } } diff --git a/src/get-ppc64le-patches.sh b/src/get-ppc64le-patches.sh new file mode 100755 index 0000000000..db4ac99101 --- /dev/null +++ b/src/get-ppc64le-patches.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +set -ex + +DEBIAN_TAG_VERSION=115.0.5790.170-1 +url=https://salsa.debian.org/chromium-team/chromium/-/archive/debian/$DEBIAN_TAG_VERSION/chromium-debian-$DEBIAN_TAG_VERSION.tar.gz + +rm -rf chromium-debian-$DEBIAN_TAG_VERSION +trap "rm -rf chromium-debian-$DEBIAN_TAG_VERSION" EXIT +curl -L $url -o- | tar xzf - + +series=" +third_party/0001-Add-PPC64-support-for-boringssl.patch +third_party/0001-third_party-boringssl-Properly-detect-ppc64le-in-BUI.patch +third_party/0001-third_party-lss-Don-t-look-for-mmap2-on-ppc64.patch +third_party/0002-third_party-lss-kernel-structs.patch +third_party/0002-third-party-boringssl-add-generated-files.patch +third_party/use-sysconf-page-size-on-ppc64.patch +" +for i in $series; do + patch --batch -p1 <chromium-debian-$DEBIAN_TAG_VERSION/debian/patches/ppc64le/$i || true +done + +patch -p2 <<EOF +diff --git a/src/third_party/boringssl/src/crypto/fipsmodule/modes/internal.h b/src/third_party/boringssl/src/crypto/fipsmodule/modes/internal.h +index ecda045c59..8780f7e3d6 100644 +--- a/src/third_party/boringssl/src/crypto/fipsmodule/modes/internal.h ++++ b/src/third_party/boringssl/src/crypto/fipsmodule/modes/internal.h +@@ -329,8 +329,8 @@ void aes_gcm_dec_kernel(const uint8_t *in, uint64_t in_bits, void *out, + #define GHASH_ASM_PPC64LE + #define GCM_FUNCREF + void gcm_init_p8(u128 Htable[16], const uint64_t Xi[2]); +-void gcm_gmult_p8(uint64_t Xi[2], const u128 Htable[16]); +-void gcm_ghash_p8(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, ++void gcm_gmult_p8(uint8_t Xi[16], const u128 Htable[16]); ++void gcm_ghash_p8(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, + size_t len); + #endif + #endif // OPENSSL_NO_ASM +EOF diff --git a/src/get-sysroot.sh b/src/get-sysroot.sh index 81a1e53d8d..0db1d7aa1a 100644 --- a/src/get-sysroot.sh +++ b/src/get-sysroot.sh @@ -42,6 +42,7 @@ case "$ARCH" in mipsel) SYSROOT_ARCH=mipsel;; mips64el) SYSROOT_ARCH=mips64el;; riscv64) SYSROOT_ARCH=riscv64;; + ppc64) SYSROOT_ARCH=ppc64el;; esac if [ "$SYSROOT_ARCH" ]; then WITH_SYSROOT="out/sysroot-build/bullseye/bullseye_${SYSROOT_ARCH}_staging" diff --git a/tests/basic.py b/tests/basic.py index 9ef8621a4c..d4f5cbc62a 100644 --- a/tests/basic.py +++ b/tests/basic.py @@ -78,6 +78,8 @@ def start_naive(naive_args): with_qemu = 'mips64el' elif argv.target_cpu == 'riscv64': with_qemu = 'riscv64' + elif argv.target_cpu == 'ppc64': + with_qemu = 'ppc64el' if argv.rootfs: if not with_qemu: @@ -148,15 +150,14 @@ def test_naive_once(proxy, *args, **kwargs): proxy = proxy.format_map(port_dict) config_file = kwargs.get('config_file', 'config.json') - if argv.rootfs: - config_file = os.path.join(argv.rootfs, config_file) config_content = kwargs.get('config_content') if config_content is not None: config_content = config_content.format_map(port_dict) with open(config_file, 'w') as f: - f.write('{') - f.write(config_content) - f.write('}') + f.write('{' + config_content + '}') + if argv.rootfs: + with open(os.path.join(argv.rootfs, config_file), 'w') as f: + f.write('{' + config_content + '}') naive_procs = []