Commit graph

102 commits

Author SHA1 Message Date
Jiakai Zhang
51b2a8b5eb Use per-app package list to avoid unnecessary dexpreopt.
Starting from aosp/2594905, dexpreopt depends on
`$PRODUCT_OUT/product_packages.txt`. When PRODUCT_PACKAGES changes,
dexpreopt has to rerun for all apps. This is not ideal.

After this change, dexpreopt uses a per-app product_packages.txt that is
filtered by the app's dependencies, and it uses `rsync --checksum` to
prevent the file's mtime from being changed if the contents don't change.
This avoids unnecessary dexpreopt reruns.

Bug: 288218403
Test: m
Test: Change PRODUCT_PACKAGES and see no dexpreopt reruns.
Change-Id: I5788a9ee987dfd0abfd7d91cbcef748452290004
2023-06-28 17:59:56 +01:00
Jiakai Zhang
a449678996 Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.

For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.

After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.

Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.

Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
  1. lunch aosp_cf_x86_64_phone-userdebug && m
  2. Check the .invocation file of the "Settings" package (defined in
     .bp file)
  3. See androidx.window.extensions
Test: -
  1. lunch aosp_redfin-userdebug && m
  2. Check the .invocation file of the "Settings" package (defined in
     .bp file)
  3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
  .mk file)
Test: -
  1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
  2. adb shell pm art dump
  3. See "reason=prebuilt" instead of "reason=vdex".
     (https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
     after: right)

Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-30 15:46:38 +01:00
Jiakai Zhang
cf61e3c591 Revert^2 "Generate app profiles even if dexpreopt is disabled."
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: I6090b4b74cedb6d129fcbeef58d075c8ccdcc4e2
2023-05-08 21:29:23 +01:00
Qiao Yang
3d08c388b9 Revert "Generate app profiles even if dexpreopt is disabled."
Revert submission 2574032

Reason for revert: DroidMonitor-triggered revert due to breakage <https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=aosp_cf_riscv64_minidroid-userdebug&lkgb=10069333&lkbb=10075041&fkbb=10071083>, bug <b/280902279>

Reverted changes: /q/submissionid:2574032

Change-Id: Ia9d05f3b7439604eb4a4b4100f46879fe11f5820
BUG: <280902279>
2023-05-05 15:03:24 +00:00
Jiakai Zhang
7b845e808f Generate app profiles even if dexpreopt is disabled.
Bug: 280440941
Test: -
  1. Patch ag/22302622 to disable dexpreopt.
  2. lunch aosp_cf_x86_64_phone-userdebug && m
  3. See app profiles still generated.
Test: -
  1. Patch ag/20592051 to enable profile for service-art.
  2. banchan com.android.art x86_64 && m
  3. See the profile for service-art generated.
Change-Id: I4e721b475b84a2f667bbccc030a8947078f26bb0
2023-05-04 13:53:22 +01:00
Jiakai Zhang
b879620ca8 Revert^2 "Generate a boot image extension for mainline BCP...
Revert submission 2465993-boot-image-mainline-revert

Reason for revert: Relanding the changes

Reverted changes: /q/submissionid:2465993-boot-image-mainline-revert

Change-Id: Ie611cf3a1ff4be7a7beab164f69b4186c474be5c
2023-03-16 08:46:29 +00:00
Jiakai Zhang
db160c078e Revert "Generate a boot image extension for mainline BCP jars."
This reverts commit 3830308fb8.

Reason for revert: Caused various SH regressions.

Bug: 271036161
Change-Id: Ia785324f83006a095e262c251b24d49fd778427e
2023-03-02 13:01:59 +00:00
Jiakai Zhang
3830308fb8 Generate a boot image extension for mainline BCP jars.
Bug: 269230245
Test: m
Test: atest art_standalone_dexpreopt_tests
Change-Id: I253c30d938eee2cf2549ec2338425d53956e7cbb
2023-02-24 17:14:08 +00:00
Jiakai Zhang
81e468171f Use the profiles in the APEX to dexpreopt system server jars.
After this change, if "profile_guided: true" is set, profile-guided
compilation will be enabled for the jar and the ".prof" file next to
the jar in the APEX ("javalib/<name>.jar.prof") will be used as the
profile when dexpreopting for the prebuilt APEX.

