Don't apply sanitizer mutators to host modules.

This CL blocks modules intended for the host from having the bottom up
sanitizer mutator applied. We only maintain a single copy of host
binaries, so generating variants doesn't make sense
anyway. Additionally, the existing logic was causing an error with
builds not embedded in make (eg: aosp-build-tools which uses
soong_ui.bash) where the wrong variant was installed on the host. This
change should fix that.

Bug: 64536751
Test: m -j40 && SANITIZE_TARGET="address" m -j40
Test: aosp-build-tools build breakage is fixed.
Change-Id: Ia79b4661f69ce26a7be17c4339c18ca0f397d760
This commit is contained in:
Vishwath Mohan 2017-08-10 11:05:00 -07:00
parent 46c6a171aa
commit bba1927bde

View file

@ -527,7 +527,7 @@ func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
// Create asan variants for modules that need them
func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
return func(mctx android.BottomUpMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil && !c.Host() {
if c.isDependencyRoot() && c.sanitize.isSanitizerExplicitlyEnabled(t) {
modules := mctx.CreateVariations(t.String())
modules[0].(*Module).sanitize.SetSanitizer(t, true)
@ -537,15 +537,8 @@ func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
modules[1].(*Module).sanitize.SetSanitizer(t, true)
modules[0].(*Module).sanitize.Properties.SanitizeDep = false
modules[1].(*Module).sanitize.Properties.SanitizeDep = false
if mctx.Device() {
modules[1].(*Module).sanitize.Properties.InSanitizerDir = true
} else {
if c.sanitize.isSanitizerExplicitlyEnabled(t) {
modules[0].(*Module).Properties.PreventInstall = true
} else {
modules[1].(*Module).Properties.PreventInstall = true
}
}
modules[1].(*Module).sanitize.Properties.InSanitizerDir = true
if mctx.AConfig().EmbeddedInMake() {
if c.sanitize.isSanitizerExplicitlyEnabled(t) {
modules[0].(*Module).Properties.HideFromMake = true