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
(cherry picked from commit bdad314f97)
Merged-In: Ic0eef29598c1ee47e958da8a5048d9696165a235
This commit is contained in:
Remi NGUYEN VAN
2022-08-04 13:19:03 +09:00
committed by Cherrypicker Worker
parent c4d437c6bf
commit 4987e7e397
2 changed files with 37 additions and 1 deletions

View File

@@ -42,6 +42,9 @@ type DexProperties struct {
// True if the module containing this has it set by default.
EnabledByDefault bool `blueprint:"mutated"`
// Whether to continue building even if warnings are emitted. Defaults to true.
Ignore_warnings *bool
// If true, runs R8 in Proguard compatibility mode (default).
// Otherwise, runs R8 in full mode.
Proguard_compatibility *bool
@@ -293,7 +296,10 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
}
// TODO(b/180878971): missing classes should be added to the relevant builds.
r8Flags = append(r8Flags, "-ignorewarnings")
// TODO(b/229727645): do not use true as default for Android platform builds.
if proptools.BoolDefault(opt.Ignore_warnings, true) {
r8Flags = append(r8Flags, "-ignorewarnings")
}
return r8Flags, r8Deps
}