Bug: 241823638
Test: m nothing
Test: -
  1. (on internal master) Patch aosp/2426453.
  2. Build the APEX bundle and the module SDK of com.android.wifi
  3. (on tm-dev) Patch this CL and aosp/2141972.
  4. Copy the APEX bundle and the module SDK built on step 2 to the
     source tree
  5. Disable hiddenapi check
  6. lunch cf_x86_64_phone-userdebug && m MODULE_BUILD_FROM_SOURCE=false com.google.android.wifi
  7. cat out/soong/.intermediates/prebuilts/module_sdk/Wifi/current/prebuilt_service-wifi/android_common_com.android.wifi/dexpreopt/oat/x86_64/javalib.invocation
  8. See the profile being used.
Change-Id: I55a5a295e9c5d6f0564afb139c5fb7da91ab8cae
2023-02-15 22:47:24 +00:00
Jiakai Zhang
9c4dc19f4e Output dex_preopt to SDK snapshot.
This is needed to determine whether we need to deapex the profile or
not.

Bug: 241823638
Test: m nothing
Test: -
  1. Patch ag/20582608 PS2.
  2. TARGET_BUILD_APPS=com.android.wifi packages/modules/common/build/mainline_modules_sdks.sh
  3. See the `dex_preopt` property being written.
Change-Id: I05177388c24be1ab315247ea85e7e3a8600cebd3
2023-02-15 22:47:23 +00:00
Jiakai Zhang
3317ce725d Install system server jar profiles into the APEX.
After this change, if profile-guided compilation is enabled for an APEX
system server jar, the profile will be installed next to the jar with
the ".prof" suffix, ("javalib/<name>.jar.prof"). This file will later be
used by odrefresh and dexpreopt from prebuilt APEX.

Bug: 241823638
Test: m nothing
Test: -
  1. Patch ag/20581649 PS2.
  2. banchan com.android.btservices x86_64 && m
  3. Check that "javalib/service-bluetooth.jar.prof" exists in the APEX.
Change-Id: Ibcfc6257dade92bd40a6d4b7368148717d0863b9
2023-02-08 19:25:37 +08:00
Jiakai Zhang
2fbc355f47 Only dexpreopt system server jars for the primary arch.
This change stops the build system from dexpreopting system server jars
for the secondary arch. System server jars are only loaded by the system
server, so the artifacts for the the secondary arch are not used.

Bug: 260577273
Test: Build a system image and no longer see artifacts for the
  secondary arch.
Change-Id: I0b131a02e996ed50e7aec3bb0a221f8ceed9ce57
2022-11-28 15:38:23 +00:00
Ulya Trafimovich
442ec7fc07 Remove obsolete dexpreopt config option UseArtImage.
Bug: 170935728
Test: lunch aosp_cf_x86_64_phone-userdebug && m && lunch_cvd
Change-Id: Id83b9085794fd2ec338077ca909f84e04ccad041
2022-04-27 13:36:47 +01:00
Jiakai Zhang
6decef916c Allow installing boot images outside of APEX.
After this change, `bootImageConfig.installDirOnDevice` can be set to a
path outside of the APEX, in which case, the boot image will not be
installed in the APEX. Instead, it will be installed to the given path
by Make.

This is a no-op change. Current behavior is not affected.

Bug: 211973309
Test: m nothing
Test: -
  1. m com.android.art
  2. See the boot image still being installed in the ART APEX.
Test: -
  1. Change `installDirOnDevice` of the ART boot image config to
     `system/framework`.
  2. See the boot image being installed in `/system/framework/<arch>`.
Change-Id: Ib13b17cc9e94dc5754c9b51b04df3307323b8783
2022-01-13 14:50:05 +00:00
Jiakai Zhang
880e11112d Merge changes I8f4eaed1,I358a62d3
* changes:
  Dexpreopt standalone system server jars from prebuilts.
  Dexpreopt standalone system server jars.
