Disable FORTIFY for fuzzer builds.

Disables FORTIFY for fuzz target builds. We generally build with a
sanitizer and want the sanitizer to handle the bugs and provide us with
a nice stack trace.

Bug: 140187921
Test: m example_fuzzer && $ANDROID_HOST_OUT/fuzz/example_fuzzer (note
that you get a proper ASan report instead of a fortify crash)

Change-Id: I15a117b26c401a03785fb44c0f796588f366bc55
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 192b8d9..72c0ecb 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -475,6 +475,12 @@
 		// TODO(b/133876586): Experimental PM breaks sanitizer coverage.
 		_, flags.CFlags = removeFromList("-fexperimental-new-pass-manager", flags.CFlags)
 		flags.CFlags = append(flags.CFlags, "-fno-experimental-new-pass-manager")
+
+		// Disable fortify for fuzzing builds. Generally, we'll be building with
+		// UBSan or ASan here and the fortify checks pollute the stack traces.
+		_, flags.CFlags = removeFromList("-D_FORTIFY_SOURCE=1", flags.CFlags)
+		_, flags.CFlags = removeFromList("-D_FORTIFY_SOURCE=2", flags.CFlags)
+		flags.CFlags = append(flags.CFlags, "-U_FORTIFY_SOURCE")
 	}
 
 	if Bool(sanitize.Properties.Sanitize.Cfi) {