Merge "Revert "[cc_fuzz] Revert 'disable LTO' patches."" am: 5c8693f5d7 am: 3807ca1cdf am: eafe37dfb7

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2004383

Change-Id: I3d5f6c2a9e539d0a9942d5c50471987dc4e887d7
This commit is contained in:
Treehugger Robot 2022-03-02 06:29:00 +00:00 committed by Automerger Merge Worker
commit 787bf8a5f4
2 changed files with 18 additions and 0 deletions

View file

@ -82,6 +82,12 @@ func (lto *lto) useClangLld(ctx BaseModuleContext) bool {
}
func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
// TODO(b/131771163): Disable LTO when using explicit fuzzing configurations.
// LTO breaks fuzzer builds.
if inList("-fsanitize=fuzzer-no-link", flags.Local.CFlags) {
return flags
}
if lto.LTO(ctx) {
var ltoCFlag string
var ltoLdFlag string

View file

@ -541,6 +541,12 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s.Address = nil
s.Thread = nil
}
// TODO(b/131771163): CFI transiently depends on LTO, and thus Fuzzer is
// mutually incompatible.
if Bool(s.Fuzzer) {
s.Cfi = nil
}
}
func toDisableImplicitIntegerChange(flags []string) bool {
@ -635,6 +641,12 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
if Bool(sanitize.Properties.Sanitize.Fuzzer) {
flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize=fuzzer-no-link")
// TODO(b/131771163): LTO and Fuzzer support is mutually incompatible.
_, flags.Local.LdFlags = removeFromList("-flto", flags.Local.LdFlags)
_, flags.Local.CFlags = removeFromList("-flto", flags.Local.CFlags)
flags.Local.LdFlags = append(flags.Local.LdFlags, "-fno-lto")
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-lto")
// TODO(b/142430592): Upstream linker scripts for sanitizer runtime libraries
// discard the sancov_lowest_stack symbol, because it's emulated TLS (and thus
// doesn't match the linker script due to the "__emutls_v." prefix).