diff options
author | Evgenii Stepanov <eugenis@google.com> | 2017-01-27 15:44:44 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-06-07 04:54:01 +0000 |
commit | fe9bc1dccb6cb8a92d5442c8a93a8f4dc30c2453 (patch) | |
tree | 68da387403e4876fceacef39e8a0fbec57861844 | |
parent | 8cede07e698cc1a15257a6b5dd653488e2bbf49e (diff) | |
download | build_soong-fe9bc1dccb6cb8a92d5442c8a93a8f4dc30c2453.tar.gz build_soong-fe9bc1dccb6cb8a92d5442c8a93a8f4dc30c2453.tar.bz2 build_soong-fe9bc1dccb6cb8a92d5442c8a93a8f4dc30c2453.zip |
Fix -fsanitize=integer not passed for soong builds.
Also filter out -Wl,--no-undefined for all host sanitizers, not just ASan.
UBSan on host defaults to no-trap (i.e. diagnostic mode), and that requires
the runtime library and runs into the same problem with undefined symbols as ASan.
Bug: 34719251
Test: Misc_undefined: ["integer"] on a soong target
Change-Id: I1fb4781f663a11f5f427d50c0bf9beb8e181cd5e
-rw-r--r-- | cc/sanitize.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go index 18d6c16e..0ccde976 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -203,8 +203,8 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { // TODO(ccross): error for compile_multilib = "32"? } - if Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || - Bool(s.Thread) || Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) { + if ctx.Os() != android.Windows && (Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || Bool(s.Thread) || + Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) || len(s.Misc_undefined) > 0) { sanitize.Properties.SanitizerEnabled = true } @@ -299,9 +299,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { // libraries needed with -fsanitize=address. http://b/18650275 (WAI) flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread") flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed") - // Host ASAN only links symbols in the final executable, so - // there will always be undefined symbols in intermediate libraries. - _, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags) } else { flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0") flags.DynamicLinker = "/system/bin/linker_asan" @@ -351,6 +348,9 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all") flags.LdFlags = append(flags.LdFlags, sanitizeArg) flags.LdFlags = append(flags.LdFlags, "-lrt", "-ldl") + // Host sanitizers only link symbols in the final executable, so + // there will always be undefined symbols in intermediate libraries. + _, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags) } else { flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort") } |