summaryrefslogtreecommitdiff
path: root/dexpreopt/config.go
AgeCommit message (Collapse)Author
2025-03-18Generic configuration for generic system modules. Justin Yun
Config object includes a copy of itself for the generic configuration. The generic configuration replaces any product-specific configurations with the generic information. When a module context gets Config() object, it returns the generic configuration if the module sets use_generic_config to true. Otherwise, Config() returns the original config object as before. By adding `generic:"<value>"` annotation to the product variable, the variables will be initialized with the <value> for the generic configs. If the <value> is "unset", the variable will be unset. The generic modules can be included in the shared system image to be installed in multiple targets. Bug: 361816274 Test: m nothing --no-skip-soong-tests Change-Id: I15e4ade17ad1a8969f8e0e91d994b60545dc412f
2025-03-13Change CommonModuleInfoProvider to a pointer. Yu Liu
Bug: 358427516 Test: Manually verified genereated ninja and mk files, unit tests. Change-Id: I53a6dd718232735decbeb93febfd269dd9449e86
2025-03-07Rename CommonModuleInfoKey to be consistent with others. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I1ce8bc782666586633ded9cfaf1b9590e3c0efde
2025-03-03Dist kernel_version.txt in soong-only builds Cole Faust
This ports some of the kernel version/config extraction code from make, and updates our handling of kernel_version_for_uffd_gc.txt as well. There are a number of differences in the implementation vs how make implements it. See comments in the source code for more information. Bug: 398023642 Test: m dist, see kernel_version.txt Change-Id: I53c9ef12912683585e45da04a44890fff1381398
2025-02-26Make EqualModules a free function. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I7e00f09a15f2857f58bea70bcedc4798630a40bc
2025-01-15Convert dex2oatPathFromDep to use ModuleProxy. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I99ffe88179991da8e5963605bf76666c8945d290
2024-12-20Soong generates kernel_version_for_uffd_gc.txt mrziwang
In the context of support "--soong-only", kernel_version_for_uffd_gc.txt needs to be generated by Soong. Soong will write the BOARD_KERNEL_VERSION to the txt file in soong-only mode. It will panic if BOARD_KERNEL_VERSION is not set. Test: CI Bug: 383564057 Change-Id: Idb264eaa91424ed9bab5be4988c7eb96334153f5
2024-11-13Use VisitAllModuleVariantProxies in generateModuleTarget. Yu Liu
Also rename android.CommonPropertiesProvider to android.CommonModuleInfo. Bug: 377723687 Test: Compare the ninja and mk files generated. Change-Id: Iea46c16234204eef808b590b5cc1b43b5a874636
2024-10-10Add a few module visiting methods that return ModuleProxy. Yu Liu
Change a few places to use these new methods when visiting dependencies. Bug: 358427516 Test: Manual verified the generated mk and ninja files. Change-Id: I7426843d76d79d41eb60fce5e796c14f968a0f1d
2024-10-04Install dexpreopt artifacts of apex system server jars in same partition Spandan Das
e.g. If a system server jar providing apex is installed in /system_ext, the dexpreopt files of that jar will also be installed in /system_ext. Currently, all of these artifacts are installed in /system This behavior will be flag guarded by RELEASE_INSTALL_APEX_SYSTEMSERVER_DEXPREOPT_SAME_PARTITION. This is necessary because the ART runtime needs to be updated to look in the new /system_ext location. Since some release configs build with ART prebuilts, the runtime in those prebuilt apexes will not have the additional search path introduced in https://r.android.com/3287191 Test: Verified that "Could not check odex file" does not appear for service-compos (a system_ext apex systemserver jar) Bug: 369678122 Change-Id: I752bdc7f5f69226b503800ce25726a211302cb07
2024-02-02Determine GC type based on BUILT_KERNEL_VERSION_FILE. Jiakai Zhang
How it works: 1. build/make/core/Makefile generates a txt file with the kernel version, which is taken from an explicit BOARD_KERNEL_VERSION value, or extracted from the kernel image on the source tree, or extracted from the kernel image extracted from the prebuilt boot.img. The file is saved at $ANDROID_PRODUCT_OUT/obj/PACKAGING/check_vintf_all_intermediates/kernel_version.txt. 2. If PRODUCT_ENABLE_UFFD_GC is "default", meaning the GC type needs to be determined by the kernel version, build/make/core/Makefile copies kernel_version.txt to out/soong/dexpreopt/kernel_version_for_uffd_gc.txt. 3. build/soong/dexpreopt/config.go writes the the UFFD GC flag to out/soong/dexpreopt/uffd_gc_flag.txt. The flag is determined by an explicit PRODUCT_ENABLE_UFFD_GC value or by contruct_uffd_gc_flag.py, which reads kernel_version_for_uffd_gc.txt and determines the flag accordingly. 4. dex2oat takes the UFFD GC flag from uffd_gc_flag.txt. 5. post_process_props.py mangles ro.dalvik.vm.enable_uffd_gc based on the same logic. Bug: 321751629 Bug: 319554951 Bug: 318763448 Bug: 319648491 Test: m --no-skip-soong-tests nothing Test: atest uffd_gc_utils_test Test: Build with `OVERRIDE_ENABLE_UFFD_GC=default m` for device with no UFFD support - 1. Check the existence of `-Xgc:CMC` in out/soong/dexpreopt_arm64/dex_bootjars/android/system/framework/arm64/boot.invocation (dex2oat invocation for a boot image) 2. Check the existence of `-Xgc:CMC` in out/soong/.intermediates/packages/apps/Settings/Settings/android_common/dexpreopt/Settings/oat/arm64/package.invocation (dex2oat invocation for an app defined in .bp) 3. Check the existence of `-Xgc:CMC` in $ANDROID_PRODUCT_OUT/obj/APPS/Dialer_intermediates/oat/arm64/package.invocation (dex2oat invocation for an app defined in .mk) 4. Check the value of ro.dalvik.vm.enable_uffd_gc in $ANDROID_PRODUCT_OUT/product/etc/build.prop Test: Build with `OVERRIDE_ENABLE_UFFD_GC=default m` for device with UFFD support, and do the steps above. Test: Build with `OVERRIDE_ENABLE_UFFD_GC=true m`, and do the steps above. Test: Build with `OVERRIDE_ENABLE_UFFD_GC=false m`, and do the steps above. Change-Id: I035ad32233e49e2a30ce11f6c7c318a648511ef8
2023-11-28Remove PreoptExtractedApk. Jiakai Zhang
This was added by r.android.com/513843 to force dexpreopt some GMS core modules even if dexpreopt is disabled, to avoid some memory usage regression. We no longer need it because dexpreopt is never disabled on production builds. Bug: 313505540 Test: m Change-Id: I605b7569c17ee715cd4df167768e25aaf51bcd37
2023-11-09Change OnlyPreoptBootImageAndSystemServer to OnlyPreoptArtBootImage. Jiakai Zhang
OnlyPreoptBootImageAndSystemServer was for making the eng build faster. This change makes it even faster. Bug: 309011617 Test: Presubmit Change-Id: If9001e99593b57deafa7b56f0ca6b3d4d80f56d3
2023-07-14Add a Make variable to determine ART boot image jars for testing. Jiakai Zhang
Bug: 290583827 Test: m nothing Change-Id: I6eb0c83dd14682905ebaf3af55171856300eb2e3
2023-06-22Use generics for DepSets Colin Cross
Use Go's generics for DepSets so they don't require a type-specific wrapper and reflection. Test: depsets_test.go Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
2023-05-19Parallelize singleton execution LaMont Jones
Bug: 281536768 Test: manual, presubmits Change-Id: I57fdc76ba6b277e88e196b506af87127a530fd37
2023-05-08Revert^2 "Generate boot image profiles even if dexpreopt is disabled." Jiakai Zhang
Revert submission 2580631-revert-2574032-XXTWCJDTDQ Reason for revert: Fixed build breakages Reverted changes: /q/submissionid:2580631-revert-2574032-XXTWCJDTDQ Bug: 280440941 Test: lunch aosp_cf_riscv64_minidroid-userdebug && m UNSAFE_DISABLE_HIDDENAPI_FLAGS=true dist Test: Disable dex2oat on host (to simulate macOS) and build Change-Id: I5f7f746ca1d4da660fe0c40115e6c71750dfdccc
2022-11-16Pass "-Xgc:CMC" to dex2oat when userfaultfd GC is enabled. Jiakai Zhang
This change is a no-op change. It doesn't enable userfaultfd GC by default. ENABLE_UFFD_GC=true can be passed to the build system to enable userfaultfd GC for testing purposes. Bug: 242553398 Test: - 1. lunch aosp_oriole-userdebug 2. ENABLE_UFFD_GC=true m 3. See "--runtime-arg -Xgc:CMC" in .invocation files. Change-Id: I789b49a71b9604fd41bf1ef77d0ac5bac4cbdf25
2022-08-08Use aapt2 Saeid Farivar Asanjan
Replace usage of `aapt` with `aapt2`. Bug: 236602069 Test: m nothing Change-Id: I0c3b224351aff82fa251fbe83447fd262ab520b1
2022-05-17Deterministically report path errors to all callers of dexpreopt.GetGlobalConfig Colin Cross
dexpreopt.GetGlobalConfig uses a OncePer to only parse the config once. If the config contains missing paths, which can happen in partial manifest branches, the missing path errors will only be reported on the first caller to GetGlobalConfig. Fix the nondeterminism by wrapping the PathContext and capturing any path errors and reporting them to all callers to GetGlobalConfig. Bug: 207813628 Test: tradefed branch builds Change-Id: I869c3ae49a819b1251b94b73e0487aa594cd5e22
2022-04-27Remove obsolete dexpreopt config option `UseArtImage`. Ulya Trafimovich
Bug: 170935728 Test: lunch aosp_cf_x86_64_phone-userdebug && m && lunch_cvd Change-Id: Id83b9085794fd2ec338077ca909f84e04ccad041
2022-01-28Annotate more java dependencies for licensing Colin Cross
Annotate more dependencies as runtime linked or toolchain. Bug: 207445310 Test: m checkbuild Change-Id: Ia5dc3321a1e476b16058eee94d6dc494fe1e933e
2021-12-20Dexpreopt standalone system server jars. Jiakai Zhang
Standalone system server jars are dynamically loaded by system server using a `PathClassLoader` whose parent is `SYSTEMSERVERCLASSPATH`. They are listed in `PRODUCT_STANDALONE_SYSTEM_SERVER_JARS` and `PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS` in Makefile. We need to dexpreopt them to achieve better performance. Bug: 203198541 Test: m nothing Test: - 1. Add a standalone system server jar (e.g., by patching aosp/1906158) 2. Build a system image. 3. See the odex and vdex files generated in $ANDROID_PRODUCT_OUT/system/framework/oat/ 4. Flash the image to a device. 5. Run `atest art_standalone_dexpreopt_tests`. Change-Id: I358a62d34989c5c8eba12e18fe6167e0b72ff69d
2021-11-30Add entries for STANDALONE_SYSTEMSERVER_JARS to systemserverclasspath.pb Jiakai Zhang
This CL updates platform_systemserverclasspath, systemserverclasspath_fragment, and prebuilt_systemserverclasspath_fragment to write entries for STANDALONE_SYSTEMSERVER_JARS to systemserverclasspath.pb. A new property `standalone_contents` is aded to `systemserverclasspath_fragment` and `prebuilt_systemserverclasspath_fragment` to list the standalone system server jars in the APEX, and entries will be written to systemserverclasspath.pb accordingly at build time. To add more context, these entries will be consumed by derive_classpath in order to generate an environment variable PRODUCT_STANDALONE_SYSTEM_SERVER_JARS. The environment variable will then be comsumed by odrefresh to determine what jars to preopt on early boot. Note that the variable should not end with "CLASSPATH" because the list is not used by runtime as a classpath. It is just a colon-separated list of jars. System server loads the jars separately with paths hardcoded in the code. Bug: 203198541 Test: manual - 1. Add some jars to PRODUCT_STANDALONE_SYSTEM_SERVER_JARS 2. Add some other jars to PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS and standalone_contents. 3. Build an image. 4. Flash the image to a device. 5. adb shell echo \$STANDALONE_SYSTEMSERVER_JARS 6. See the correct list of jars. Change-Id: I09a6fd1d3db85c194330da9b751702a9bf069e26
2021-08-27Rename BuildDir and NinjaBuildDir. Lukacs T. Berki
These are just out/ and out/soong/ and the old names were quite confusing. Test: Presubmits. Merged-In: I999ca62162062f27e449f83ffb00fa580d4065b8 Merged-In: I2fcd80a9e376a6842a06aa104a9f6f5c5e16f8c7 Change-Id: Ib481d2aac40df8da1b74174dc8ec576c1cb48be0
2021-07-28Rename UpdatableSystemServerJars to ApexSystemServerJars. satayev
This is consistent with naming for boot jars, e.g. ApexBootJars. Bug: 191127295 Test: presubmit Change-Id: I6e8828d55ac86b7f5260ed7f8d4eca1c0b3dced8
2021-07-22Rename UpdatableBootJars to ApexBootJars. satayev
Note that ART apex boot jars and core-icu4j are exceptions here as they are not part of ApexBootJars. ART apex boot jars are defined in their own variable, while core-icu4j is treated as a regular non-updatable boot jar. Bug: 191127295 Test: atest CtsClasspathsTestCases Change-Id: I3cea3d82ef521655a1a5ffa8cae2258ab9d08bfc
2021-05-18Don't fail if the target module is disabled in dex2oat tool Martin Stjernholm
dependencies. dexpreopt.RegisterToolDeps runs late after prebuilt dependencies have been resolved, and there's special code in dex2oatPathFromDep to resolve the prebuilt from the source module. However, if the source module is disabled then the dependencies check in validateAndroidModule will complain, so we need to disable that check in this particular situation. Also add a comment to explain why dexpreopt.RegisterToolDeps needs to run so late. Test: m nothing Bug: 145934348 Bug: 172480615 Change-Id: Ibc673303d0336768fa23261a2068e91a08f46a30
2021-05-15Add usesTargetFiles option in dexpreopt_gen Jeongik Cha
For running dex2oat on the target_files, the paths should be use the device install path instead of the path starting with $(OUT). So add usesTargetFiles option and basePath option which indicates extracted path. With those options, the path is replaced with $(basePath)/$(device path) And also, add DexPreoptImageDeviceLocations in the config which refers to the boot image path(without arch) on the device. Because DexPreoptImage related device path was missing. Bug: 158843648 Test: dexpreopt_gen -usesTargetFiles -basePath (extract path) and then check if paths in the generated shell script are based on on-device path. Change-Id: I9667fadbf3b7c6f770e0d1bcbee5d67c1ecd8a3d
2021-05-08Merge "Rename fields in dexpreopt config" Treehugger Robot
2021-05-07Rename fields in dexpreopt config Jeongik Cha
Add 'host' into the name of fields regarding path on the host side to distinguish between paths on the device(which will be added in the following commit), and paths on the host. Bug: 158843648 Test: build and flash, and then adb wait-for-device \ && adb -s $S root \ && adb -s $S logcat \ | grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C 1 Change-Id: Ib2645ed51591ba2f4b726c115b401ad2bd6675da
2021-05-05Make SystemServerJars ConfiguredJarList. satayev
Consistent with plumbing of boot jars. SystemServerJars only support /system/framework/ jars. Bug: 180105615, 155630745 Test: m && launch_cvd Change-Id: I58b005b7c4103c8e250090e995b1d9b2f9ed4a76
2021-04-28Add GetEmbeddedPrebuilt and IsModulePrebuilt Paul Duffin
Dedups the many repetitions of the code to obtain a *Prebuilt from a module. Bug: 177892522 Test: m nothing Change-Id: I1ededbe9ee79e89ea6dd8882dfee4be0bf0b51b7
2021-04-27Merge "Drop DexPreoptImages field in dexpreopt config" Treehugger Robot
2021-04-26Drop DexPreoptImages field in dexpreopt config Jeongik Cha
The field isn't used anymore. And DexPreoptImagesDeps will have the slice of which size is the same as Archs to avoid an error. Bug: 158843648 Test: m Change-Id: I520063ff7376811febbc82e1a0a43785feb5bbb2
2021-04-23Check consistency of the BootJars/UpdatableBootJars config Paul Duffin
Both out/soong/dexpreopt.config and out/soong/soong.variables contain configuration for the BootJars and UpdatableBootJars that MUST be identical. If they are not then it can lead to broken builds. This change adds a consistency check for them that will make the issue more obvious. Bug: 186195980 Test: DIST_DIR=out/bionic-dist ./art/tools/dist_linux_bionic.sh -j80 com.android.art.host com.android.support.apexer --skip-soong-tests Ran the previous command with and without the fix in https://r.android.com/1684877. Without the fix the build reported an inconsistency in the configuration, with that fix the build passed. Change-Id: I10fbe328ba4f1fbd9db4708409979e9824c196ef
2021-04-19Expose "full" dexpreopt.config Jeongik Cha
1. Instead of 'slim' config, use full config even for libs 2. Define moduleJSONConfig for fields which cannot be converted to JSON field directly(Path type field, ProfileBootListing, DexPreoptImagesDeps are added in this CL) and exclude fields which is convertible(DexPreoptImageLocations) Bug: 158843648 Test: m dist Change-Id: I3f9192ab5292bd079be1b686bb3b25735a836cbc
2021-04-15Made ManifestPath OptionalPath instead of Path Jeongik Cha
because it is actually an optional value. Bug: 158843648 Test: m nothing Change-Id: If323eacf6a7aa83dcf5ce4825ad8cabeeaa97ac9
2021-03-25Merge "Allow using updatable boot jars in dexpreopt (but don't use them yet)." Ulyana Trafimovich
2021-03-24Cleanup usages of Dex2oatDepTag Paul Duffin
Creates a new deptag type for it so that it can implement the marker interfaces that will exclude it from being added to the APEX and from visibility enforcement. The latter is probably not an issue ATM because the dependencies are added after visibility checks are enforced but this code is undergoing lots of refactoring so that may change. Bug: 177892522 Test: m nothing Change-Id: Ibd167d557adec761a2e3eed78f4d334c40a04fb9
2021-03-24Allow using updatable boot jars in dexpreopt (but don't use them yet). Ulya Trafimovich
This CL handles updatable boot jars in the same hacky way as we handle non-updatable boot jars: it creates a set of predefined paths to the dex jars in a global config, then traverses all modules in a singleton context, finds updatable boot jars and adds copy rules from these jars to the predefined paths. A proper way would be to register dependencies of the dexpreopted modules on the boot jars and extracting paths to dex files by walking these dependencies. Bug: 178467404 Test: lunch aosp_cf_x86_64_phone-userdebug && m Test: added new Soong test Change-Id: I87f764109315f79315d73bf43799b70eb010fc0b
2021-03-02Use compiler filter "verify" for dexpreopt w/o class loader context. Ulya Trafimovich
In cases when class loader context cannot be computed at build time and verify_uses_libraries check is relaxed (RELAX_USES_LIBRARY_CHECK=true) dexpreopt uses a special compiler filter that suppresses AOT-compilation to native code and applies only those optimizations that do not require class loader context. Previously the "extract" filter was used. Now ART supports using "verify" filter in this configuration. Bug: 132357300 Test: lunch cf_x86_64_phone-userdebug && m && launch_cvd \ adb wait-for-device && adb root && adb logcat \ | grep -E 'ClassLoaderContext [a-z ]+ mismatch' # empty grep output, no errors Change-Id: Id4933aa94ea96894278355283383c16d103e98c9
2021-02-22Add non-fatal mode for verify_uses_libraries check. Ulya Trafimovich
The new mode is enabled with environment variable RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a verify_uses_libraries check failure does not fail the build, instead it sets a special compiler filter "extract" for dexpreopt, which means that the DEX file will be extracted, but it won't be compiled to native code. Class loader context will be set to empty in this case (not &, as it is going to be deprecated soon). If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something other than "true", then the old behaviour of the verify_uses_libraries check is preserved. The intended use case for this flag is to have a smoother migration path for the Java modules that need to add <uses-library> information in the build files. The flag allows to quickly silence build errors. This flag should be used with caution and only as a temporary measure, as it masks real errors and affects performance. verify_uses_libraries check is reworked so that it writes the error message to a status file (which is used instead of the former timestamp file). Currently the stored error message is not used, but it may be used later to produce a warning. Dexpreopt command checks if the status file exists and is nonempty; if that is the case, then compiler filter is set to "extract". Bug: 132357300 Test: Manually add some mismatch between the libraries in the Android.bp and Android.mk files for dexpreopted apps, build with RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't fail and they are compiled with compiler-filter "extract". Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails. Change-Id: Ibb5d993a25b1df1d2e70b7d5aafc6997f9d64e67
2021-01-28Write module dexpreopt.config for Make. Ulya Trafimovich
This is needed for Java libraries that are <uses-library> dependencies of Java libraries and apps defined as Make modules. Each dexpreopted module in Make generates a dexpreopt.config file, which incorporates information from its dependencies' dexpreopt.config files. For dependencies that are Make modules their dexpreopt.config files are generated by Make, and for Soong modules they are generated by Soong. Since Soong doesn't know which libraries are used by Make, it generates build rules for a superset of the necessary libraries. Bug: 132357300 Test: lunch aosp_cf_x86_phone-userdebug && m Change-Id: I325b1037658736ee3c02450b08c00eca1a175962
2021-01-21Allow createGlobalSoongConfig() to be used from tests Paul Duffin
Previously, the createGlobalSoongConfig() function was explicitly prevented from being used in tests because it would fail. However, it turns out that is no longer the case and it does now work. That allows the following changes to be made: * Tests no longer need to use GlobalSoongConfigForTests() to prepopulate the cache. * GlobalSoongConfigForTests() is only needed in the dexpreopt package. Bug: 177892522 Test: m nothing Change-Id: Ifcbb1a44254c5d2d10c1d02ab23227488d1d1ed1
2021-01-20Merge "dexpreopt: Use the dirty-image-objects path from frameworks/base." Nicolas Geoffray
2021-01-20dexpreopt: Use the dirty-image-objects path from frameworks/base. Nicolas Geoffray
Test: m Bug: 176171716 Change-Id: Ifbc08ae03e2b1bec7161948970bd197386e3b305
2021-01-20Support building boot images with disabled dexpreopt. Ulya Trafimovich
Bug: 176171716 Test: build_mainline_modules.sh and ensure that the ART boot image is built: `find out -type f -name '*.art'` is nonempty for every arch. Change-Id: Ibc45581eef2b205c750a30709780cf659ba7cfa1
2020-11-16Merge "Replace android.WriteFile rule with android.WriteFileRule" Colin Cross
2020-11-14Replace android.WriteFile rule with android.WriteFileRule Colin Cross
The android.WriteFile rule takes careful escaping to produce the right contents. Wrap it in an android.WriteFileRule that handles the escaping. Test: compare all android.WriteFile outputs Change-Id: If71a5843af47a37ca61714e1a1ebb32d08536c31