aboutsummaryrefslogtreecommitdiffstats
path: root/cc/sanitize.go
diff options
context:
space:
mode:
authorJayant Chowdhary <jchowdhary@google.com>2017-06-15 14:45:18 -0700
committerJayant Chowdhary <jchowdhary@google.com>2017-06-19 19:43:03 -0700
commit9677e8c6adbede1b661703521b45827d1abb58db (patch)
tree4513c0e16d609b3bdd5c1b6bc88bd4fe82e2fd5c /cc/sanitize.go
parentf47b0487822dac28e72d2af18ed3692732bac9f0 (diff)
downloadbuild_soong-9677e8c6adbede1b661703521b45827d1abb58db.tar.gz
build_soong-9677e8c6adbede1b661703521b45827d1abb58db.tar.bz2
build_soong-9677e8c6adbede1b661703521b45827d1abb58db.zip
Black-list for clang LibTooling Cflags.
Add a list of flags which are not understood by clang LibTooling tools and filter them out of the Cflags the tools are invoked with. Test: In frameworks/av, make libmedia vendor_available (this invokes header-abi-dumper on this module), mm -j64. Bug: 62447349 Change-Id: I46f017212b89f4331145c999103d0ed44da0abaf
Diffstat (limited to 'cc/sanitize.go')
-rw-r--r--cc/sanitize.go34
1 files changed, 19 insertions, 15 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go
index dfd86f08..b847c6f3 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -25,17 +25,21 @@ import (
"android/soong/cc/config"
)
-const (
- asanCflags = "-fno-omit-frame-pointer"
- asanLdflags = "-Wl,-u,__asan_preinit"
- asanLibs = "libasan"
+var (
+ // Any C flags added by sanitizer which libTooling tools may not
+ // understand also need to be added to ClangLibToolingUnknownCflags in
+ // cc/config/clang.go
+
+ asanCflags = []string{"-fno-omit-frame-pointer"}
+ asanLdflags = []string{"-Wl,-u,__asan_preinit"}
+ asanLibs = []string{"libasan"}
- cfiCflags = "-flto -fsanitize-cfi-cross-dso -fvisibility=default " +
- "-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"
+ cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso", "-fvisibility=default",
+ "-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
// FIXME: revert the __cfi_check flag when clang is updated to r280031.
- cfiLdflags = "-flto -fsanitize-cfi-cross-dso -fsanitize=cfi " +
- "-Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check"
- cfiArflags = "--plugin ${config.ClangBin}/../lib64/LLVMgold.so"
+ cfiLdflags = []string{"-flto", "-fsanitize-cfi-cross-dso", "-fsanitize=cfi",
+ "-Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check"}
+ cfiArflags = []string{"--plugin ${config.ClangBin}/../lib64/LLVMgold.so"}
)
type sanitizerType int
@@ -232,7 +236,7 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
if ctx.Device() {
if Bool(sanitize.Properties.Sanitize.Address) {
- deps.StaticLibs = append(deps.StaticLibs, asanLibs)
+ deps.StaticLibs = append(deps.StaticLibs, asanLibs...)
}
if Bool(sanitize.Properties.Sanitize.Address) || Bool(sanitize.Properties.Sanitize.Thread) {
deps.SharedLibs = append(deps.SharedLibs, "libdl")
@@ -300,8 +304,8 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
// TODO: put in flags?
flags.RequiredInstructionSet = "arm"
}
- flags.CFlags = append(flags.CFlags, asanCflags)
- flags.LdFlags = append(flags.LdFlags, asanLdflags)
+ flags.CFlags = append(flags.CFlags, asanCflags...)
+ flags.LdFlags = append(flags.LdFlags, asanLdflags...)
if ctx.Host() {
// -nodefaultlibs (provided with libc++) prevents the driver from linking
@@ -337,9 +341,9 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, "-march=armv7-a")
}
sanitizers = append(sanitizers, "cfi")
- flags.CFlags = append(flags.CFlags, cfiCflags)
- flags.LdFlags = append(flags.LdFlags, cfiLdflags)
- flags.ArFlags = append(flags.ArFlags, cfiArflags)
+ flags.CFlags = append(flags.CFlags, cfiCflags...)
+ flags.LdFlags = append(flags.LdFlags, cfiLdflags...)
+ flags.ArFlags = append(flags.ArFlags, cfiArflags...)
if Bool(sanitize.Properties.Sanitize.Diag.Cfi) {
diagSanitizers = append(diagSanitizers, "cfi")
}