From 4277651fc11618a4031deb0dc6ef65a5703a7166 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 03:48:51 +0800 Subject: [PATCH 01/14] test v8 10.0 with ndk r21 --- .github/Dockerfile | 2 +- .github/workflows/android.yml | 4 +- .github/workflows/ios.yml | 4 +- .github/workflows/tools_macos_android.yml | 3 +- package.json | 2 +- packages/v8-android-jit-nointl/package.json | 4 +- packages/v8-android-jit/package.json | 4 +- packages/v8-android-nointl/package.json | 4 +- packages/v8-android-tools-linux/package.json | 2 +- packages/v8-android-tools-macos/package.json | 2 +- packages/v8-android/package.json | 4 +- packages/v8-ios/package.json | 27 +++++++++ packages/v8-ios/v8-ios.podspec | 21 +++++++ scripts/archive.sh | 53 +++++++++++++---- scripts/build.sh | 60 +++++++++++++------- scripts/env.sh | 10 +++- scripts/setup.sh | 6 +- 17 files changed, 159 insertions(+), 53 deletions(-) create mode 100644 packages/v8-ios/package.json create mode 100644 packages/v8-ios/v8-ios.podspec diff --git a/.github/Dockerfile b/.github/Dockerfile index bf81ca3..b20b138 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update ENV DEBIAN_FRONTEND noninteractive RUN apt-get install -y sudo -RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu +RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1001 ubuntu RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers USER ubuntu WORKDIR /home/ubuntu diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3fdec71..be7b9ed 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,6 +1,8 @@ name: Build for Android -on: [push] +on: + push: + workflow_dispatch: env: CACHE_KEY_SUFFIX: v2 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 2922d7c..1e98497 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,6 +1,8 @@ name: iOS build -on: [push] +on: + push: + workflow_dispatch: jobs: build: diff --git a/.github/workflows/tools_macos_android.yml b/.github/workflows/tools_macos_android.yml index 26fb92d..38e590c 100644 --- a/.github/workflows/tools_macos_android.yml +++ b/.github/workflows/tools_macos_android.yml @@ -1,6 +1,7 @@ name: v8-android tools builder for macos host -on: [push] +on: + workflow_dispatch: env: CACHE_KEY_SUFFIX: v2 diff --git a/package.json b/package.json index 83693ce..b62d104 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "10.100.1", + "version": "11.1000.3", "workspaces": [ "packages/*" ], diff --git a/packages/v8-android-jit-nointl/package.json b/packages/v8-android-jit-nointl/package.json index d2f5d24..d19bcea 100644 --- a/packages/v8-android-jit-nointl/package.json +++ b/packages/v8-android-jit-nointl/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-jit-nointl", - "version": "10.100.1", + "version": "11.1000.3", "description": "Pre-build version of V8 to be used by React Native apps", "repository": { "type": "git", @@ -18,6 +18,6 @@ }, "homepage": "https://github.com/Kudo/v8-android-buildscripts#readme", "files": [ - "dist/" + "dist/**/*" ] } diff --git a/packages/v8-android-jit/package.json b/packages/v8-android-jit/package.json index 0d9c792..a5fc8a3 100644 --- a/packages/v8-android-jit/package.json +++ b/packages/v8-android-jit/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-jit", - "version": "10.100.1", + "version": "11.1000.3", "description": "Pre-build version of V8 to be used by React Native apps", "repository": { "type": "git", @@ -18,6 +18,6 @@ }, "homepage": "https://github.com/Kudo/v8-android-buildscripts#readme", "files": [ - "dist/" + "dist/**/*" ] } diff --git a/packages/v8-android-nointl/package.json b/packages/v8-android-nointl/package.json index f696a34..d4a77e1 100644 --- a/packages/v8-android-nointl/package.json +++ b/packages/v8-android-nointl/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-nointl", - "version": "10.100.1", + "version": "11.1000.3", "description": "Pre-build version of V8 to be used by React Native apps (Non Intl supported version)", "repository": { "type": "git", @@ -18,6 +18,6 @@ }, "homepage": "https://github.com/Kudo/v8-android-buildscripts#readme", "files": [ - "dist/" + "dist/**/*" ] } diff --git a/packages/v8-android-tools-linux/package.json b/packages/v8-android-tools-linux/package.json index 3c1b3c4..c2638f6 100644 --- a/packages/v8-android-tools-linux/package.json +++ b/packages/v8-android-tools-linux/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-tools-linux", - "version": "10.100.1", + "version": "11.1000.3", "description": "Tools for v8-android", "repository": { "type": "git", diff --git a/packages/v8-android-tools-macos/package.json b/packages/v8-android-tools-macos/package.json index f6a2a5c..ea3fd98 100644 --- a/packages/v8-android-tools-macos/package.json +++ b/packages/v8-android-tools-macos/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-tools-macos", - "version": "10.100.1", + "version": "11.1000.3", "description": "Tools for v8-android", "repository": { "type": "git", diff --git a/packages/v8-android/package.json b/packages/v8-android/package.json index 3237bcf..dcf0bb8 100644 --- a/packages/v8-android/package.json +++ b/packages/v8-android/package.json @@ -1,6 +1,6 @@ { "name": "v8-android", - "version": "10.100.1", + "version": "11.1000.3", "description": "Pre-build version of V8 to be used by React Native apps", "repository": { "type": "git", @@ -18,6 +18,6 @@ }, "homepage": "https://github.com/Kudo/v8-android-buildscripts#readme", "files": [ - "dist/" + "dist/**/*" ] } diff --git a/packages/v8-ios/package.json b/packages/v8-ios/package.json new file mode 100644 index 0000000..52b8533 --- /dev/null +++ b/packages/v8-ios/package.json @@ -0,0 +1,27 @@ +{ + "name": "v8-ios", + "version": "11.110.0", + "description": "Pre-build version of V8 to be used by React Native apps", + "repository": { + "type": "git", + "url": "git+https://github.com/Kudo/v8-android-buildscripts.git", + "directory": "packages/v8-ios" + }, + "keywords": [ + "react-native", + "ios", + "v8" + ], + "author": "Kudo Chien", + "license": "BSD-2-Clause", + "bugs": { + "url": "https://github.com/Kudo/v8-android-buildscripts/issues" + }, + "homepage": "https://github.com/Kudo/v8-android-buildscripts#readme", + "files": [ + "v8-ios.podspec", + "include/", + "v8.xcframework/**/*", + "tools/" + ] +} diff --git a/packages/v8-ios/v8-ios.podspec b/packages/v8-ios/v8-ios.podspec new file mode 100644 index 0000000..56b818d --- /dev/null +++ b/packages/v8-ios/v8-ios.podspec @@ -0,0 +1,21 @@ +require "json" + +package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) + +Pod::Spec.new do |s| + s.name = package['name'] + s.version = package['version'] + s.summary = package['description'] + s.license = package['license'] + + s.author = package['author'] + s.homepage = package['homepage'] + s.platforms = { :ios => "12.0" } + + s.source = { :http => "https://registry.npmjs.org/v8-ios/-/v8-ios-#{s.version}.tgz" } + + s.vendored_framework = 'v8.xcframework' + s.source_files = 'include/**/*.h' + s.preserve_paths = 'include' + s.header_mappings_dir = 'include' +end diff --git a/scripts/archive.sh b/scripts/archive.sh index bc5f0d1..20c9eb6 100755 --- a/scripts/archive.sh +++ b/scripts/archive.sh @@ -21,6 +21,7 @@ function makeDistPackageDir() { } DIST_PACKAGE_DIR=$(makeDistPackageDir) +mkdir -p "${DIST_PACKAGE_DIR}" function createAAR() { printf "\n\n\t\t===================== create aar =====================\n\n" @@ -30,16 +31,45 @@ function createAAR() { popd } -function createUniversalDylib() { - printf "\n\n\t\t===================== create universal dylib =====================\n\n" - mkdir -p "${BUILD_DIR}/lib/universal" - lipo "${BUILD_DIR}/lib/arm64/libv8.dylib" "${BUILD_DIR}/lib/x64/libv8.dylib" -output "${BUILD_DIR}/lib/universal/libv8.dylib" -create -} - -function copyDylib() { - printf "\n\n\t\t===================== copy dylib =====================\n\n" - mkdir -p "${DIST_PACKAGE_DIR}" - cp -Rf "${BUILD_DIR}/lib" "${DIST_PACKAGE_DIR}/" +function createXcframework() { + plist=$(cat << EOF + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + v8 + CFBundleIdentifier + io.csie.kudo.v8.framework + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + + +EOF +) + printf "\n\n\t\t===================== create ios device framework =====================\n\n" + mkdir -p "${BUILD_DIR}/ios-arm64/v8.framework" + echo "${plist}" > "${BUILD_DIR}/ios-arm64/v8.framework/Info.plist" + cp -f "${BUILD_DIR}/lib/device/arm64/libv8.dylib" "${BUILD_DIR}/ios-arm64/v8.framework/v8" + install_name_tool -id "@rpath/v8.framework/v8" "${BUILD_DIR}/ios-arm64/v8.framework/v8" + + printf "\n\n\t\t===================== create ios simulator framework =====================\n\n" + mkdir -p "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework" + echo "${plist}" > "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework/Info.plist" + lipo "${BUILD_DIR}/lib/simulator/arm64/libv8.dylib" "${BUILD_DIR}/lib/simulator/x64/libv8.dylib" -output "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework/v8" -create + install_name_tool -id "@rpath/v8.framework/v8" "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework/v8" + + printf "\n\n\t\t===================== create ios xcframework =====================\n\n" + rm -rf "${BUILD_DIR}/v8.xcframework" + xcodebuild -create-xcframework -framework "${BUILD_DIR}/ios-arm64/v8.framework" -framework "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework" -output "${BUILD_DIR}/v8.xcframework" + + cp -Rf "${BUILD_DIR}/v8.xcframework" "${DIST_PACKAGE_DIR}/v8.xcframework" } function createUnstrippedLibs() { @@ -87,8 +117,7 @@ if [[ ${PLATFORM} = "android" ]]; then copyTools copySnapshotBlobIfNeeded elif [[ ${PLATFORM} = "ios" ]]; then - createUniversalDylib - copyDylib + createXcframework copyHeaders copyTools copySnapshotBlobIfNeeded diff --git a/scripts/build.sh b/scripts/build.sh index 8c0a9c2..54cc78a 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -12,6 +12,7 @@ GN_ARGS_BASE=" icu_use_data_file=false treat_warnings_as_errors=false default_min_sdk_version=21 + v8_enable_sandbox=false " if [[ ${PLATFORM} = "macos_android" ]]; then @@ -21,7 +22,7 @@ else fi if [[ ${PLATFORM} = "ios" ]]; then - GN_ARGS_BASE="${GN_ARGS_BASE} enable_ios_bitcode=false use_xcode_clang=true ios_enable_code_signing=false v8_enable_pointer_compression=false ios_deployment_target=${IOS_DEPLOYMENT_TARGET}" + GN_ARGS_BASE="${GN_ARGS_BASE} enable_ios_bitcode=false use_xcode_clang=true ios_enable_code_signing=false v8_enable_pointer_compression=false ios_deployment_target=\"${IOS_DEPLOYMENT_TARGET}\" v8_control_flow_integrity=false v8_enable_lite_mode=true" elif [[ ${PLATFORM} = "android" ]]; then # Workaround v8 sysroot build issues with custom ndk GN_ARGS_BASE="${GN_ARGS_BASE} use_sysroot=false" @@ -93,6 +94,7 @@ function normalize_arch_for_platform() function buildArch() { local arch=$1 + local ios_env=$2 local platform_arch=$(normalize_arch_for_platform $arch) local target='' @@ -109,71 +111,86 @@ function buildArch() exit 1 fi - echo "Build v8 ${arch} variant NO_INTL=${NO_INTL} NO_JIT=${NO_JIT}" - gn gen --args="${GN_ARGS_BASE} ${GN_ARGS_BUILD_TYPE} target_cpu=\"${arch}\"" "out.v8.${arch}" + local output_dir='' + if [[ ${PLATFORM} = "ios" ]]; then + echo "Build v8 ${ios_env} ${arch} variant NO_INTL=${NO_INTL}" + output_dir="out.v8.ios.${ios_env}.${arch}" + gn gen --args="${GN_ARGS_BASE} ${GN_ARGS_BUILD_TYPE} target_cpu=\"${arch}\" target_environment=\"${ios_env}\"" "${output_dir}" + else + echo "Build v8 ${arch} variant NO_INTL=${NO_INTL} NO_JIT=${NO_JIT}" + output_dir="out.v8.${arch}" + gn gen --args="${GN_ARGS_BASE} ${GN_ARGS_BUILD_TYPE} target_cpu=\"${arch}\"" "${output_dir}" + fi if [[ ${TOOLS_ONLY} = "true" ]]; then - date ; ninja ${NINJA_PARAMS} -C "out.v8.${arch}" run_mksnapshot_default mkcodecache_group ; date - copySnapshot $arch - copyMkcodecache $arch + date ; ninja ${NINJA_PARAMS} -C "${output_dir}" run_mksnapshot_default mkcodecache_group ; date + copySnapshot "${arch}" "${output_dir}" + copyMkcodecache "${arch}" "${output_dir}" else - date ; ninja ${NINJA_PARAMS} -C "out.v8.${arch}" ${target} run_mksnapshot_default mkcodecache_group ; date - copyLib $arch - copySnapshot $arch - copyMkcodecache $arch + date ; ninja ${NINJA_PARAMS} -C "${output_dir}" ${target} run_mksnapshot_default mkcodecache_group ; date + copyLib "${arch}" "${output_dir}" "${ios_env}" + copySnapshot "${arch}" "${output_dir}" + copyMkcodecache "${arch}" "${output_dir}" fi } function copyLib() { local arch=$1 + local output_dir=$2 + local ios_env=$3 local platform_arch=$(normalize_arch_for_platform $arch) local target='' local target_ext='' + local lib_dir='' if [[ ${PLATFORM} = "android" ]]; then target="libv8android" target_ext=".so" + lib_dir="${platform_arch}" elif [[ ${PLATFORM} = "ios" ]]; then target="libv8" target_ext=".dylib" + lib_dir="${ios_env}/${platform_arch}" else exit 1 fi - mkdir -p "${BUILD_DIR}/lib/${platform_arch}" - cp -f "out.v8.${arch}/${target}${target_ext}" "${BUILD_DIR}/lib/${platform_arch}/${target}${target_ext}" + mkdir -p "${BUILD_DIR}/lib/${lib_dir}" + cp -f "${output_dir}/${target}${target_ext}" "${BUILD_DIR}/lib/${lib_dir}/${target}${target_ext}" - if [[ -d "out.v8.${arch}/lib.unstripped" ]]; then - mkdir -p "${BUILD_DIR}/lib.unstripped/${platform_arch}" - cp -f "out.v8.${arch}/lib.unstripped/${target}${target_ext}" "${BUILD_DIR}/lib.unstripped/${platform_arch}/${target}${target_ext}" + if [[ -d "${output_dir}/lib.unstripped" ]]; then + mkdir -p "${BUILD_DIR}/lib.unstripped/${lib_dir}" + cp -f "${output_dir}/lib.unstripped/${target}${target_ext}" "${BUILD_DIR}/lib.unstripped/${lib_dir}/${target}${target_ext}" fi } function copySnapshot() { local arch=$1 + local output_dir=$2 local platform_arch=$(normalize_arch_for_platform $arch) mkdir -p "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}" - cp -f out.v8.${arch}/clang_*/mksnapshot "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}/mksnapshot" + cp -f ${output_dir}/clang_*/mksnapshot "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}/mksnapshot" if [[ ${EXTERNAL_STARTUP_DATA} = "true" || ${TOOLS_ONLY} = "true" ]]; then mkdir -p "${BUILD_DIR}/snapshot_blob/${platform_arch}" - cp -f out.v8.${arch}/snapshot_blob.bin "${BUILD_DIR}/snapshot_blob/${platform_arch}/snapshot_blob.bin" + cp -f ${output_dir}/snapshot_blob.bin "${BUILD_DIR}/snapshot_blob/${platform_arch}/snapshot_blob.bin" fi } function copyMkcodecache() { local arch=$1 + local output_dir=$2 local platform_arch=$(normalize_arch_for_platform $arch) mkdir -p "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}" - cp -f out.v8.${arch}/clang_*/mkcodecache "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}/mkcodecache" + cp -f ${output_dir}/clang_*/mkcodecache "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}/mkcodecache" if [[ ${EXTERNAL_STARTUP_DATA} = "true" || ${TOOLS_ONLY} = "true" ]]; then - cp -f out.v8.${arch}/clang_*/snapshot_blob.bin "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}/snapshot_blob.bin" + cp -f ${output_dir}/clang_*/snapshot_blob.bin "${BUILD_DIR}/tools/${PLATFORM}/${platform_arch}/snapshot_blob.bin" fi } @@ -185,8 +202,9 @@ elif [[ ${PLATFORM} = "android" ]]; then buildArch "arm64" buildArch "x64" elif [[ ${PLATFORM} = "ios" ]]; then - buildArch "arm64" - buildArch "x64" + buildArch "arm64" "device" + buildArch "arm64" "simulator" + buildArch "x64" "simulator" elif [[ ${PLATFORM} = "macos_android" ]]; then # buildArch "arm" # buildArch "x86" diff --git a/scripts/env.sh b/scripts/env.sh index 87cc8c9..319ee20 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -43,8 +43,14 @@ DIST_DIR="${ROOT_DIR}/dist" PATCHES_DIR="${ROOT_DIR}/patches" NDK_VERSION="r21e" -IOS_DEPLOYMENT_TARGET="9" -EXTERNAL_STARTUP_DATA="true" +IOS_DEPLOYMENT_TARGET="12.0" export PATH="$DEPOT_TOOLS_DIR:$PATH" PLATFORM=$(verify_platform $1) + +if [[ ${PLATFORM} = "android" ]]; then + EXTERNAL_STARTUP_DATA="true" +else + EXTERNAL_STARTUP_DATA="false" + NO_JIT="true" +fi diff --git a/scripts/setup.sh b/scripts/setup.sh index 1429c35..63bffbc 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -20,9 +20,9 @@ function installNDK() { local host_arch=$1 pushd . cd "${V8_DIR}" - wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip - unzip -q android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip - rm -f android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip + wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-${host_arch}.zip + unzip -q android-ndk-${NDK_VERSION}-${host_arch}.zip + rm -f android-ndk-${NDK_VERSION}-${host_arch}.zip popd } From 11f7a1fbff20e2cc7d8d44a1169d23a4e135cc09 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 04:18:55 +0800 Subject: [PATCH 02/14] fix --- scripts/setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/setup.sh b/scripts/setup.sh index 63bffbc..4e29697 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -43,9 +43,12 @@ if [[ ${PLATFORM} = "android" ]]; then gclient sync --deps=android # Patch build-deps installer for snapd not available in docker + echo "ooxx setup patch prebuild_no_snapd" patch -d "${V8_DIR}" -p1 < "${PATCHES_DIR}/prebuild_no_snapd.patch" + echo "ooxx install-build-deps-android" sudo bash -c 'v8/build/install-build-deps-android.sh' + echo "ooxx install apt-get" sudo apt-get -y install \ libc6-dev \ libc6-dev-i386 \ @@ -62,14 +65,18 @@ if [[ ${PLATFORM} = "android" ]]; then libsfstdc++-10-dev-armhf-cross # Reset changes after installation + echo "ooxx setup revert prebuild_no_snapd" patch -d "${V8_DIR}" -p1 -R < "${PATCHES_DIR}/prebuild_no_snapd.patch" # Workaround to install missing sysroot + echo "ooxx gclient sync#1" gclient sync # Workaround to install missing android_sdk tools + echo "ooxx gclient sync#2" gclient sync --deps=android + echo "ooxx install ndk" installNDK "linux" exit 0 fi From c5ace5eef6e4d4fc42d60068b6a7dc4e87626e4c Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 12:27:36 +0800 Subject: [PATCH 03/14] lock depot_tools version --- .github/workflows/android.yml | 1 + .github/workflows/ios.yml | 3 +++ .github/workflows/tools_macos_android.yml | 1 + scripts/setup.sh | 3 +++ 4 files changed, 8 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index be7b9ed..a95e82a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -22,6 +22,7 @@ jobs: TZ: UTC NO_INTL: ${{ contains(matrix.variant, 'nointl') }} NO_JIT: ${{ !contains(matrix.variant, 'jit') }} + DEPOT_TOOLS_UPDATE: 0 steps: - name: Setup docker workspace diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 1e98497..f26051f 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -4,6 +4,9 @@ on: push: workflow_dispatch: +env: + DEPOT_TOOLS_UPDATE: 0 + jobs: build: runs-on: macOS-latest diff --git a/.github/workflows/tools_macos_android.yml b/.github/workflows/tools_macos_android.yml index 38e590c..be47b92 100644 --- a/.github/workflows/tools_macos_android.yml +++ b/.github/workflows/tools_macos_android.yml @@ -5,6 +5,7 @@ on: env: CACHE_KEY_SUFFIX: v2 + DEPOT_TOOLS_UPDATE: 0 jobs: macos: diff --git a/scripts/setup.sh b/scripts/setup.sh index 4e29697..90a042b 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -28,6 +28,9 @@ function installNDK() { if [[ ! -d "${DEPOT_TOOLS_DIR}" || ! -f "${DEPOT_TOOLS_DIR}/gclient" ]]; then git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${DEPOT_TOOLS_DIR}" + pushd "${DEPOT_TOOLS_DIR}" + git checkout 'main@{2022-07-05}' + popd fi gclient config --name v8 --unmanaged "https://chromium.googlesource.com/v8/v8.git" From 46773baf243653f4790423cab7796675cde2fdb7 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 12:51:41 +0800 Subject: [PATCH 04/14] fix --- scripts/setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 90a042b..cc7b708 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -20,9 +20,9 @@ function installNDK() { local host_arch=$1 pushd . cd "${V8_DIR}" - wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-${host_arch}.zip - unzip -q android-ndk-${NDK_VERSION}-${host_arch}.zip - rm -f android-ndk-${NDK_VERSION}-${host_arch}.zip + wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip + unzip -q android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip + rm -f android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip popd } From 641ba7662a8baeb235ab1d2452f8d9a26f30943e Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 13:37:32 +0800 Subject: [PATCH 05/14] fix --- .github/workflows/ios.yml | 2 +- scripts/setup.sh | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index f26051f..c0892d4 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -23,7 +23,7 @@ jobs: - name: Setup V8 build environment run: | - brew install coreutils + brew install coreutils ninja scripts/setup.sh -r ${V8_VERSION} ios - name: Patch V8 diff --git a/scripts/setup.sh b/scripts/setup.sh index cc7b708..1238f3c 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -46,13 +46,11 @@ if [[ ${PLATFORM} = "android" ]]; then gclient sync --deps=android # Patch build-deps installer for snapd not available in docker - echo "ooxx setup patch prebuild_no_snapd" patch -d "${V8_DIR}" -p1 < "${PATCHES_DIR}/prebuild_no_snapd.patch" - echo "ooxx install-build-deps-android" sudo bash -c 'v8/build/install-build-deps-android.sh' - echo "ooxx install apt-get" sudo apt-get -y install \ + ninja-build \ libc6-dev \ libc6-dev-i386 \ libc6-dev-armel-cross \ @@ -68,18 +66,14 @@ if [[ ${PLATFORM} = "android" ]]; then libsfstdc++-10-dev-armhf-cross # Reset changes after installation - echo "ooxx setup revert prebuild_no_snapd" patch -d "${V8_DIR}" -p1 -R < "${PATCHES_DIR}/prebuild_no_snapd.patch" # Workaround to install missing sysroot - echo "ooxx gclient sync#1" gclient sync # Workaround to install missing android_sdk tools - echo "ooxx gclient sync#2" gclient sync --deps=android - echo "ooxx install ndk" installNDK "linux" exit 0 fi From 913c7516ae0ce6737a1f8ec84a494c292ce6b4e8 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 18:40:30 +0800 Subject: [PATCH 06/14] fix --- .github/workflows/ios.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index c0892d4..1f4010a 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -17,6 +17,9 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: Use Xcode 13 + run: sudo xcode-select --switch /Applications/Xcode_13.2.1.app + - name: Export settings from npm package run: | npm run export_npm_env From 7edd32a8ab80f366c2eb4e23d62a90ca0d64d043 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 18:45:33 +0800 Subject: [PATCH 07/14] fix --- .github/workflows/ios.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 1f4010a..80ca3f6 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: Use Xcode 13 + - name: Use Xcode 13 run: sudo xcode-select --switch /Applications/Xcode_13.2.1.app - name: Export settings from npm package From 9f8c8dc246889b77a7b211657c69180dfd4efe07 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Fri, 28 Apr 2023 22:49:55 +0800 Subject: [PATCH 08/14] use macos 11 --- .github/workflows/ios.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 80ca3f6..b58ad0f 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -9,7 +9,7 @@ env: jobs: build: - runs-on: macOS-latest + runs-on: macos-11 env: NO_INTL: false NO_JIT: true @@ -17,9 +17,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Use Xcode 13 - run: sudo xcode-select --switch /Applications/Xcode_13.2.1.app - - name: Export settings from npm package run: | npm run export_npm_env From 2ac52855881088fb699fac4ed23dda7e94c885f5 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 30 Apr 2023 00:13:50 +0800 Subject: [PATCH 09/14] try to fix ios build error --- patches/system_xcode_build_error.patch | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/patches/system_xcode_build_error.patch b/patches/system_xcode_build_error.patch index acf8c23..23f045c 100644 --- a/patches/system_xcode_build_error.patch +++ b/patches/system_xcode_build_error.patch @@ -11,3 +11,34 @@ index bc3de06d0..1e96de22c 100644 # TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here. cflags += [ "-Xclang", +diff --git a/config/ios/BUILD.gn b/config/ios/BUILD.gn +index 0ec875e9c..104fa9275 100644 +--- a/build/config/ios/BUILD.gn ++++ b/build/config/ios/BUILD.gn +@@ -126,16 +126,16 @@ config("runtime_library") { + # TODO(crbug.com/1223481): Temporarily use a different + # libclang_rt.iossim.a for arm64 simulator builds. This can be + # removed when an arm64 slice is added to upstream Clang. +- if (target_environment == "simulator" && current_cpu == "arm64") { +- assert(1300 <= xcode_version_int && xcode_version_int <= 1321) +- ldflags += [ +- "-lSystem", +- rebase_path("$ios_toolchains_path/usr/lib/clang/13.0.0/" + +- "lib/darwin/libclang_rt.iossim.a", +- root_build_dir), +- "-nodefaultlibs", +- ] +- } ++ # if (target_environment == "simulator" && current_cpu == "arm64") { ++ # assert(1300 <= xcode_version_int && xcode_version_int <= 1321) ++ # ldflags += [ ++ # "-lSystem", ++ # rebase_path("$ios_toolchains_path/usr/lib/clang/13.0.0/" + ++ # "lib/darwin/libclang_rt.iossim.a", ++ # root_build_dir), ++ # "-nodefaultlibs", ++ # ] ++ # } + + # TODO(crbug.com/1259122): Temporarily use a different libclang_rt.osx.a + # for catalyst build. This can be removed when a catalyst slice is added From a21ada28c4b296d72db933c004e192ee4d6398a9 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 30 Apr 2023 11:02:24 +0800 Subject: [PATCH 10/14] try to fix ios build error --- patches/system_xcode_build_error.patch | 46 +++++++++----------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/patches/system_xcode_build_error.patch b/patches/system_xcode_build_error.patch index 23f045c..43b0bba 100644 --- a/patches/system_xcode_build_error.patch +++ b/patches/system_xcode_build_error.patch @@ -11,34 +11,20 @@ index bc3de06d0..1e96de22c 100644 # TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here. cflags += [ "-Xclang", -diff --git a/config/ios/BUILD.gn b/config/ios/BUILD.gn -index 0ec875e9c..104fa9275 100644 ---- a/build/config/ios/BUILD.gn -+++ b/build/config/ios/BUILD.gn -@@ -126,16 +126,16 @@ config("runtime_library") { - # TODO(crbug.com/1223481): Temporarily use a different - # libclang_rt.iossim.a for arm64 simulator builds. This can be - # removed when an arm64 slice is added to upstream Clang. -- if (target_environment == "simulator" && current_cpu == "arm64") { -- assert(1300 <= xcode_version_int && xcode_version_int <= 1321) -- ldflags += [ -- "-lSystem", -- rebase_path("$ios_toolchains_path/usr/lib/clang/13.0.0/" + -- "lib/darwin/libclang_rt.iossim.a", -- root_build_dir), -- "-nodefaultlibs", -- ] -- } -+ # if (target_environment == "simulator" && current_cpu == "arm64") { -+ # assert(1300 <= xcode_version_int && xcode_version_int <= 1321) -+ # ldflags += [ -+ # "-lSystem", -+ # rebase_path("$ios_toolchains_path/usr/lib/clang/13.0.0/" + -+ # "lib/darwin/libclang_rt.iossim.a", -+ # root_build_dir), -+ # "-nodefaultlibs", -+ # ] -+ # } +diff --git a/config/c++/BUILD.gn b/config/c++/BUILD.gn +index e7ed69ec8..cf73e4490 100644 +--- a/config/c++/BUILD.gn ++++ b/config/c++/BUILD.gn +@@ -121,7 +121,11 @@ config("runtime_library") { - # TODO(crbug.com/1259122): Temporarily use a different libclang_rt.osx.a - # for catalyst build. This can be removed when a catalyst slice is added + # Make sure we don't link against the system libstdc++ or libc++. + if (is_clang) { +- ldflags += [ "-nostdlib++" ] ++ if (target_environment == "simulator" && current_cpu == "arm64") { ++ // noop ++ } else { ++ ldflags += [ "-nostdlib++" ] ++ } + } else { + # Gcc has a built-in abs() definition with default visibility. + # If it was not disabled, it would conflict with libc++'s abs() From 8205d459b88d79cbb876ce1abf2123180827284d Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 30 Apr 2023 13:57:28 +0800 Subject: [PATCH 11/14] try to fix ios build error --- patches/system_xcode_build_error.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/system_xcode_build_error.patch b/patches/system_xcode_build_error.patch index 43b0bba..c9d4723 100644 --- a/patches/system_xcode_build_error.patch +++ b/patches/system_xcode_build_error.patch @@ -13,8 +13,8 @@ index bc3de06d0..1e96de22c 100644 "-Xclang", diff --git a/config/c++/BUILD.gn b/config/c++/BUILD.gn index e7ed69ec8..cf73e4490 100644 ---- a/config/c++/BUILD.gn -+++ b/config/c++/BUILD.gn +--- a/build/config/c++/BUILD.gn ++++ b/build/config/c++/BUILD.gn @@ -121,7 +121,11 @@ config("runtime_library") { # Make sure we don't link against the system libstdc++ or libc++. From 25edd89148f0f2143f55a7d11f35fe205469df54 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 20 Aug 2023 00:36:39 +0800 Subject: [PATCH 12/14] Bump --- package.json | 2 +- packages/v8-android-jit-nointl/package.json | 2 +- packages/v8-android-jit/package.json | 2 +- packages/v8-android-nointl/package.json | 2 +- packages/v8-android-tools-linux/package.json | 2 +- packages/v8-android-tools-macos/package.json | 2 +- packages/v8-android/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b62d104..94cd5fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "11.1000.3", + "version": "11.1000.4", "workspaces": [ "packages/*" ], diff --git a/packages/v8-android-jit-nointl/package.json b/packages/v8-android-jit-nointl/package.json index d19bcea..b60c0df 100644 --- a/packages/v8-android-jit-nointl/package.json +++ b/packages/v8-android-jit-nointl/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-jit-nointl", - "version": "11.1000.3", + "version": "11.1000.4", "description": "Pre-build version of V8 to be used by React Native apps", "repository": { "type": "git", diff --git a/packages/v8-android-jit/package.json b/packages/v8-android-jit/package.json index a5fc8a3..79d6dd0 100644 --- a/packages/v8-android-jit/package.json +++ b/packages/v8-android-jit/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-jit", - "version": "11.1000.3", + "version": "11.1000.4", "description": "Pre-build version of V8 to be used by React Native apps", "repository": { "type": "git", diff --git a/packages/v8-android-nointl/package.json b/packages/v8-android-nointl/package.json index d4a77e1..fa2236c 100644 --- a/packages/v8-android-nointl/package.json +++ b/packages/v8-android-nointl/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-nointl", - "version": "11.1000.3", + "version": "11.1000.4", "description": "Pre-build version of V8 to be used by React Native apps (Non Intl supported version)", "repository": { "type": "git", diff --git a/packages/v8-android-tools-linux/package.json b/packages/v8-android-tools-linux/package.json index c2638f6..d9b5e42 100644 --- a/packages/v8-android-tools-linux/package.json +++ b/packages/v8-android-tools-linux/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-tools-linux", - "version": "11.1000.3", + "version": "11.1000.4", "description": "Tools for v8-android", "repository": { "type": "git", diff --git a/packages/v8-android-tools-macos/package.json b/packages/v8-android-tools-macos/package.json index ea3fd98..f935c0f 100644 --- a/packages/v8-android-tools-macos/package.json +++ b/packages/v8-android-tools-macos/package.json @@ -1,6 +1,6 @@ { "name": "v8-android-tools-macos", - "version": "11.1000.3", + "version": "11.1000.4", "description": "Tools for v8-android", "repository": { "type": "git", diff --git a/packages/v8-android/package.json b/packages/v8-android/package.json index dcf0bb8..d63e93a 100644 --- a/packages/v8-android/package.json +++ b/packages/v8-android/package.json @@ -1,6 +1,6 @@ { "name": "v8-android", - "version": "11.1000.3", + "version": "11.1000.4", "description": "Pre-build version of V8 to be used by React Native apps", "repository": { "type": "git", From 25a552d311ef91b53a585ea9f2653002a3eabbca Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 20 Aug 2023 00:53:14 +0800 Subject: [PATCH 13/14] Build by NDK r23c --- README.md | 2 +- patches/v8_97_android_unwind_link_error.patch | 47 ------------------- patches/v8_android_unwind_link_error.patch | 26 ++++++++++ scripts/env.sh | 2 +- scripts/patch.sh | 6 +-- 5 files changed, 31 insertions(+), 52 deletions(-) delete mode 100644 patches/v8_97_android_unwind_link_error.patch create mode 100644 patches/v8_android_unwind_link_error.patch diff --git a/README.md b/README.md index 3e83108..6317b41 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To integrate with React Native, please check [react-native-v8](https://github.co 1. Single libv8android.so (or libv8.so on iOS) file. 2. Support i18n and JavaScript [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl). 3. V8 Lite mode (JIT-less mode) https://v8.dev/blog/v8-lite -4. Build by Android official NDK r21e which prevent potential ABI incompatible issue to integrate with React Native. +4. Build by Android official NDK r23e which prevent potential ABI incompatible issue to integrate with React Native. ## Build Guides diff --git a/patches/v8_97_android_unwind_link_error.patch b/patches/v8_97_android_unwind_link_error.patch deleted file mode 100644 index ab38e6c..0000000 --- a/patches/v8_97_android_unwind_link_error.patch +++ /dev/null @@ -1,47 +0,0 @@ -diff --git a/build/config/android/BUILD.gn b/build/config/android/BUILD.gn -index 4fc5565e2..c48c53536 100644 ---- a/build/config/android/BUILD.gn -+++ b/build/config/android/BUILD.gn -@@ -41,12 +41,18 @@ config("compiler") { - } - - ldflags = [ -+ # Don't allow visible symbols from libgcc or libc++ to be -+ # re-exported. -+ "-Wl,--exclude-libs=libgcc.a", -+ - # Don't allow visible symbols from libraries that contain - # assembly code with symbols that aren't hidden properly. - # http://crbug.com/448386 - "-Wl,--exclude-libs=libvpx_assembly_arm.a", - ] - -+ # TODO(crbug.com/1184398): Move to compiler-rt when we are ready. -+ ldflags += [ "--rtlib=libgcc" ] - if (current_cpu == "arm64") { - if (arm_control_flow_integrity == "standard") { - cflags += [ "-mbranch-protection=standard" ] -@@ -55,10 +61,6 @@ config("compiler") { - } - } - -- # Instead of using an unwind lib from the toolchain, -- # buildtools/third_party/libunwind will be built and used directly. -- ldflags += [ "--unwindlib=none" ] -- - # $compile_api_level corresponds to the API level used for the sysroot path - # calculation in //build/config/android/config.gni - if (android_64bit_target_cpu) { -@@ -80,8 +82,11 @@ config("compiler") { - # that is Android-only. Please see that target for advice on what should go in - # :runtime_library vs. :compiler. - config("runtime_library") { -+ # Let the linker find libgcc.a. -+ ldflags = [ "--gcc-toolchain=" + -+ rebase_path(android_toolchain_root, root_build_dir) ] -+ - libs = [] -- ldflags = [] - - # On 64-bit platforms, the only symbols provided by libandroid_support.a are - # strto{d,f,l,ul}_l. These symbols are not used by our libc++, and newer NDKs diff --git a/patches/v8_android_unwind_link_error.patch b/patches/v8_android_unwind_link_error.patch new file mode 100644 index 0000000..141884a --- /dev/null +++ b/patches/v8_android_unwind_link_error.patch @@ -0,0 +1,26 @@ +diff --git a/build/config/android/BUILD.gn b/build/config/android/BUILD.gn +index 63b37e0c1..10fdb3cbf 100644 +--- a/build/config/android/BUILD.gn ++++ b/build/config/android/BUILD.gn +@@ -57,9 +57,18 @@ config("compiler") { + } + } + +- # Instead of using an unwind lib from the toolchain, +- # buildtools/third_party/libunwind will be built and used directly. +- ldflags += [ "--unwindlib=none" ] ++ if (current_cpu == "x86") { ++ arch_dir = "i386" ++ } else if (current_cpu == "x64") { ++ arch_dir = "x86_64" ++ } else if (current_cpu == "arm") { ++ arch_dir = "arm" ++ } else if (current_cpu == "arm64") { ++ arch_dir = "aarch64" ++ } else { ++ assert(false, "Unknown Android ABI: " + current_cpu) ++ } ++ lib_dirs = [ "$android_ndk_library_path/clang/12.0.9/lib/linux/$arch_dir"] + + # $compile_api_level corresponds to the API level used for the sysroot path + # calculation in //build/config/android/config.gni diff --git a/scripts/env.sh b/scripts/env.sh index 319ee20..4154a0e 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -42,7 +42,7 @@ V8_DIR="${ROOT_DIR}/v8" DIST_DIR="${ROOT_DIR}/dist" PATCHES_DIR="${ROOT_DIR}/patches" -NDK_VERSION="r21e" +NDK_VERSION="r23c" IOS_DEPLOYMENT_TARGET="12.0" export PATH="$DEPOT_TOOLS_DIR:$PATH" diff --git a/scripts/patch.sh b/scripts/patch.sh index b8ad0f5..f2f3355 100755 --- a/scripts/patch.sh +++ b/scripts/patch.sh @@ -18,9 +18,9 @@ V8_PATCHSET_ANDROID=( # Fix v8 9.7 build error "v8_97_android_build_error.patch" - # Fix v8 9.7 libunwind link error - # revert https://chromium.googlesource.com/chromium/src/build/+/7bb5f36104 - "v8_97_android_unwind_link_error.patch" + # Fix v8 libunwind link error + # link the libunwind from official ndk rather than the chromium's builtin toolchain + "v8_android_unwind_link_error.patch" # Add mkcodecache tool "mkcodecache.patch" From 3ef2cf76c0f078c3da32f61dbebeb76322558bf4 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 20 Aug 2023 01:07:24 +0800 Subject: [PATCH 14/14] Build by NDK r23c --- scripts/setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 1238f3c..211cb8e 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -20,9 +20,9 @@ function installNDK() { local host_arch=$1 pushd . cd "${V8_DIR}" - wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip - unzip -q android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip - rm -f android-ndk-${NDK_VERSION}-${host_arch}-x86_64.zip + wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-${host_arch}.zip + unzip -q android-ndk-${NDK_VERSION}-${host_arch}.zip + rm -f android-ndk-${NDK_VERSION}-${host_arch}.zip popd }