summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2023-06-06 17:13:20 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-06-06 17:13:20 +0000
commit2976fa1185488d13b6742f97b38ba886d7cc49bd (patch)
tree9bc5e433d199a97b8c959326f2ba81ab130afc00
parentaefd27fce656292f83f5e34d94b6f53860c20b4a (diff)
parented79fa382b3b8a3411440e317679f7a961b2cdac (diff)
Merge "Use a less hacky way to detect if a module is Fuzzer enabled"
-rw-r--r--cc/cc.go12
-rw-r--r--cc/lto.go2
2 files changed, 13 insertions, 1 deletions
diff --git a/cc/cc.go b/cc/cc.go
index c9f00e248..2bfb372ed 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -524,6 +524,7 @@ type ModuleContextIntf interface {
isAfdoCompile() bool
isPgoCompile() bool
isCfi() bool
+ isFuzzer() bool
isNDKStubLibrary() bool
useClangLld(actx ModuleContext) bool
isForPlatform() bool
@@ -1365,6 +1366,13 @@ func (c *Module) isCfi() bool {
return false
}
+func (c *Module) isFuzzer() bool {
+ if sanitize := c.sanitize; sanitize != nil {
+ return Bool(sanitize.Properties.SanitizeMutated.Fuzzer)
+ }
+ return false
+}
+
func (c *Module) isNDKStubLibrary() bool {
if _, ok := c.compiler.(*stubDecorator); ok {
return true
@@ -1660,6 +1668,10 @@ func (ctx *moduleContextImpl) isCfi() bool {
return ctx.mod.isCfi()
}
+func (ctx *moduleContextImpl) isFuzzer() bool {
+ return ctx.mod.isFuzzer()
+}
+
func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
return ctx.mod.isNDKStubLibrary()
}
diff --git a/cc/lto.go b/cc/lto.go
index a8bed235f..8d6e3e771 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -74,7 +74,7 @@ func (lto *lto) begin(ctx BaseModuleContext) {
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) {
+ if ctx.isFuzzer() {
return flags
}