Commit 2c37032b authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

Modules: Remove fallback path for non-component debug case.

For a period of time, LLD couldn't produce partitions in debug builds,
and hence a workaround was needed for the debug non-component case. The
same workaround would kick in if partitioning were disabled on release
builds (ie. a kill switch).

Now, LLD is fixed and partitions have soaked long enough to drop the
kill switch.

Bug: 1011834
Change-Id: I00bdb911c61a7e7e7cd7359daa996074494b8b3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873910Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709047}
parent 283cc917
...@@ -87,13 +87,9 @@ source_set("native") { ...@@ -87,13 +87,9 @@ source_set("native") {
] ]
# The method used to load and register JNI for native libraries depends # The method used to load and register JNI for native libraries depends
# heavily on build type. # on build type.
if (use_native_partitions) { if (use_native_partitions) {
defines = [ "LOAD_FROM_PARTITIONS" ] defines = [ "LOAD_FROM_PARTITIONS" ]
} else if (is_component_build) {
defines = [ "LOAD_FROM_COMPONENTS" ]
} else {
defines = [ "LOAD_FROM_BASE_LIBRARY" ]
} }
} }
......
...@@ -16,19 +16,6 @@ ...@@ -16,19 +16,6 @@
using base::android::BundleUtils; using base::android::BundleUtils;
#if defined(LOAD_FROM_BASE_LIBRARY)
extern "C" {
// These methods are forward-declared here for the build case where
// partitioned libraries are disabled, and module code is pulled into the main
// library. In that case, there is no current way of dlsym()'ing for this
// JNI registration method, and hence it's referred to directly.
// This list could be auto-generated in the future.
extern bool JNI_OnLoad_test_dummy(JNIEnv* env) __attribute__((weak_import));
} // extern "C"
#endif // LOAD_FROM_BASE_LIBRARY
namespace module_installer { namespace module_installer {
// Allows memory mapping module PAK files on the main thread. // Allows memory mapping module PAK files on the main thread.
...@@ -56,7 +43,6 @@ typedef bool JniRegistrationFunction(JNIEnv* env); ...@@ -56,7 +43,6 @@ typedef bool JniRegistrationFunction(JNIEnv* env);
void LoadLibrary(JNIEnv* env, const std::string& library_name) { void LoadLibrary(JNIEnv* env, const std::string& library_name) {
JniRegistrationFunction* registration_function = nullptr; JniRegistrationFunction* registration_function = nullptr;
#if defined(LOAD_FROM_PARTITIONS) || defined(LOAD_FROM_COMPONENTS)
#if defined(LOAD_FROM_PARTITIONS) #if defined(LOAD_FROM_PARTITIONS)
// The partition library must be opened via native code (using // The partition library must be opened via native code (using
// android_dlopen_ext() under the hood). There is no need to repeat the // android_dlopen_ext() under the hood). There is no need to repeat the
...@@ -65,10 +51,12 @@ void LoadLibrary(JNIEnv* env, const std::string& library_name) { ...@@ -65,10 +51,12 @@ void LoadLibrary(JNIEnv* env, const std::string& library_name) {
// library, for lazy JNI registration). // library, for lazy JNI registration).
void* library_handle = void* library_handle =
BundleUtils::DlOpenModuleLibraryPartition(library_name); BundleUtils::DlOpenModuleLibraryPartition(library_name);
#else // defined(LOAD_FROM_PARTITIONS) #elif defined(COMPONENT_BUILD)
const std::string lib_name = "lib" + library_name + ".cr.so"; const std::string lib_name = "lib" + library_name + ".cr.so";
void* library_handle = dlopen(lib_name.c_str(), RTLD_LOCAL); void* library_handle = dlopen(lib_name.c_str(), RTLD_LOCAL);
#endif // defined(LOAD_FROM_PARTITIONS) #else
#error "Unsupported configuration."
#endif // defined(COMPONENT_BUILD)
CHECK(library_handle != nullptr) CHECK(library_handle != nullptr)
<< "Could not open feature library:" << dlerror(); << "Could not open feature library:" << dlerror();
...@@ -78,14 +66,6 @@ void LoadLibrary(JNIEnv* env, const std::string& library_name) { ...@@ -78,14 +66,6 @@ void LoadLibrary(JNIEnv* env, const std::string& library_name) {
CHECK(symbol != nullptr) << "Could not find JNI registration method: " CHECK(symbol != nullptr) << "Could not find JNI registration method: "
<< dlerror(); << dlerror();
registration_function = reinterpret_cast<JniRegistrationFunction*>(symbol); registration_function = reinterpret_cast<JniRegistrationFunction*>(symbol);
#else // defined(LOAD_FROM_PARTITIONS) || defined(LOAD_FROM_COMPONENTS)
// TODO(https://crbug.com/1011834): Remove this code path (and anything
// associated with it) once there's confidence partitions will stay enabled.
const std::map<std::string, JniRegistrationFunction*> modules = {
{"test_dummy", JNI_OnLoad_test_dummy}};
registration_function = modules.at(library_name);
#endif // defined(LOAD_FROM_PARTITIONS) || defined(LOAD_FROM_COMPONENTS)
CHECK(registration_function(env)) CHECK(registration_function(env))
<< "JNI registration failed: " << library_name; << "JNI registration failed: " << library_name;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment