From 5ba6d53760a7309ae7b9d802b7a5ef3e0879f306 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Thu, 7 Nov 2019 08:44:06 +0800 Subject: [PATCH] Rename libv8.so to libv8android.so Summary: On some Android device, there is libv8.so in system ROM. E.g. /system/lib/libv8.so or /vendor/lib/libv8.so On old Android, dlopen() with RTLD_GLOBAL is not handled well and it's by default RTLD_LOCAL. Even we call System.loadLibrary("v8") before, during the time RNV8 call System.loadLibrary("v8executor") and search libv8.so in DT_NEEDED. It seems bionic linker will use system libv8.so instead of ours. Since our libv8.so is customized with libplatform.so, this leads to unresolved symbol as https://github.com/Kudo/react-native-v8/issues/29. That's why I am proposing to rename libv8.so as libv8android.so and to prevent name conflict from system libv8.so. Reference for RTLD_GLOBAL: https://github.com/android/ndk/issues/201 --- patches/v8_shared_library.patch | 4 ++-- scripts/build.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/v8_shared_library.patch b/patches/v8_shared_library.patch index e8ab6f1..c5d758f 100644 --- a/patches/v8_shared_library.patch +++ b/patches/v8_shared_library.patch @@ -58,8 +58,8 @@ index c486f1a..6aeb762 100644 @@ -3813,6 +3805,23 @@ v8_static_library("wee8") { ] } - -+v8_loadable_module("libv8") { + ++v8_loadable_module("libv8android") { + defines = [ "BUILDING_V8_SHARED" ] + + sources = [ diff --git a/scripts/build.sh b/scripts/build.sh index 48e4949..afe4e8a 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -72,12 +72,12 @@ function build_arch() if [[ ${MKSNAPSHOT_ONLY} -eq "1" ]]; then date ; ninja ${NINJA_PARAMS} -C out.v8.$arch run_mksnapshot_default ; date else - date ; ninja ${NINJA_PARAMS} -C out.v8.$arch libv8 ; date + date ; ninja ${NINJA_PARAMS} -C out.v8.$arch libv8android ; date mkdir -p $BUILD_DIR/lib/$arch_for_android - cp -f out.v8.$arch/libv8.so $BUILD_DIR/lib/$arch_for_android/libv8.so + cp -f out.v8.$arch/libv8android.so $BUILD_DIR/lib/$arch_for_android/libv8android.so mkdir -p $BUILD_DIR/lib.unstripped/$arch_for_android - cp -f out.v8.$arch/lib.unstripped/libv8.so $BUILD_DIR/lib.unstripped/$arch_for_android/libv8.so + cp -f out.v8.$arch/lib.unstripped/libv8android.so $BUILD_DIR/lib.unstripped/$arch_for_android/libv8android.so fi mkdir -p $BUILD_DIR/tools/$arch_for_android