2021-12-20 19:52:37 +00:00
Jiakai Zhang
28bc9a8a7e Dexpreopt standalone system server jars from prebuilts.
This change adds support for dexpreopting standalone system server
jars from prebuilts.

Bug: 203198541
Test: -
  1. Add a standalone system server jar (e.g., by patching
     aosp/1906158)
  2. Build and drop a module SDK and an APEX.
  3. Build a system image from prebuilts.
  4. See the odex and vdex files generated in
     $ANDROID_PRODUCT_OUT/system/framework/oat/
Change-Id: I8f4eaed10a1053cd560b8583efa12dc495f58db1
2021-12-20 15:48:20 +00:00
Jiakai Zhang
389a647320 Dexpreopt standalone system server jars.
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-12-20 15:07:26 +00:00
Colin Cross
c68db4b305 Remove InstallBypassMake and ToMakePath
InstallBypassMake and ToMakePath are obsolete, remove them.

Bug: 204136549
Test: m checkbuild
Change-Id: Ie5a6f7254b3d317ed6039e114ed6aec35e1ce273
2021-12-15 15:22:53 -08:00
Colin Cross
38310bb4ac Only get dexpreopt config for device modules
Calling dexpreopt.GetGlobalConfig can return errors, move the checks
that don't depend on dexpreopt.GetGlobalConfig first to avoid
breaking all modules when the global config is invalid, for example
in a partial branch that is missing the BootProfileImages file.

Bug: 207813628
Test: tradefed branch builds
Change-Id: Id1689de3f1ef986a41a60622cb357edb9d323b8a
2021-12-01 12:32:11 -08:00
Colin Cross
fa9bfcd0d2 Honor PreventInstall for APKs and dexpreopt files
Native coverage builds create a second variant of APKs and set
PreventInstall on the non-coverage variant.  Skip calling
ctx.InstallFile for APKs and in dexpreopt when PreventInstall
is set.

Fixes: 205865567
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="*" NATIVE_COVERAGE_EXCLUDE_PATHS="art bionic/libc device external/compiler-rt external/clang external/llvm external/swiftshader/third_party/llvm-10.0"
Change-Id: I9e38ac737315db12475e8f9bfb3e0e7c0327fc06
2021-11-10 16:42:38 -08:00
Colin Cross
1d0eb7a9d0 Fix ctx.InstallFile calls for java modules
Call ctx.InstallFile on the primary install file last so that the
primary install file can depend on the extra install files, and so that
the primary install file can be inferred from the last installed file.

Add missing ctx.InstallFile calls for the dexpreopt and hostdex outputs.

Fix the install subdirectory for modules installing to the testcases
directory.

Bug: 204136549
Test: m checkbuild
Change-Id: I7edd7647be27439d3ca0ecc589ca5e89d4ba8474
2021-11-05 14:20:28 -07:00
Jiakai Zhang
02669e8a30 Preopt system server jars with updatable bootclasspath.
Previously, we preopt system server jars without updatable bootclasspath
in the build system so that the artifacts can keep valid after a
mainline update. Things have been changed after then. We now re-compile
system server jars on the user's device after a mainline update
(b/189467174), so we no longer need the artifacts generated at build
time to keep valid. Therefore, we can preopt system server jars with
updatable bootclasspath to achieve better performance.

Bug: 199573699
Test: m services
Test: manual - 1. Build a system image and flash it into a device.
  2. adb root && adb shell grep "services" /proc/`adb shell pidof system_server`/maps
  3. See "/system/framework/oat/x86_64/services.{odex,vdex,art} in the
  output.
  4. adb logcat -d odrefresh:D odsign:D "*:S"
  5. See "odrefresh said artifacts are VALID" and no dex2oat invocation
  in the output.

Change-Id: I9c94a54aa15c46708067f4bc89ff05bc7af32a7b
2021-09-15 09:01:07 +00:00
Jiakai Zhang
204356f3b5 Preopt APEX system server jars from prebuilts.
Similar to the previous CL, but for jars from prebuilts.

