Merge "Revert^2 "Switch platform-NDK unwinder to LLVM libunwind.a prebuilt""
diff --git a/Changes.md b/Changes.md
index 0a6adc4..1ab005f 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,5 +1,49 @@
# Build System Changes for Android.mk Writers
+## Dexpreopt starts enforcing `<uses-library>` checks (for Java modules)
+
+In order to construct correct class loader context for dexpreopt, build system
+needs to know about the shared library dependencies of Java modules listed in
+the `<uses-library>` tags in the manifest. Since the build system does not have
+access to the manifest contents, that information must be present in the build
+files. In simple cases Soong is able to infer it from its knowledge of Java SDK
+libraries and the `libs` property in Android.bp, but in more complex cases it is
+necessary to add the missing information in Android.bp/Android.mk manually.
+
+To specify a list of libraries for a given modules, use:
+
+* Android.bp properties: `uses_libs`, `optional_uses_libs`
+* Android.mk variables: `LOCAL_USES_LIBRARIES`, `LOCAL_OPTIONAL_USES_LIBRARIES`
+
+If a library is in `libs`, it usually should *not* be added to the above
+properties, and Soong should be able to infer the `<uses-library>` tag. But
+sometimes a library also needs additional information in its
+Android.bp/Android.mk file (e.g. when it is a `java_library` rather than a
+`java_sdk_library`, or when the library name is different from its module name,
+or when the module is defined in Android.mk rather than Android.bp). In such
+cases it is possible to tell the build system that the library provides a
+`<uses-library>` with a given name (however, this is discouraged and will be
+deprecated in the future, and it is recommended to fix the underlying problem):
+
+* Android.bp property: `provides_uses_lib`
+* Android.mk variable: `LOCAL_PROVIDES_USES_LIBRARY`
+
+It is possible to disable the check on a per-module basis. When doing that it is
+also recommended to disable dexpreopt, as disabling a failed check will result
+in incorrect class loader context recorded in the .odex file, which will cause
+class loader context mismatch and dexopt at first boot.
+
+* Android.bp property: `enforce_uses_lib`
+* Android.mk variable: `LOCAL_ENFORCE_USES_LIBRARIES`
+
+Finally, it is possible to globally disable the check:
+
+* For a given product: `PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true`
+* On the command line: `RELAX_USES_LIBRARY_CHECK=true`
+
+The environment variable overrides the product variable, so it is possible to
+disable the check for a product, but quickly re-enable it for a local build.
+
## `LOCAL_REQUIRED_MODULES` requires listed modules to exist {#BUILD_BROKEN_MISSING_REQUIRED_MODULES}
Modules listed in `LOCAL_REQUIRED_MODULES`, `LOCAL_HOST_REQUIRED_MODULES` and
diff --git a/core/main.mk b/core/main.mk
index 56950ec..3362681 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1573,6 +1573,8 @@
$(INSTALLED_SUPERIMAGE_EMPTY_TARGET) \
$(INSTALLED_PRODUCTIMAGE_TARGET) \
$(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
+ $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
+ $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
$(INSTALLED_FILES_FILE) \
$(INSTALLED_FILES_JSON) \
$(INSTALLED_FILES_FILE_VENDOR) \
@@ -1750,14 +1752,12 @@
$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK) \
$(INSTALLED_DEBUG_RAMDISK_TARGET) \
$(INSTALLED_DEBUG_BOOTIMAGE_TARGET) \
+ $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
+ $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) \
$(INSTALLED_VENDOR_RAMDISK_TARGET) \
$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) \
)
- $(call dist-for-goals, bootimage_test_harness, \
- $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
- $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
- )
endif
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
diff --git a/tools/rbcrun/Android.bp b/tools/rbcrun/Android.bp
index b5f7155..90173ac 100644
--- a/tools/rbcrun/Android.bp
+++ b/tools/rbcrun/Android.bp
@@ -13,6 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
blueprint_go_binary {
name: "rbcrun",
srcs: ["cmd/rbcrun.go"],
diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp
index 3b0c070..65c035e 100644
--- a/tools/releasetools/Android.bp
+++ b/tools/releasetools/Android.bp
@@ -133,6 +133,7 @@
required: [
"brillo_update_payload",
"checkvintf",
+ "minigzip",
"lz4",
"toybox",
"unpack_bootimg",
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 414ab97..c550490 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -651,6 +651,9 @@
raise KeyError(fn)
return file
+class RamdiskFormat(object):
+ LZ4 = 1
+ GZ = 2
def LoadInfoDict(input_file, repacking=False):
"""Loads the key/value pairs from the given input target_files.
@@ -753,13 +756,17 @@
# Load recovery fstab if applicable.
d["fstab"] = _FindAndLoadRecoveryFstab(d, input_file, read_helper)
+ if d.get('lz4_ramdisks') == 'true':
+ ramdisk_format = RamdiskFormat.LZ4
+ else:
+ ramdisk_format = RamdiskFormat.GZ
# Tries to load the build props for all partitions with care_map, including
# system and vendor.
for partition in PARTITIONS_WITH_BUILD_PROP:
partition_prop = "{}.build.prop".format(partition)
d[partition_prop] = PartitionBuildProps.FromInputFile(
- input_file, partition)
+ input_file, partition, ramdisk_format=ramdisk_format)
d["build.prop"] = d["system.build.prop"]
# Set up the salt (based on fingerprint) that will be used when adding AVB
@@ -818,6 +825,9 @@
placeholder_values: A dict of runtime variables' values to replace the
placeholders in the build.prop file. We expect exactly one value for
each of the variables.
+ ramdisk_format: If name is "boot", the format of ramdisk inside the
+ boot image. Otherwise, its value is ignored.
+ Use lz4 to decompress by default. If its value is gzip, use minigzip.
"""
def __init__(self, input_file, name, placeholder_values=None):
@@ -840,11 +850,11 @@
return props
@staticmethod
- def FromInputFile(input_file, name, placeholder_values=None):
+ def FromInputFile(input_file, name, placeholder_values=None, ramdisk_format=RamdiskFormat.LZ4):
"""Loads the build.prop file and builds the attributes."""
if name == "boot":
- data = PartitionBuildProps._ReadBootPropFile(input_file)
+ data = PartitionBuildProps._ReadBootPropFile(input_file, ramdisk_format=ramdisk_format)
else:
data = PartitionBuildProps._ReadPartitionPropFile(input_file, name)
@@ -853,7 +863,7 @@
return props
@staticmethod
- def _ReadBootPropFile(input_file):
+ def _ReadBootPropFile(input_file, ramdisk_format):
"""
Read build.prop for boot image from input_file.
Return empty string if not found.
@@ -863,7 +873,7 @@
except KeyError:
logger.warning('Failed to read IMAGES/boot.img')
return ''
- prop_file = GetBootImageBuildProp(boot_img)
+ prop_file = GetBootImageBuildProp(boot_img, ramdisk_format=ramdisk_format)
if prop_file is None:
return ''
with open(prop_file, "r") as f:
@@ -3661,12 +3671,12 @@
append('move %s %s' % (p, u.tgt_group))
-def GetBootImageBuildProp(boot_img):
+def GetBootImageBuildProp(boot_img, ramdisk_format=RamdiskFormat.LZ4):
"""
Get build.prop from ramdisk within the boot image
Args:
- boot_img: the boot image file. Ramdisk must be compressed with lz4 format.
+ boot_img: the boot image file. Ramdisk must be compressed with lz4 or minigzip format.
Return:
An extracted file that stores properties in the boot image.
@@ -3679,7 +3689,16 @@
logger.warning('Unable to get boot image timestamp: no ramdisk in boot')
return None
uncompressed_ramdisk = os.path.join(tmp_dir, 'uncompressed_ramdisk')
- RunAndCheckOutput(['lz4', '-d', ramdisk, uncompressed_ramdisk])
+ if ramdisk_format == RamdiskFormat.LZ4:
+ RunAndCheckOutput(['lz4', '-d', ramdisk, uncompressed_ramdisk])
+ elif ramdisk_format == RamdiskFormat.GZ:
+ with open(ramdisk, 'rb') as input_stream:
+ with open(uncompressed_ramdisk, 'wb') as output_stream:
+ p2 = Run(['minigzip', '-d'], stdin=input_stream.fileno(), stdout=output_stream.fileno())
+ p2.wait()
+ else:
+ logger.error('Only support lz4 or minigzip ramdisk format.')
+ return None
abs_uncompressed_ramdisk = os.path.abspath(uncompressed_ramdisk)
extracted_ramdisk = MakeTempDir('extracted_ramdisk')