Add ppc64le build

This commit is contained in:
klzgrad 2023-08-07 22:58:14 +08:00
parent 958d8b012a
commit e68642f198
9 changed files with 77 additions and 8 deletions

View File

@ -97,7 +97,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
arch: [x64, x86, arm64, arm, mipsel, mips64el, riscv64] arch: [x64, x86, arm64, arm, mipsel, mips64el, riscv64, ppc64]
env: env:
EXTRA_FLAGS: 'target_cpu="${{ matrix.arch }}"' EXTRA_FLAGS: 'target_cpu="${{ matrix.arch }}"'
BUNDLE: naiveproxy-${{ github.event.release.tag_name }}-${{ github.job }}-${{ 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 sudo dpkg -i qemu-user-static*.deb
# libc6-i386 interferes with x86 build # libc6-i386 interferes with x86 build
sudo apt remove libc6-i386 sudo apt remove libc6-i386
- name: Import Debian patches (ppc64el)
run: ./get-ppc64le-patches.sh
if: ${{ matrix.arch == 'ppc64' }}
- run: ./get-clang.sh - run: ./get-clang.sh
- run: ccache -z - run: ccache -z
- run: ./build.sh - run: ./build.sh

View File

@ -17,7 +17,7 @@ if (is_nacl) {
has_64_bit_pointers = false has_64_bit_pointers = false
} else if (current_cpu == "x64" || current_cpu == "arm64" || } else if (current_cpu == "x64" || current_cpu == "arm64" ||
current_cpu == "loong64" || current_cpu == "riscv64" || current_cpu == "loong64" || current_cpu == "riscv64" ||
current_cpu == "mips64el") { current_cpu == "mips64el" || current_cpu == "ppc64") {
has_64_bit_pointers = true has_64_bit_pointers = true
} else if (current_cpu == "x86" || current_cpu == "arm" || current_cpu == "mipsel") { } else if (current_cpu == "x86" || current_cpu == "arm" || current_cpu == "mipsel") {
has_64_bit_pointers = false has_64_bit_pointers = false

View File

@ -1365,6 +1365,10 @@ config("compiler_cpu_abi") {
ldflags += [ "-mips64r2" ] ldflags += [ "-mips64r2" ]
} }
} else if (current_cpu == "ppc64") { } 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") { if (current_os == "aix") {
cflags += [ "-maix64" ] cflags += [ "-maix64" ]
ldflags += [ "-maix64" ] ldflags += [ "-maix64" ]

View File

@ -37,7 +37,7 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
URL_PREFIX = 'https://commondatastorage.googleapis.com' URL_PREFIX = 'https://commondatastorage.googleapis.com'
URL_PATH = 'chrome-linux-sysroot/toolchain' 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 = { ARCH_TRANSLATIONS = {
'x64': 'amd64', 'x64': 'amd64',
@ -45,6 +45,7 @@ ARCH_TRANSLATIONS = {
'arm': 'armhf', 'arm': 'armhf',
'mips': 'mipsel', 'mips': 'mipsel',
'mips64': 'mips64el', 'mips64': 'mips64el',
'ppc64': 'ppc64el',
} }
DEFAULT_TARGET_PLATFORM = 'bullseye' DEFAULT_TARGET_PLATFORM = 'bullseye'

View File

@ -99,6 +99,15 @@ DEBIAN_PACKAGES_MIPS64EL="
DEBIAN_PACKAGES_RISCV64=" DEBIAN_PACKAGES_RISCV64="
" "
DEBIAN_PACKAGES_PPC64EL="
libasan6
libitm1
liblsan0
libquadmath0
libtsan0
libubsan1
"
readonly REQUIRED_TOOLS="curl xzcat" readonly REQUIRED_TOOLS="curl xzcat"
###################################################################### ######################################################################
@ -221,6 +230,10 @@ SetEnvironmentVariables() {
# RISCV64 has no support in bookworm # RISCV64 has no support in bookworm
APT_SOURCES_LIST=("https://snapshot.debian.org/archive/debian-ports/20230724T141507Z/ sid main") 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" echo "ERROR: Unsupported architecture: $ARCH"
Usage Usage

View File

@ -46,5 +46,11 @@
"Sha1Sum": "", "Sha1Sum": "",
"SysrootDir": "debian_bullseye_riscv64-sysroot", "SysrootDir": "debian_bullseye_riscv64-sysroot",
"Tarball": "debian_bullseye_riscv64_sysroot.tar.xz" "Tarball": "debian_bullseye_riscv64_sysroot.tar.xz"
},
"bullseye_ppc64el": {
"Key": "",
"Sha1Sum": "",
"SysrootDir": "debian_bullseye_ppc64el-sysroot",
"Tarball": "debian_bullseye_ppc64el_sysroot.tar.xz"
} }
} }

40
src/get-ppc64le-patches.sh Executable file
View File

@ -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

View File

@ -42,6 +42,7 @@ case "$ARCH" in
mipsel) SYSROOT_ARCH=mipsel;; mipsel) SYSROOT_ARCH=mipsel;;
mips64el) SYSROOT_ARCH=mips64el;; mips64el) SYSROOT_ARCH=mips64el;;
riscv64) SYSROOT_ARCH=riscv64;; riscv64) SYSROOT_ARCH=riscv64;;
ppc64) SYSROOT_ARCH=ppc64el;;
esac esac
if [ "$SYSROOT_ARCH" ]; then if [ "$SYSROOT_ARCH" ]; then
WITH_SYSROOT="out/sysroot-build/bullseye/bullseye_${SYSROOT_ARCH}_staging" WITH_SYSROOT="out/sysroot-build/bullseye/bullseye_${SYSROOT_ARCH}_staging"

View File

@ -78,6 +78,8 @@ def start_naive(naive_args):
with_qemu = 'mips64el' with_qemu = 'mips64el'
elif argv.target_cpu == 'riscv64': elif argv.target_cpu == 'riscv64':
with_qemu = 'riscv64' with_qemu = 'riscv64'
elif argv.target_cpu == 'ppc64':
with_qemu = 'ppc64el'
if argv.rootfs: if argv.rootfs:
if not with_qemu: if not with_qemu:
@ -148,15 +150,14 @@ def test_naive_once(proxy, *args, **kwargs):
proxy = proxy.format_map(port_dict) proxy = proxy.format_map(port_dict)
config_file = kwargs.get('config_file', 'config.json') 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') config_content = kwargs.get('config_content')
if config_content is not None: if config_content is not None:
config_content = config_content.format_map(port_dict) config_content = config_content.format_map(port_dict)
with open(config_file, 'w') as f: with open(config_file, 'w') as f:
f.write('{') f.write('{' + config_content + '}')
f.write(config_content) if argv.rootfs:
f.write('}') with open(os.path.join(argv.rootfs, config_file), 'w') as f:
f.write('{' + config_content + '}')
naive_procs = [] naive_procs = []