Test: manual - 1. Patch aosp/1818020 and aosp/1810840.
  2. m SOONG_CONFIG_art_module_source_build=false com.android.art
Bug: 194150908
Change-Id: Idc0c73a78045a602ad3a91cb5071d291bd611015
2021-09-15 09:01:07 +00:00
Jiakai Zhang
ca9bc98e0c Preopt APEX system server jars.
The path to the artifacts will in the form of
/system/framework/oat/<arch>/<encoded-jar-path>@classes.{odex,vdex,art},
where <encoded-jar-path> is the path to the jar file with "/" replaced
by "@". For example,
/system/framework/oat/x86_64/apex@com.android.art@javalib@service-art.jar@classes.odex

There will be a follow-up CL to update ART runtime to recognize
artifacts in that path.

Test: m com.android.art
Bug: 194150908
Change-Id: Ic89fd63c4b1cd565684cead83fc91dae3bc97a4c
2021-09-15 09:01:07 +00:00
Jeongik Cha
4b073cd083 dexpreopt.config should be created even though unbundled image is built
Bug: 188179858
Test: compare dexpreopt_config.zip files from
 1. TARGET_BUILD_UNBUNDLED_IMAGE=true m dexpreopt_config_zip
 2. m dexpreopt_config_zip
(note that m clean should run between steps)

Change-Id: I36a6e8b10b9922cc5522accaf90af1aa05049a86
2021-07-15 09:57:49 +09:00
Jeongik Cha
4dda75e73e Add usesTargetFiles option in dexpreopt_gen
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-15 00:29:49 +09:00
Treehugger Robot
564fce4578 Merge "Rename fields in dexpreopt config" 2021-05-08 01:47:39 +00:00
Jeongik Cha
a596909342 Rename fields in dexpreopt config
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-07 21:40:23 +09:00
satayev
9a6f87ebd6 Make SystemServerJars ConfiguredJarList.
Consistent with plumbing of boot jars. SystemServerJars only support /system/framework/ jars.

Bug: 180105615, 155630745
Test: m && launch_cvd
Change-Id: I58b005b7c4103c8e250090e995b1d9b2f9ed4a76
2021-05-05 14:24:02 +01:00
Jeongik Cha
b19b58a015 Drop DexPreoptImages field in dexpreopt config
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-26 23:41:40 +09:00
Jeongik Cha
c6246671ea Expose "full" dexpreopt.config
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-19 18:24:42 +09:00
Jeongik Cha
33a3a8182f Made ManifestPath OptionalPath instead of Path
because it is actually an optional value.

