Commit 48705d75 authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

Modules: Use partitions in non-component debug builds

LLD partition generation has been patched to work properly in Debug
builds, so that configuration can be re-enabled.

Ride-along tweaks:

- Rename variable use_native_modules to use_native_partitions

- Remove redundant allow_partitions template argument, which can be inferred
  from whether module descriptors are supplied.

Bug: None
Change-Id: Ib885f75bb00358b3e61b450187db2020b1f32a9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844076Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703474}
parent a12d6f39
......@@ -1190,7 +1190,6 @@ chrome_common_shared_library("libchrome") {
deps += [ "//chrome/browser/android/vr:module_factory" ]
}
allow_partitions = true
module_descs = chrome_modern_module_descs
}
......@@ -1460,7 +1459,6 @@ template("libmonochrome_apk_or_bundle_tmpl") {
}
is_monochrome = true
allow_partitions = true
module_descs = monochrome_module_descs
}
}
......
......@@ -22,12 +22,8 @@ apk_pak_asset_type = "_apk"
# is_monochrome: Optional. If set, the library is for use in monochrome.
# is_webview: If true, the library is for webview, and browser-specific
# config is skipped.
# allow_partitions: If true, and the build config supports it, the library
# is linked as a partitioned library, and separate feature libs are
# generated if specified. Those libraries may later be packaged into
# dynamic feature modules or APKs.
# module_descs: Optional. Descriptors of modules for which to extract
# partitions. Can only be set if |allow_partitions| is true. See
# module_descs: Optional. Descriptors of feature modules from which deps
# should be included, and if enabled, partition libraries created. See
# //chrome/android/modules/chrome_feature_modules.gni for the descriptor
# format.
template("chrome_common_shared_library") {
......@@ -39,16 +35,10 @@ template("chrome_common_shared_library") {
_linker_script_target = "${target_name}_linker_script"
# Create a partitioned libraries if the build config supports it, and the
# invoker wants partitions.
_allow_partitions =
defined(invoker.allow_partitions) && invoker.allow_partitions
_generate_partitions = _allow_partitions && use_native_modules
if (_generate_partitions) {
assert(defined(invoker.module_descs))
} else {
if (defined(invoker.module_descs)) {
not_needed(invoker, [ "module_descs" ])
}
# invoker has supplied module descriptors.
_generate_partitions = defined(invoker.module_descs) && use_native_partitions
if (defined(invoker.module_descs)) {
not_needed(invoker, [ "module_descs" ])
}
# Create a custom linker script based on JNI and feature module requirements.
......@@ -107,7 +97,7 @@ template("chrome_common_shared_library") {
}
}
if (_allow_partitions) {
if (defined(invoker.module_descs)) {
partitions = []
foreach(_module_desc, invoker.module_descs) {
if (defined(_module_desc.native_deps)) {
......
......@@ -12,7 +12,7 @@ vr_module_desc = {
java_deps = [ "//chrome/android/features/vr:java" ]
android_manifest = "//chrome/android/features/vr/java/AndroidManifest.xml"
proguard_async = async_vr
if (use_native_modules && modularize_vr_native) {
if (use_native_partitions) {
native_deps = [ "//chrome/browser/vr:vr_ui" ]
native_entrypoints = "//chrome/browser/vr/module_exports.lst"
}
......
......@@ -6,13 +6,6 @@ import("//build/config/android/config.gni")
import("//build/config/compiler/compiler.gni")
import("//device/vr/buildflags/buildflags.gni")
# This variable indicates whether the native feature module system is engaged.
# Currently, this implies a build configuration that supports native modules,
# and that at least one feature is using a native module.
# TODO(https://crbug.com/1004329): Partitioning should work with is_debug. When
# this bug is fixed, remove that condition here.
if (is_android && is_clang && use_lld && !is_component_build && !is_debug) {
use_native_modules = enable_vr && modularize_vr_native
} else {
use_native_modules = false
}
# If true, lld is used to partition feature code into separate libraries, which
# in turn are included in Dynamic Feature Modules.
use_native_partitions = is_android && is_clang && use_lld && !is_component_build
......@@ -65,7 +65,7 @@ template("chrome_feature_module") {
_loadable_modules_64_bit += _module_desc.loadable_modules_64_bit
}
if (use_native_modules && defined(_module_desc.native_deps) &&
if (use_native_partitions && defined(_module_desc.native_deps) &&
_module_desc.native_deps != []) {
_arch = ""
_toolchain = ""
......
......@@ -36,7 +36,7 @@ component("test_dummy") {
]
# Test dummy native entrypoints belong in the partition.
if (use_native_modules) {
if (use_native_partitions) {
cflags = [ "-fsymbol-partition=libtest_dummy.so" ]
}
}
......
......@@ -188,7 +188,7 @@ source_set("ui_module_factory") {
# dependency on chrome/browser precludes the use of an intermediate target (eg.
# vr_android_with_factory).
group("module_factory") {
if (use_native_modules && modularize_vr_native) {
if (use_native_partitions) {
deps = [
":ui_module_factory",
]
......
......@@ -194,7 +194,7 @@ component("vr_ui") {
"//skia",
]
if (use_native_modules && modularize_vr_native) {
if (use_native_partitions) {
# Mark symbols in this library as belonging to the VR partition. Only
# exported symbols (module entrypoints) are affected.
cflags = [ "-fsymbol-partition=libvr.so" ]
......
......@@ -88,7 +88,7 @@ source_set("native") {
# The method used to load and register JNI for native libraries depends
# heavily on build type.
if (use_native_modules) {
if (use_native_partitions) {
defines = [ "LOAD_FROM_PARTITIONS" ]
} else if (is_component_build) {
defines = [ "LOAD_FROM_COMPONENTS" ]
......
......@@ -79,8 +79,8 @@ void LoadLibrary(JNIEnv* env, const std::string& library_name) {
<< dlerror();
registration_function = reinterpret_cast<JniRegistrationFunction*>(symbol);
#else // defined(LOAD_FROM_PARTITIONS) || defined(LOAD_FROM_COMPONENTS)
// TODO(https://crbug.com/870055): Similar to the declarations above, this map
// could be auto-generated.
// 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);
......
......@@ -48,9 +48,6 @@ declare_args() {
enable_arcore = enable_vr && is_android && !is_chromecast &&
(current_cpu == "arm" || current_cpu == "arm64")
# When true, portions of VR's native code are included in the VR DFM.
modularize_vr_native = true
# Whether to create AR module as an asynchronous DFM.
async_ar = false
......
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