diff options
author | Manoj Gupta <manojgupta@google.com> | 2019-10-11 10:49:21 -0700 |
---|---|---|
committer | Manoj Gupta <manojgupta@chromium.org> | 2019-10-11 18:57:34 +0000 |
commit | c08e01d98e72f2e9dffd73a7fd3d011f2a251ac9 (patch) | |
tree | 955fd03ab874fd6b735a3d309d031afefd5723a0 /compiler_wrapper/sanitizer_flags.go | |
parent | 6ecb3475254b6ab7ab3be6a2f58abc2f2fdd3da8 (diff) | |
download | toolchain-utils-c08e01d98e72f2e9dffd73a7fd3d011f2a251ac9.tar.gz |
compiler_wrapper: Disable new pass manager with sanitizers+coverage.
Useing sanitizers and coverage together in new pass manager
causes clang to crash.
Avoid the crash by disabling new pass manager in these cases.
BUG=chromium:1013622
TEST=go test
Change-Id: Ifc787e9f288891e3e1b68c791f0ddaa508d8c816
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1856379
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/sanitizer_flags.go')
-rw-r--r-- | compiler_wrapper/sanitizer_flags.go | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/compiler_wrapper/sanitizer_flags.go b/compiler_wrapper/sanitizer_flags.go index 32f2cb78..fe8d1503 100644 --- a/compiler_wrapper/sanitizer_flags.go +++ b/compiler_wrapper/sanitizer_flags.go @@ -9,15 +9,20 @@ import ( ) func processSanitizerFlags(builder *commandBuilder) { + hasCoverageFlags := false hasSanitizeFlags := false hasSanitizeFuzzerFlags := false for _, arg := range builder.args { // TODO: This should probably be -fsanitize= to not match on // e.g. -fsanitize-blacklist - if arg.fromUser && strings.HasPrefix(arg.value, "-fsanitize") { - hasSanitizeFlags = true - if strings.Contains(arg.value, "fuzzer") { - hasSanitizeFuzzerFlags = true + if arg.fromUser { + if strings.HasPrefix(arg.value, "-fsanitize") { + hasSanitizeFlags = true + if strings.Contains(arg.value, "fuzzer") { + hasSanitizeFuzzerFlags = true + } + } else if arg.value == "-fprofile-instr-generate" { + hasCoverageFlags = true } } } @@ -39,12 +44,15 @@ func processSanitizerFlags(builder *commandBuilder) { } return arg.value }) - if hasSanitizeFuzzerFlags && builder.target.compilerType == clangType { - fuzzerFlagsToAdd := []string{ - // TODO: This flag should be removed once fuzzer works with new pass manager - "-fno-experimental-new-pass-manager", + if builder.target.compilerType == clangType { + // hasSanitizeFlags && hasCoverageFlags is to work around crbug.com/1013622 + if hasSanitizeFuzzerFlags || (hasSanitizeFlags && hasCoverageFlags) { + fuzzerFlagsToAdd := []string{ + // TODO: This flag should be removed once fuzzer works with new pass manager + "-fno-experimental-new-pass-manager", + } + builder.addPreUserArgs(fuzzerFlagsToAdd...) } - builder.addPreUserArgs(fuzzerFlagsToAdd...) } } } |