Bug: 158843648
Test: m nothing
Change-Id: If323eacf6a7aa83dcf5ce4825ad8cabeeaa97ac9
2021-04-15 09:12:49 +09:00
Ulya Trafimovich
9023b02c00 Allow using updatable boot jars in dexpreopt (but don't use them yet).
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-24 11:16:11 +00:00
Ulya Trafimovich
8c35fcf4d5 Add non-fatal mode for verify_uses_libraries check.
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-02-22 15:41:03 +00:00
Ulya Trafimovich
c0f64799da Don't write nonexistent DEX file paths to dexpreopt.config files.
A path to an nonexistent file caused dex2oat to write an empty path in
the class loader context stored inside of the OAT/ODEX file, which
resulted in class loader context mistmatch and a failure to load
dexpreopt code on device.

An example of a faulty class loader context for GoogleDialer, can be
seen either with oatdump or by grepping logcat for class loader context
mimatch messages (the first empty PCL[] is expected, note the second
empty PCL[] in the subcontext for shared libraries):

  PCL[]{PCL[]#PCL[/system/framework/org.apache.http.legacy.jar*22205474]

This CL removes the nonexistent path from the generated dexpreopt.config
file, which works in conjunction with a change in makefiles that stops
using the removed config field. This is possible because makefiles can
access DEX files using a module name and "intermediates-dir-for" macro.

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: I8d16f77c6f76ad6234cc4114ad3545cbe572ef13
2021-02-04 12:14:51 +00:00
Paul Duffin
612e610063 Switch hiddenapi to use OutputPath instead of ModuleOutPath
In order to allow the hiddenapi code which expects its inputs to be
ModuleOutPath to consume the output from the deapexer module type (used
by prebuilt_apex) this change converts the hiddenapi from using
ModuleOutPath to use OutputPath instead.

This is part of a general cleanup to remove ModuleOutPath that is
separated out in order to avoid having the hiddenapi work dependent
upon and possibly delayed by issues with that general cleanup.

Bug: 178361284
Bug: 179124768
Test: m droid
Change-Id: I890f775bf5e33528dbaa62b95fa4198185ff8bf8
2021-02-02 14:42:05 +00:00
Ulya Trafimovich
76b0852a48 Write module dexpreopt.config for Make.
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-28 06:29:13 +00:00
Jaewoong Jung
4b97a56615 Remove the return value from dexpreopt
dexpreopt doesn't strip dex files from the input jar anymore, so there's
no point returning the input jar path untouched.

Test: m nothing + TreeHugger
Change-Id: I8fde6cdc19e85a2fbc946513696417b945c5de0f
2020-12-17 09:43:28 -08:00
Colin Cross
f1a035e6be Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access
the BuilderContext by passing it to NewRuleBuilder instead of
RuleBuilder.Build.

Test: genrule_test.go
Test: rule_builder_test.go
Test: m checkbuild
Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-12-01 16:22:16 -08:00
Ulya Trafimovich
8cbc5d269b Rework class loader context implementation.
The old representation consisted of a list of libraries (UsesLibraries),
a list of optional libraries (OptionalUsesLibraries) and a mapping from
library name to its build/install paths (LibraryPaths). The separation
into lists and map was necessary because of special handling of
compatibility libraries, which is now unified with normal libraries.

The new representation is a mapping from target SDK version to a tree
structure ClassLoaderContext. Each node of the tree represents a library
and contains library name, build/install paths and a slice of
subcontexts for dependencies. The same library may occur in the tree
multiple times in case it is a dependency of multiple libraries. The
order in which libraries are added matters (the resulting tree shape may
be different).

Test results have to be updated, as the resulting <uses-library> list is
reodered (previously it was a sorted list of map keys, and now it is
formed by a depth-first preorder traversal of the class loader tree).

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Bug: 168686456
Change-Id: I11be8cd2967f004fd58753d7c5fb99fed179cd63
2020-11-03 15:15:46 +00:00
Colin Cross
56a8321c21 Remove global state from apex modules
A global variant was used to store the global mapping between
modules and APEXes.  Replace it with storing pointers to APEX
contents inside each module so that they can query the contents
of any APEXes they belong to.

Bug: 146393795
Test: all Soong tests
Test: single line change to build.ninja host install dependency ordering
Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk
Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
2020-10-06 13:39:57 -07:00
Dan Willemsen
78d51b00de Only look for profiles when we have a profile dir
Right now, it's looking for *.prof files at the top of the source
directory.

For devices that don't specify the profile dir (everything on AOSP,
etc), this saves a couple percent of the globs that we check during
every build (and would re-execute if you add or remove files from the
top directory)

Bug: 159845846
Test: treehugger
Change-Id: I10d43422a2b5ae25e6557d435ecc89fe43536dd7
2020-06-24 16:33:31 -07:00
Ulya Trafimovich
6e82748bd6 Rename dexpreopt.config field to bring it in sync with Make.
Different names of the same field in Make and in Soong resulted in
the field being dropped when unmarshalling the JSON from Make to Soong.
As a result, the list of optional used libraries for Make modules was
always empty.

Test: lunch aosp_cf_x86_phone-userdebug && m
Test: Cherry-pick in internal master and observe that the logcat error
    "ClassLoaderContext shared library size mismatch" for GoogleDialer
    has disappeared:
    terminal-1 $ lunch cf_x86_phone-userdebug && m && launch_cvd
    terminal-2 $ adb wait-for-device && adb root \
        && adb logcat | grep 'size mismatch'
    (nothing after the change, one error message before the change)

Bug: 132357300
Change-Id: I57820646fa7c1d8af01b2cbc8a3521da450719c0
2020-06-12 14:47:50 +01:00
Martin Stjernholm
fa096325fe Merge changes from topics "target-build-unbundled", "unbundled-preopt"
* changes:
  Don't disable dexpreopting implicitly in unbundled builds.
  Add TARGET_BUILD_UNBUNDLED as a variable to control builds.
2020-06-11 10:01:59 +00:00
Martin Stjernholm
95d6ea3781 Don't disable dexpreopting implicitly in unbundled builds.
Test: art/test/testrunner/run_build_test_target.py art-linux-bionic-x64
  with TARGET_BUILD_UNBUNDLED enabled in the build scripts
Test: art/test/testrunner/testrunner.py --target --64 --optimizing
  with TARGET_BUILD_UNBUNDLED enabled in chroot on device
Bug: 157549171
Change-Id: I124c341d1801c4afa22f836dd567019de3e9498e
2020-06-04 20:28:21 +01:00
Ulya Trafimovich
d4bcea4e24 Refactor library path representation in dexpreopt.
This is a preliminary CL before fixing on-device paths to DEX jars.
It groups together the inormation about on-host build paths and
on-device install paths to library DEX jars.

This CL changes the structure of module dexpreopt.config files
generated by the build system. Aside of that, no functional changes.

Test: lunch aosp_cf_x86_phone-userdebug && m
Change-Id: I059654be7670f2ba66248d9c49b9694a0591f9c1
2020-06-04 17:37:42 +01:00
Ulya Trafimovich
6cf2c0c197 Fix host path for dexpreopted system server modules defined in Make.
Previously there was a discrepancy between the generated paths for
Soong modules that used "out/soong/system_server_jars" and Make modules
that used "out/system_server_jars". This happened because the default
output directory is $OUT/soong for the normal Soong config and jsut $OUT
for the reduced "null config" created by dexpreopt_gen.

As a result, class loader context for system server jars defined in Make
was referring to nonexistent jars, which caused non-fatal dex2oat errors
(the build was not broken, so the errors remained unnoticed):

  Failed to determine oat file name for dex location out/system_server_dexjars/[...]
  Could not open dex files from location: out/system_server_dexjars/[...]

Test: aosp_walleye-userdebug boots
Test: cherry-picked in master-arc-dev that has a Make system server jar
  arc-services, `lunch lunch cheets_x86-userdebug && m`, check that the
  generated dexpreopt.sh for arc-services contains paths starting with
  "out/soong/system_server_jars" rather than "out/system_server_jars".

Bug: 140712566
Change-Id: Ia7ea8ac383e32042c31d64971cdc8101ea3068cd
2020-04-27 09:46:02 +01:00
David Srbecky
ab99498ea1 Adjust embedded dex locations in host boot image.
ART tests require that "out/host/linux-x86" is included.

This requires making the dexLocations per-variant specific.

Test: m test-art-host-gtest
Bug: 147817558
Bug: 147819342
Change-Id: I7839ee15cb6dfc62508bdd3fa0f306336af17055
2020-04-01 12:06:56 +01:00
David Srbecky
1aacc6c3df Fix dump-oat-boot build target.
Implement support of dumping host boot.art.

That was not possible before because imageLocation is different on host.

This CL makes imageLocation per-variant so can access for the host variant.

Test: m dump-oat-boot
Change-Id: Id82161e4901a6b77f220238aec460b8609fd765f
2020-03-26 15:28:27 +00:00
David Srbecky
c177ebeca9 Distinguish boot images by target rather than arch
We plan to add boot image variants for host tests.
Distinguishing the variants by arch does not work,
since both host and device can have the same arch.

Change-Id: Iea73c77367affb074f97a0fc318389417ce537da
2020-02-26 17:04:21 +00:00