Skip to content

Commit 5a78dd5

Browse files
committed
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 #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: android/ndk#201
1 parent 9d0951e commit 5a78dd5

File tree

8 files changed

+13
-15
lines changed

8 files changed

+13
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ yarn add 'react-native-v8@>=0.60.0-patch.0 <0.60.1'
4343
dependencies {
4444
implementation fileTree(dir: "libs", include: ["*.jar"])
4545
implementation "com.facebook.react:react-native:+" // From node_modules
46-
+ // Add v8-android - prebuilt libv8.so into APK
46+
+ // Add v8-android - prebuilt libv8android.so into APK
4747
+ implementation 'org.chromium:v8-android:+'
4848

4949
// JSC from node_modules
@@ -60,7 +60,7 @@ yarn add 'react-native-v8@>=0.60.0-patch.0 <0.60.1'
6060
+ url("$rootDir/../node_modules/react-native-v8/dist")
6161
+ }
6262
+ maven {
63-
+ // prebuilt libv8.so
63+
+ // prebuilt libv8android.so
6464
+ url("$rootDir/../node_modules/v8-android/dist")
6565
}
6666
maven {
@@ -109,7 +109,7 @@ $ yarn add v8-android-nointl
109109
@@ -29,7 +29,7 @@ allprojects {
110110
}
111111
maven {
112-
// prebuilt libv8.so
112+
// prebuilt libv8android.so
113113
- url("$rootDir/../node_modules/v8-android/dist")
114114
+ url("$rootDir/../node_modules/v8-android-nointl/dist")
115115
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"RN_VERSION": "v0.61.4"
2929
},
3030
"dependencies": {
31-
"v8-android": "^7.8.0"
31+
"v8-android": "7.8.x >= 7.8.1"
3232
},
3333
"peerDependencies": {
3434
"react-native": "^0.61.0"

src/androidexecutor/reactexecutor/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(REACT_NATIVE
1717
LOCAL_CPP_FEATURES := exceptions
1818

1919
LOCAL_STATIC_LIBRARIES := libjsireact libjsi v8runtime
20-
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libv8
20+
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libv8android
2121

2222
include $(BUILD_SHARED_LIBRARY)

src/androidexecutor/reactexecutor/V8Executor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
public class V8Executor extends JavaScriptExecutor {
1515
static {
16-
// libv8 must be loaded explicitly to invoke its JNI_OnLoad.
17-
SoLoader.loadLibrary("v8");
1816
SoLoader.loadLibrary("v8executor");
1917
}
2018

src/patches/build_with_v8.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ index 3a155af..587c95d 100644
4040
into("$buildDir/react-ndk/exported")
4141
exclude("**/libjsc.so")
4242
exclude("**/libhermes.so")
43-
+ exclude("**/libv8.so")
43+
+ exclude("**/libv8android.so")
4444
}
4545

4646
task packageReactNdkLibsForBuck(dependsOn: packageReactNdkLibs, type: Copy) {

src/sowrapper/Android.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
LOCAL_PATH:= $(call my-dir)
22
include $(CLEAR_VARS)
3-
LOCAL_MODULE:= v8
4-
LOCAL_SRC_FILES := jni/$(TARGET_ARCH_ABI)/libv8.so
3+
LOCAL_MODULE:= v8android
4+
LOCAL_SRC_FILES := jni/$(TARGET_ARCH_ABI)/libv8android.so
55
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
66
include $(PREBUILT_SHARED_LIBRARY)

src/v8runtime/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ ifeq ($(APP_OPTIM),release)
1919
LOCAL_CFLAGS += -O3
2020
endif
2121

22-
LOCAL_SHARED_LIBRARIES := libfolly_json libv8 glog
22+
LOCAL_SHARED_LIBRARIES := libfolly_json libv8android glog
2323

2424
include $(BUILD_STATIC_LIBRARY)

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# yarn lockfile v1
33

44

5-
v8-android@^7.8.0:
6-
version "7.8.0"
7-
resolved "https://registry.yarnpkg.com/v8-android/-/v8-android-7.8.0.tgz#5c95722fe78a8b488563f18a0dab238495cf56ac"
8-
integrity sha512-nBzlNYoCgptxaKlJ7O6miQsF+ctY33Tk+HmqxFDVy29LqEm7Tf13r0al71TYrh1TOu9mHZAEJJTpjdpyN4o0bw==
5+
"[email protected].x >= 7.8.1":
6+
version "7.8.1"
7+
resolved "https://registry.yarnpkg.com/v8-android/-/v8-android-7.8.1.tgz#2686c3fe655742bbd02e1b6d1c3e336365d4e8e0"
8+
integrity sha512-fxqBNITrILwfzQI9ZIWHR44B6Hvhplfht+V9dpcTrm7CGZjWpUaD/n3C0ghCW15VLRYhWPuCVltXHwbvsBOLjw==

0 commit comments

Comments
 (0)