Commit graph

19 commits

Author SHA1 Message Date
Sam Delmerico
59570d1e64 remove unneeded dontwarn settings
Some of these -dontwarn settings were added because r8 did not have access to transitive dependencies. Now these dependencies are passed as -libraryjars we can remove some of the -dontwarns.

Test: TARGET_BUILD_VARIANT=userdebug MODULE_BUILD_FROM_SOURCE=true \
  UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true \
  packages/modules/common/build/mainline_modules_arm64.sh -j120
Bug: 242088131
Change-Id: I408a8f3ac9d11c1bd6608f2a18fd2291db8c9275
2023-01-24 11:52:42 -05:00
Jared Duke
dd1fd79728 Ensure line numbers are preserved in default Proguard config
Explicitly keep the `LineNumberTable,SourceFile` attributes, ensuring
positional information is preserved for stack traces. While this isn't
required in R8's Proguard compat mode (still the default in soong), it
is needed for R8's full mode or when optimizations are enabled.

Bug: 215530220
Test: m
Change-Id: If1994e92f694c1a82317d79267714ad8114f3d99
2022-10-13 16:31:45 -07:00
Jared Duke
9d27a928f2 Only keep Parcelables if used
Use `-keepclassmembers` instead of `-keep` for Parcelable types
and their CREATOR members. This allows shrinking of Parcelable types
that aren't referenced while still preserving the necessary CREATOR
member when the classes are kept. This saves ~3MB across various
platform targets.

Bug: 238670321
Test: m + presubmit
Change-Id: I13508073dbc07e28aa93bb6604c8f838bcf72646
2022-09-19 16:26:44 -07:00
Jared Duke
3ca564b047 Suppress R8 warnings for support library annotations
Most of these annotations are stripped at dex compile-time, and are not
necessarily present in the generated dex library's classpath. As the
classpath is used to inform R8 about `libraryjars`, this can cause
reference failures during R8 execution when warnings are enabled.

For now, suppress the reference warnings. Unrecognized runtime-visible
annotations will still be kept, and this should unblock efforts to
re-enable R8 warnings for many platform targets. A proper solution will
be to ensure the appropriate annotation libs are fed as `-libraryjars`
to R8.

Bug: 242088131
Test: m + `optimize { ignore_warnings: false }`
Change-Id: Ie92db2a9725ff520b311c6b66a50feae79463925
2022-08-16 08:49:36 -07:00
Treehugger Robot
55d24aeb4c Merge "Ensure runtime-visible annotations are kept" 2022-07-28 15:58:28 +00:00
Jared Duke
3837a945b7 Ensure runtime-visible annotations are kept
With R8 full mode, these annotations must be explicitly kept as
attributes. Also keep annotation defaults as they may be used at
runtime.

Test: m + presubmit
Bug: 215530220
Change-Id: Ibab630cd8498c5789ebcad6785fda24967df4d61
2022-07-25 16:56:09 -07:00
zhidou
12fdb34299 Keep proguard fields for lite runtime of jarjared class
Some targets rename protobuf.MessageLite with jarjar rules. This change
adds keep rules to keep the fields of renamed classes.

Bug: 233746531
Test: m checkbuild.
Change-Id: Ib487dbd35f69654489aa28577afb47b9fb87c6f6
Merged-In: I986f05455b45651749fb5f819661041d7399f683
2022-07-13 13:09:09 +00:00
Jared Duke
df60c0bb14 Update default system Proguard config rules
Use the `includedescriptorclasses` modifier with the native keep rules
to ensure native method signatures remain preserved. This matches
common native Proguard rules used elsewhere.

Bug: 196084106
Test: m + presubmit
Change-Id: Ie413459ad0f65ce6b8cd6eb34318494c12568c5e
2022-02-07 10:54:51 -08:00
Colin Cross
7a9acce4ec Keep proguard fields for lite runtime
The lite proto runtime uses reflection to access fields based on the names in
the schema, keep all the fields.

