Skip to content

Commit 714b89e

Browse files
committed
PPC64: cross build for ppc64 architecture
1 parent cd441a3 commit 714b89e

8 files changed

Lines changed: 62 additions & 3 deletions

File tree

.github/workflows/build-one.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ on:
2727
options:
2828
- arm
2929
- arm64
30+
- ppc64
3031
- x64
3132
- x86
3233
- wasm

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
type: string
2929
required: true
3030
target_cpu:
31-
description: Target (CPU arm|arm64|x64|x86|wasm)
31+
description: Target (CPU arm|arm64|ppc64|x64|x86|wasm)
3232
type: string
3333
required: true
3434
target_environment:

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash -eu
22

33
OS_NAMES="android|emscripten|ios|linux|mac|win"
4-
CPU_NAMES="arm|arm64|x64|x86|wasm"
4+
CPU_NAMES="arm|arm64|ppc64|x64|x86|wasm"
55
ENV_NAMES="catalyst|device|musl|simulator"
66
OS_ENV_COMBINATIONS="linux musl|ios (catalyst|device|simulator)"
77
STEP_REGEX="[0-9]"

patches/ppc64/build.patch

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/linux/sysroot_scripts/install-sysroot.py b/linux/sysroot_scripts/install-sysroot.py
2+
index 3158972..fadb431 100755
3+
--- a/linux/sysroot_scripts/install-sysroot.py
4+
+++ b/linux/sysroot_scripts/install-sysroot.py
5+
@@ -46,6 +46,7 @@ ARCH_TRANSLATIONS = {
6+
"mips": "mipsel",
7+
"mips64": "mips64el",
8+
"ppc64le": "ppc64el",
9+
+ "ppc64": "ppc64el",
10+
}
11+
12+
DEFAULT_TARGET_PLATFORMS = {
13+
diff --git a/toolchain/linux/BUILD.gn b/toolchain/linux/BUILD.gn
14+
index a6e20a0..b98f5dc 100644
15+
--- a/toolchain/linux/BUILD.gn
16+
+++ b/toolchain/linux/BUILD.gn
17+
@@ -312,12 +312,14 @@ gcc_toolchain("s390x") {
18+
}
19+
20+
gcc_toolchain("ppc64") {
21+
- cc = "gcc"
22+
- cxx = "g++"
23+
+ toolprefix = "powerpc64le-linux-gnu-"
24+
25+
- readelf = "readelf"
26+
- nm = "nm"
27+
- ar = "ar"
28+
+ cc = "${toolprefix}gcc"
29+
+ cxx = "${toolprefix}g++"
30+
+
31+
+ readelf = "${toolprefix}readelf"
32+
+ nm = "${toolprefix}nm"
33+
+ ar = "${toolprefix}ar"
34+
ld = cxx
35+
36+
toolchain_args = {

steps/01-install.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ case "$TARGET_OS" in
7070

7171
sudo apt-get install -y $PACKAGES
7272

73-
else
73+
else # i.e. not musl
7474

7575
case "$TARGET_CPU" in
7676
arm)
@@ -81,6 +81,14 @@ case "$TARGET_OS" in
8181
sudo apt-get install -y libc6-i386 gcc-10-multilib g++-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu
8282
;;
8383

84+
ppc64)
85+
sudo apt-get install -y gcc-11-multilib g++-11-powerpc64le-linux-gnu gcc-11-powerpc64le-linux-gnu
86+
sudo update-alternatives --install /usr/bin/powerpc64le-linux-gnu-gcc powerpc64le-linux-gnu-gcc /usr/bin/powerpc64le-linux-gnu-gcc-11 100
87+
sudo update-alternatives --install /usr/bin/powerpc64le-linux-gnu-g++ powerpc64le-linux-gnu-g++ /usr/bin/powerpc64le-linux-gnu-g++-11 100
88+
sudo update-alternatives --set powerpc64le-linux-gnu-gcc /usr/bin/powerpc64le-linux-gnu-gcc-11
89+
sudo update-alternatives --set powerpc64le-linux-gnu-g++ /usr/bin/powerpc64le-linux-gnu-g++-11
90+
;;
91+
8492
x86)
8593
sudo apt-get install -y g++-multilib
8694
;;

steps/03-patch.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
PATCHES="$PWD/patches"
44
SOURCE="${PDFium_SOURCE_DIR:-pdfium}"
55
OS="${PDFium_TARGET_OS:?}"
6+
TARGET_CPU="${PDFium_TARGET_CPU:?}"
67
TARGET_ENVIRONMENT="${PDFium_TARGET_ENVIRONMENT:-}"
78
ENABLE_V8=${PDFium_ENABLE_V8:-false}
89

@@ -68,4 +69,10 @@ case "$TARGET_ENVIRONMENT" in
6869
;;
6970
esac
7071

72+
case "$TARGET_CPU" in
73+
ppc64)
74+
apply_patch "$PATCHES/ppc64/build.patch" build
75+
;;
76+
esac
77+
7178
popd

steps/05-configure.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ mkdir -p "$BUILD"
4040
;;
4141
linux)
4242
echo "clang_use_chrome_plugins = false"
43+
if [ "$TARGET_CPU" == 'ppc64' ]; then
44+
echo 'is_clang = false'
45+
echo 'use_custom_libcxx = false'
46+
fi
4347
;;
4448
mac)
4549
echo "clang_use_chrome_plugins = false"

steps/09-test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ case "$OS" in
8686
SUFFIX="-10"
8787
fi
8888
;;
89+
ppc64)
90+
PREFIX="powerpc64le-linux-gnu-"
91+
;;
8992
x86)
9093
if [ "$TARGET_ENVIRONMENT" == "musl" ]; then
9194
PREFIX="i686-linux-musl-"

0 commit comments

Comments
 (0)