From 6be405ef69e47a8be194dabb2b9ac92db35afc57 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Thu, 19 Oct 2017 15:52:11 -0700 Subject: [PATCH] Support tsan in Android.bp. Bug: http://b/25392375 Test: build a unit test with tsan. Change-Id: Ifbd30e41e3a9558a8f106750c2a08778db5d5c81 --- cc/sanitize.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cc/sanitize.go b/cc/sanitize.go index b8b5ffa56..74f4bdbb3 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -342,6 +342,10 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { diagSanitizers = append(diagSanitizers, "address") } + if Bool(sanitize.Properties.Sanitize.Thread) { + sanitizers = append(sanitizers, "thread") + } + if Bool(sanitize.Properties.Sanitize.Coverage) { flags.CFlags = append(flags.CFlags, "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp") } @@ -408,6 +412,8 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { runtimeLibrary := "" if Bool(sanitize.Properties.Sanitize.Address) { runtimeLibrary = config.AddressSanitizerRuntimeLibrary(ctx.toolchain()) + } else if Bool(sanitize.Properties.Sanitize.Thread) { + runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(ctx.toolchain()) } else if len(diagSanitizers) > 0 { runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(ctx.toolchain()) }