Skip to content

Commit 61ac7a8

Browse files
authored
feat: build with ndk r23c on top of webkitgtk 2.26.1 (#179)
# Why fixes #178 # How - manually pick necessary changes for ndk r23 from #169. it's ndk r23c which is newer than react-native 0.71's r23b. i cannot build jsc on top on r23b successfully. hopefully r23b <-> r23c is good for abi safety. - fix build errors for webkitgtk 2.26.1 + ndk r23. - unlike #169, this pr is still using shared c++ runtime. - update test project to 0.71 and build from source code because we need a patch to link libunwind in libjscexecutor.so. # Test Plan ci passed
1 parent ef2df99 commit 61ac7a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+6852
-5736
lines changed

.github/workflows/build_and_test.yml

+36-12
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,50 @@
11
name: Build jsc-android and test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
47

58
jobs:
69
build:
710
runs-on: ubuntu-latest
8-
container: reactnativecommunity/react-native-android:2019-9-4
11+
container: reactnativecommunity/react-native-android:5.4
912

1013
steps:
1114
- uses: actions/checkout@v1
1215

16+
- name: 🔨 Use JDK 11
17+
uses: actions/setup-java@v3
18+
with:
19+
distribution: 'temurin'
20+
java-version: '11'
21+
1322
- name: Install packages
1423
run: |
1524
apt-get update
16-
apt-get install coreutils realpath curl git subversion python3.5 python3.5-dev ruby gperf -y
17-
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
18-
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
25+
apt-get install coreutils curl git subversion wget python3 ruby gperf -y
26+
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
1927
echo 'export NVM_DIR="$HOME/.nvm"' >> "${HOME}/.bashrc"
2028
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "${HOME}/.bashrc"
2129
source "${HOME}/.bashrc"
22-
nvm install 10
23-
nvm use 10
24-
nvm alias default 10
30+
nvm install 16
31+
nvm use 16
32+
nvm alias default 16
2533
shell: bash
2634

2735
- name: Install Android packages
2836
run: |
2937
sdkmanager \
30-
"cmake;3.10.2.4988404"
38+
"cmake;3.22.1" \
39+
"ndk;23.2.8568313"
40+
# move out builtin icu headers from ndk and prevent icu build errors
41+
mv "${ANDROID_HOME}/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode" "${ANDROID_HOME}/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode2"
42+
echo "ANDROID_NDK=$ANDROID_HOME/ndk/23.2.8568313" >> $GITHUB_ENV
3143
shell: bash
44+
3245
- name: Build
3346
run: |
47+
yarn install --frozen-lockfile
3448
yarn clean
3549
yarn download
3650
yarn start
@@ -56,15 +70,25 @@ jobs:
5670
steps:
5771
- uses: actions/checkout@v1
5872

73+
- name: 🔨 Use JDK 11
74+
uses: actions/setup-java@v3
75+
with:
76+
distribution: 'temurin'
77+
java-version: '11'
78+
5979
- uses: actions/download-artifact@v2
6080
with:
6181
name: archive
6282
path: archive
6383

84+
- name: Install node packages
85+
run: yarn install --frozen-lockfile
86+
working-directory: test
87+
6488
- name: Run test
6589
uses: reactivecircus/android-emulator-runner@v2
6690
with:
67-
api-level: 16
68-
arch: x86
91+
api-level: 21
92+
arch: x86_64
6993
disable-animations: false
70-
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew assembleRelease assembleAndroidTest connectedAndroidTest
94+
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew :app:assembleRelease :app:assembleAndroidTest :app:connectedAndroidTest

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package-lock.json
22
/build
33
/dist
4+
/dist.unstripped
45

56
# Created by https://www.gitignore.io/api/node,android,reactnative,intellij+all,androidstudio,visualstudiocode
67

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsc-android",
3-
"version": "250230.2.1",
3+
"version": "250231.0.0",
44
"description": "Pre-build version of JavaScriptCore to be used by React Native apps",
55
"repository": {
66
"type": "git",

patches/ndkr23.patch

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- target-org/webkit/Source/WTF/wtf/URLHelpers.cpp 2023-02-04 00:50:26
2+
+++ target/webkit/Source/WTF/wtf/URLHelpers.cpp 2023-02-04 00:50:29
3+
@@ -301,7 +301,7 @@
4+
Optional<UChar32> previousCodePoint;
5+
while (i < length) {
6+
UChar32 c;
7+
- U16_NEXT(buffer, i, length, c)
8+
+ U16_NEXT(buffer, i, length, c);
9+
UErrorCode error = U_ZERO_ERROR;
10+
UScriptCode script = uscript_getScript(c, &error);
11+
if (error != U_ZERO_ERROR) {

scripts/compile/common.sh

+7-30
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,18 @@ TOOLCHAIN_PLATFORM=$(ls -1 $ANDROID_NDK/toolchains/llvm/prebuilt | head -1)
4949
TOOLCHAIN_DIR="$ANDROID_NDK/toolchains/llvm/prebuilt/$TOOLCHAIN_PLATFORM/"
5050

5151
# settings
52-
PLATFORM_CFLAGS_arm=" \
53-
-march=armv7-a \
54-
-mfloat-abi=softfp \
55-
-mfpu=neon \
56-
-mthumb \
57-
"
58-
PLATFORM_LDFLAGS_arm=" \
59-
-march=armv7-a \
60-
-Wl,--fix-cortex-a8 \
61-
"
52+
PLATFORM_CFLAGS_arm=""
53+
PLATFORM_LDFLAGS_arm=""
6254
JNI_ARCH_arm=armeabi-v7a
6355

6456
PLATFORM_LDFLAGS_arm64=""
6557
JNI_ARCH_arm64=arm64-v8a
6658

67-
PLATFORM_CFLAGS_x86=" \
68-
-march=i686 \
69-
-mtune=intel \
70-
-mssse3 \
71-
-mfpmath=sse \
72-
-m32 \
73-
"
59+
PLATFORM_CFLAGS_x86=""
7460
PLATFORM_LDFLAGS_x86=""
7561
JNI_ARCH_x86=x86
7662

77-
PLATFORM_CFLAGS_x86_64=" \
78-
-march=x86-64 \
79-
-msse4.2 \
80-
-mpopcnt \
81-
-m64 \
82-
-mtune=intel \
83-
"
63+
PLATFORM_CFLAGS_x86_64=""
8464
PLATFORM_LDFLAGS_x86_64=""
8565
JNI_ARCH_x86_64=x86_64
8666

@@ -119,7 +99,7 @@ DEBUG_SYMBOL_LEVEL="-g2"
11999
if [[ "$BUILD_TYPE" = "Release" ]]
120100
then
121101
FRAME_POINTER_FLAG="-fomit-frame-pointer"
122-
CFLAGS_BUILD_TYPE="-DNDEBUG -g0"
102+
CFLAGS_BUILD_TYPE="-DNDEBUG -g0 -Oz -flto=full"
123103
ICU_CFLAGS_BUILD_TYPE="-Oz"
124104
else
125105
FRAME_POINTER_FLAG="-fno-omit-frame-pointer"
@@ -133,7 +113,6 @@ COMMON_LDFLAGS=" \
133113
-Wl,-z,noexecstack \
134114
-Wl,--gc-sections \
135115
-Wl,--exclude-libs,libgcc.a \
136-
-Wl,--exclude-libs,libunwind.a \
137116
-Wl,--no-undefined \
138117
"
139118

@@ -149,7 +128,7 @@ $FRAME_POINTER_FLAG \
149128
-DCUSTOMIZE_REACT_NATIVE \
150129
$SWITCH_COMMON_CFLAGS_INTL \
151130
$CFLAGS_BUILD_TYPE \
152-
-D__ANDROID_API__=${ANDROID_API} \
131+
-D__ANDROID_MIN_SDK_VERSION__=${ANDROID_API} \
153132
"
154133

155134
COMMON_CXXFLAGS=" \
@@ -158,10 +137,8 @@ COMMON_CXXFLAGS=" \
158137
ICU_CFLAGS="$COMMON_CFLAGS $PLATFORM_CFLAGS $ICU_CFLAGS_BUILD_TYPE"
159138
ICU_CXXFLAGS="$COMMON_CXXFLAGS $ICU_CFLAGS $ICU_CFLAGS_BUILD_TYPE"
160139
ICU_LDFLAGS="$COMMON_LDFLAGS \
161-
-fuse-ld=gold \
162-
-Wl,--icf=safe \
163140
$PLATFORM_LDFLAGS \
164141
"
165142

166143
JSC_LDFLAGS="$COMMON_LDFLAGS"
167-
JSC_CFLAGS="$COMMON_CFLAGS -DU_STATIC_IMPLEMENTATION=1 -DU_SHOW_CPLUSPLUS_API=0"
144+
JSC_CFLAGS="$COMMON_CFLAGS -Wno-implicit-const-int-float-conversion -DU_STATIC_IMPLEMENTATION=1 -DU_SHOW_CPLUSPLUS_API=0 -DTRUE=1 -DFALSE=0"

scripts/compile/icu.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ $TARGETDIR/icu/source/configure --prefix=${INSTALL_DIR} \
4646
LDFLAGS="$ICU_LDFLAGS" \
4747
CC=$CROSS_COMPILE_PLATFORM_CC-clang \
4848
CXX=$CROSS_COMPILE_PLATFORM_CC-clang++ \
49-
AR=$CROSS_COMPILE_PLATFORM-ar \
50-
RINLIB=$CROSS_COMPILE_PLATFORM-ranlib \
49+
AR=$TOOLCHAIN_DIR/bin/llvm-ar \
50+
LD=$TOOLCHAIN_DIR/bin/ld \
51+
RANLIB=$TOOLCHAIN_DIR/bin/llvm-ranlib \
52+
STRIP=$TOOLCHAIN_DIR/bin/llvm-strip \
5153
--with-data-packaging=static
5254

5355
make -j5 install

scripts/compile/jsc.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ $TARGETDIR/webkit/Tools/Scripts/build-webkit \
6464
--no-netscape-plugin-api \
6565
--no-tools \
6666
--cmakeargs="-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
67+
-DUSE_LD_GOLD=OFF \
6768
-DANDROID_ABI=${JNI_ARCH} \
6869
-DANDROID_PLATFORM=${ANDROID_API} \
6970
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
@@ -90,7 +91,7 @@ mkdir -p $INSTALL_UNSTRIPPED_DIR_I18N/$JNI_ARCH
9091
mkdir -p $INSTALL_DIR_I18N/$JNI_ARCH
9192
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_UNSTRIPPED_DIR_I18N/$JNI_ARCH
9293
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_DIR_I18N/$JNI_ARCH
93-
$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/bin/strip $INSTALL_DIR_I18N/$JNI_ARCH/libjsc.so
94+
$TOOLCHAIN_DIR/bin/llvm-strip $INSTALL_DIR_I18N/$JNI_ARCH/libjsc.so
9495
mv $TARGETDIR/webkit/WebKitBuild $TARGETDIR/webkit/${CROSS_COMPILE_PLATFORM}-${FLAVOR}
9596

9697
cp $TOOLCHAIN_DIR/sysroot/usr/lib/$CROSS_COMPILE_PLATFORM/libc++_shared.so $INSTALL_CPPRUNTIME_DIR

scripts/info.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ URL="https://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-${npm_pa
44
ROOTDIR=$PWD
55

66
INFO=$(svn info "${URL}")
7-
export REVISION=$(LANG=en svn info "${URL}" | sed -n 's/^Last Changed Rev: //p')
7+
export REVISION=$(node -e "console.log(require('./package.json').version.split('.')[0])")
8+
WEBKIT_REVISION=$(LANG=en svn info "${URL}" | sed -n 's/^Last Changed Rev: //p')
89
CONFIG=$(node -e "console.log(require('$ROOTDIR/package.json').config)")
910
APPLE_VERSION=$(svn cat "${URL}/Source/WebCore/Configurations/Version.xcconfig" | grep 'MAJOR_VERSION\s=\|MINOR_VERSION\s=\|TINY_VERSION\s=\|MICRO_VERSION\s=\|NANO_VERSION\s=')
1011

@@ -15,6 +16,7 @@ else
1516
fi
1617

1718
printf "\n\n\n\n\n\t\t\tRevision: \x1B[32m$REVISION\x1B[0m\n\n\n"
19+
printf "WebKit revision:\n$WEBKIT_REVISION\n\n"
1820
printf "Config:\n$CONFIG\n\n"
1921
printf "Info:\n$INFO\n\n"
2022
printf "AppleWebkit:\n$APPLE_VERSION\n\n"

scripts/patch.sh

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ JSC_PATCHSET=(
1515
# Feature toggles, e.g. disable unnecessary build or JIT settings
1616
"jsc_features.patch"
1717

18+
# NDK r23 errors
19+
"ndkr23.patch"
20+
1821
# NDK does not support backtrace and execinfo.h
1922
"jsc_fix_build_error_execinfo.patch"
2023

test/.buckconfig

-6
This file was deleted.

test/.flowconfig

-75
This file was deleted.

test/.gitattributes

-1
This file was deleted.

test/.gitignore

+14-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23+
ios/.xcode.env.local
2324

2425
# Android/IntelliJ
2526
#
@@ -28,32 +29,35 @@ build/
2829
.gradle
2930
local.properties
3031
*.iml
32+
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
3136

3237
# node.js
3338
#
3439
node_modules/
3540
npm-debug.log
3641
yarn-error.log
3742

38-
# BUCK
39-
buck-out/
40-
\.buckd/
41-
*.keystore
42-
!debug.keystore
43-
4443
# fastlane
4544
#
4645
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4746
# screenshots whenever they are needed.
4847
# For more information about the recommended setup visit:
4948
# https://docs.fastlane.tools/best-practices/source-control/
5049

51-
*/fastlane/report.xml
52-
*/fastlane/Preview.html
53-
*/fastlane/screenshots
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
5454

5555
# Bundle artifact
5656
*.jsbundle
5757

58-
# CocoaPods
58+
# Ruby / CocoaPods
5959
/ios/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*

0 commit comments

Comments
 (0)