summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2022-02-08 20:33:43 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-02-08 20:33:43 +0000
commit3e7f5c411dfed43cb08f7b4a4c0d5220cdcd3c8c (patch)
tree8ccc02886f5f48eb8094e7cf5e3ff31f37138d9f
parentcb1703d8b1287d654f61e7e60eaa545203fbd964 (diff)
parent234b01de96a439e44bd993ac3824f435dcfddc42 (diff)
Merge "Use -fno-sanitize-link-runtime for bionic sanitizers"
-rw-r--r--cc/sanitize.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 6c6882217..b8e1468e4 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -705,19 +705,22 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
if len(sanitize.Properties.Sanitizers) > 0 {
sanitizeArg := "-fsanitize=" + strings.Join(sanitize.Properties.Sanitizers, ",")
-
flags.Local.CFlags = append(flags.Local.CFlags, sanitizeArg)
flags.Local.AsFlags = append(flags.Local.AsFlags, sanitizeArg)
- if ctx.Host() {
+ flags.Local.LdFlags = append(flags.Local.LdFlags, sanitizeArg)
+
+ if ctx.toolchain().Bionic() {
+ // Bionic sanitizer runtimes have already been added as dependencies so that
+ // the right variant of the runtime will be used (with the "-android"
+ // suffix), so don't let clang the runtime library.
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-fno-sanitize-link-runtime")
+ } else {
// Host sanitizers only link symbols in the final executable, so
// there will always be undefined symbols in intermediate libraries.
_, flags.Global.LdFlags = removeFromList("-Wl,--no-undefined", flags.Global.LdFlags)
- flags.Local.LdFlags = append(flags.Local.LdFlags, sanitizeArg)
- // non-Bionic toolchain prebuilts are missing UBSan's vptr and function sanitizers
- if !ctx.toolchain().Bionic() {
- flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=vptr,function")
- }
+ // non-Bionic toolchain prebuilts are missing UBSan's vptr and function san
+ flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=vptr,function")
}
if enableMinimalRuntime(sanitize) {