Bug: 117607748
Bug: 140062984
Test: m checkbuild
Change-Id: I39bc7d28f619dd2ccaee603e4d407aa7ad33f534
Merged-In: I39bc7d28f619dd2ccaee603e4d407aa7ad33f534
2019-09-05 14:42:14 -07:00
Luca Stefani
765d2aed94 Remove unsupported option from R8 flags
See I71cd2d0e54f24c61043ac0a67df0a22c1e74deb3

Bug: 112338230
Change-Id: Ia4f19555fb86464c19d3e9cd07cba1870b215181
2019-04-22 20:00:37 +00:00
Colin Cross
e75840fe4d Add default proguard flags from guava
Guava 27.1 causes some warnings in R8, silence them.

Bug: 130306229
Test: m checkbuild
Change-Id: Ia9948d597538a16c5b7ab26a2e41eebde52e7427
Merged-In: Ia9948d597538a16c5b7ab26a2e41eebde52e7427
Exempt-From-Owner-Approval: cherry pick
(cherry picked from commit b4917146aa)
2019-04-15 21:44:50 -07:00
Colin Cross
2ac9c6219a Remove obsolete proguard flags
R8 now warns:
Warning in ./build/make/core/proguard_basic_keeps.flags:
  Ignoring option: -optimizations

Remove the flags, they are not used by R8.

Fixes: 123401079
Test: m checkbuild
Change-Id: I8b0c558be8bcf943652dddb71802ddc145ae42c1
2019-01-25 21:30:13 +00:00
Ying Wang
480a9bb64e Keep Throwable's constructor that takes a String argument.
Bug: 20495321
Change-Id: Iaf041da325e1d31f136f36e8ed85b2d90c578b0e
2015-05-11 14:56:20 -07:00
Ying Wang
4f5d0e60b4 Raise SDK version for ProGuard processing when app links support library.
When an app's LOCAL_SDK_VERSION is lower than the support library's
LOCAL_SDK_VERSION,  we artifically raises the "SDK version" "linked"
by ProGuard, to
- suppress ProGuard warnings of referencing symbols unknown to the
  lower SDK version.
- prevent ProGuard stripping subclass in the support library that
  extends class added in the higher SDK version.

This allows us to remove the dangerous ProGuard flag
"-dontwarn android.support.**".

Notes:
- We don't raise the app's LOCAL_SDK_VERSION, so that the app's own
  code is still unable to use the higher SDK version.
- For platform build, we can't just raise to the "current" SDK,
  because would break apps that use APIs removed from the current SDK.
  We raise it to framework.jar instead, which contains the most complete
  symbol set.

Bug: 20658265
Change-Id: I90099073457a65cb8031fbaec6b396d68ce614a7
(cherry picked from commit 8e8d1e7aba)
2015-05-05 17:35:12 +00:00
Ying Wang
f864d502ab Less spammy ProGuard.
Change-Id: I465921b878c4ed6ec5d564704801e435d1aaa63c
2014-06-17 11:53:31 -07:00
Scott Kennedy
62eb51af23 Keep Parcelable CREATOR fields
Change-Id: I64451134a9d11d17307ef4d8ea923df5fe5e37ed
2014-04-07 11:50:23 -07:00
Ying Wang
e391e7a86e Remove -allowaccessmodification from the basic Proguard flags
It seems with that flag Proguard modifies the class files in a way that
Dalvik does not like.
Bug: 10307364

Change-Id: If0cc7552da00ae8a3a3a39a9f2f029819ca3164a
2013-08-13 17:40:24 -07:00
Ying Wang
38cdd4429f Tweak proguard flags in the 2 files.
So all most commonly-used flags go to proguard_basic_keeps.flags
and they will still be applied when LOCAL_PROGUARD_ENABLED=nosystem.
Bug: 9203442

Change-Id: If018076dc625ac1efe31898b179dbba850218aaf
2013-06-12 11:04:49 -07:00
Ying Wang
5745351908 Split out proguard_basic_keeps.flags
For 'LOCAL_PROGUARD_ENABLED := nosystem' we still include
proguard_basic_keeps.flags.

Change-Id: I43ee7e98d2aaeb84879441f90ab6839c0e8f4e65
2013-05-17 10:02:00 -07:00