Commit graph

18 commits

Author SHA1 Message Date
Spandan Das
15a67111f8 Make dex_preopt.enable_prof_rewrite=false an error for optimized apps
If profile guided dexpreopt _and_ optimization/obfuscation is true, then
apps must use the rewritten profile created by r8/d8

Bug: 335418838
Test: m nothing --no-skip-soong-tests
Change-Id: Iac45b614f43e52ac40ad1d13df0338bcafa788c3
2024-05-30 20:44:44 +00:00
Spandan Das
3dbda18e80 Use r8/d8 optimized profile for dexpreopt
Currently, dexpreopt supports profile guided optimization. This does not
work well with r8/d8 optimization, since the checked-in profile will not
match the dex signatures after r8/d8 has optimized the dex code.

This CL introduces a new property `dex_preopt.enable_profile_rewrting`.
If set, the checked-in profile will passed as `input` to r8 via
`--art-profile <input> <output>`. The <output> from the previous command
will be used as the profile for dexpreopt.

Test: m nothing --no-skip-soong-tests
Test: m CredentialManager with https://ag.corp.google.com/27448930
and obfuscation turned on
Test: nm -U symbol.odex # contains obfuscated methods

Bug: 335418838

Change-Id: I53beed9ed76f013262f1c503de0f2b74997c2a7f
2024-05-29 01:05:05 +00:00
Sam Delmerico
c8e040c70f transitive r8 flags for installable {android,java}_libraries
Only android_apps were actually applying transitive proguard flags files
to their r8 invocation. This CL ensures that this also occurs for
installable android_libraries and java_libraries.

Bug: 302342049
Test: go test ./java
Change-Id: Ie94d688d04367ee3d39e7e760fb3003df5829951
2023-10-31 18:59:04 +00:00
Sam Delmerico
95d709402a export_proguard_spec for libs deps
Add a property to export proguard flags files for libs dependencies.
Currently only proguard flags files from static deps are propagated up
to reverse dependencies, but it is necessary sometimes to have flags
from libs dependencies also be propagated.

Bug: 289087274
Test: go test ./java
Change-Id: Ic0aa22b086792bf322041aa5780db6c4f4eb2770
2023-08-18 15:43:56 +00: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
Treehugger Robot
de1d5bc90c Merge "Revert "Revert "R8/D8 should use sdk_version prop to determine API surface stability.""" 2023-02-23 21:39:49 +00:00
Spandan Das
c404cc79e9 Revert "Revert "R8/D8 should use sdk_version prop to determine API surface stability.""
This reverts commit 7eb9243fa7.

Reason for revert: The original change was reverted since it was suspected to cause missing libc++.so errors. It was a red herring, and the root cause has been fixed now b/264588525

Change-Id: Ib9110c41bacf220b91f24de11589f63235895e56
2023-02-23 18:05:05 +00:00
Sam Delmerico
9f9c0a22fa transitive Java deps for r8
The -libraryjars argument to r8 was missing transitive dependencies, and
so complained when there were classes used in the program JAR which were
not provided via libraries. This CL propagates transitive dependencies
to the r8 command to reduce the warnings that are generated for missing classes.

Bug: 242088131
Change-Id: Ifad7bc7c5d406e3de8d98ea963c97e88c84b45a1
2023-01-20 17:05:14 -05:00
Spandan Das
7eb9243fa7 Revert "R8/D8 should use sdk_version prop to determine API surface stability."
This reverts commit daa220ae8c.

Reason for revert: Suspected to be a cause for build failure (b/264446640). Will use go/abtd to verify

Change-Id: Ibfdf893f2426b1119923467027e0acedd08808c1
2023-01-04 22:14:59 +00:00
Spandan Das
daa220ae8c R8/D8 should use sdk_version prop to determine API surface stability.
`min_sdk_version` is used to represent the api_level of the device and
its type will eventually become android.ApiLevel. OTOH,
`sdk_version` property represents the API surface a module builds against
_and_ the version of that API surface. For
R8/D8, the additional `--android-platform-build` should be determined
using the sdk_version of the soong module and not min_sdk_version, since
min_sdk_version will not contain information about the api surface used
for compilation.

The unit test for `core_platform_app` in TestR8 were passing since
min_sdk_version was not set, and therefore it implicitly defaulted to
sdk_version.

Also created a custom struct to propagate params to the helper dex
functions

Test: In build/soong, go test ./java
Test: TH
Bug: 208456999
Change-Id: I08ac6f496444d603557e498c8a1794af665abc7a
2023-01-04 00:16:45 +00:00
Jared Duke
5979b30170 Revert "Revert "Include proguard flag files from transitive java_library deps""
This reverts commit 6f7e288fb5.

Reason for revert: Downstream proguard usage has been fixed.

Change-Id: I3667e7e908eebc62c640b42cb96b04993fc66e45
2022-12-19 23:05:28 +00:00
Colin Cross
6f7e288fb5 Revert "Include proguard flag files from transitive java_library deps"
This reverts commit 9c54f032b9.

Reason for revert: b/262940536

Bug: b/262940536
Change-Id: I8140eacc7ca8716f799561412cb5cef29df35d29
2022-12-17 03:15:22 +00:00
Jared Duke
9c54f032b9 Include proguard flag files from transitive java_library deps
Ensure proguard flag files specified by java_library targets propagate
to downstream targets. This matches bazel behavior, as well as
behavior for transitive android_library deps.

Bug: 212623640
Test: m + presubmit
Change-Id: I61abaf1fd43d6f06bb610383751bb26e9a1bafd6
2022-12-16 14:09:08 -08:00
Jared Duke
40d731a4c3 Provide platform build flag to R8/D8
Provide the `--android-platform-build` flag to R8/D8 for targets that do
not specify a stable min SDK. This includes all targets that do not
specificy an SDK version (e.g., services.jar, SystemUI.apk) and all
targets that specify core_platform (e.g., framework.jar).

Follow-up work will expand the set of cases that qualify for this flag,
but for now this captures some of the highest priority targets.

Bug: 232073181
Test: m + presubmit + validate verbose.log
Change-Id: Idad32c80490a101c049b7f937807a615564ca8ef
2022-09-21 11:01:32 -07:00
Remi NGUYEN VAN
bdad314f97 Make ignorewarnings optional in optimize
This allows targets to opt-in to running R8 without the -ignorewarnings
flag. Ignored warnings can cause code to be optimized incorrectly, so
this makes the build safer for such targets.

Ideally ignore_warnings should default to false, but all targets need to
be fixed for that to happen. As a first step, provide a mechanism for
individual targets to ensure they do not introduce regressions.

Bug: 229727645
Bug: 180878971
Bug: 226127213
Bug: 239990030
Test: m (runs dex_test)
Change-Id: Ic0eef29598c1ee47e958da8a5048d9696165a235
2022-08-04 13:23:47 +09:00
Colin Cross
9bb9bfb349 Don't pass static libs to r8
r8 gets the static libs in the program jar, it shouldn't also get
them as library jars.  Keep a separate classpath for dexing that
includes libs but not static_libs.

Bug: 222468116
Test: m checkbuild
Test: TestD8
Test: TestR8
Change-Id: Icca3393f496cbcadcc633f3b156761e6c145f975
2022-03-18 20:48:27 +00:00