From bc6fb16b26dedee0e9f10239cb9a6c8a3e647b04 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 24 May 2016 15:39:04 -0700 Subject: [PATCH] Support sanitizer variants inside make builds Create both sanitized and unsanitized variants inside make builds with sanitizers enabled. Only export the sanitized version to make, and always install the sanitized version in /data to match the make build. Change-Id: I5a17bcbddc7a9d871c929c84d3c116228ef3258f --- cc/androidmk.go | 5 +++++ cc/cc.go | 20 +------------------- cc/sanitize.go | 17 +++++++---------- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/cc/androidmk.go b/cc/androidmk.go index 103d5ea6d..a661c6c28 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -24,6 +24,11 @@ import ( ) func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) { + if c.Properties.HideFromMake { + ret.Disabled = true + return ret, nil + } + ret.OutputFile = c.outputFile ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) (err error) { fmt.Fprintln(w, "LOCAL_SANITIZE := never") diff --git a/cc/cc.go b/cc/cc.go index d5f17a84a..0fa3ca975 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -427,6 +427,7 @@ type BaseProperties struct { No_default_compiler_flags *bool AndroidMkSharedLibs []string `blueprint:"mutated"` + HideFromMake bool `blueprint:"mutated"` } type InstallerProperties struct { @@ -992,20 +993,6 @@ func (c *Module) InstallInData() bool { return c.installer.inData() } -type appendVariantName interface { - appendVariantName(string) -} - -func (c *Module) appendVariantName(name string) { - if c.linker == nil { - return - } - - if l, ok := c.linker.(appendVariantName); ok { - l.appendVariantName(name) - } -} - // Compiler type baseCompiler struct { @@ -1476,7 +1463,6 @@ type libraryLinker struct { } var _ linker = (*libraryLinker)(nil) -var _ appendVariantName = (*libraryLinker)(nil) func (library *libraryLinker) props() []interface{} { props := library.baseLinker.props() @@ -1667,10 +1653,6 @@ func (library *libraryLinker) installable() bool { return !library.static() } -func (library *libraryLinker) appendVariantName(variant string) { - library.Properties.VariantName += variant -} - type libraryInstaller struct { baseInstaller diff --git a/cc/sanitize.go b/cc/sanitize.go index 4162e97ad..1bc1351b3 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -335,17 +335,14 @@ func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) { modules[0].(*Module).sanitize.Properties.InData = true } } else if c.sanitize.Properties.SanitizeDep { + modules := mctx.CreateVariations("", t.String()) + modules[0].(*Module).sanitize.SetSanitizer(t, false) + modules[1].(*Module).sanitize.SetSanitizer(t, true) + modules[0].(*Module).sanitize.Properties.SanitizeDep = false + modules[1].(*Module).sanitize.Properties.SanitizeDep = false + modules[1].(*Module).sanitize.Properties.InData = true if mctx.AConfig().EmbeddedInMake() { - modules := mctx.CreateVariations(t.String()) - modules[0].(*Module).sanitize.SetSanitizer(t, true) - modules[0].(*Module).sanitize.Properties.InData = true - } else { - modules := mctx.CreateVariations("", t.String()) - modules[0].(*Module).sanitize.SetSanitizer(t, false) - modules[1].(*Module).sanitize.SetSanitizer(t, true) - modules[1].(*Module).appendVariantName("_" + t.String()) - modules[0].(*Module).sanitize.Properties.SanitizeDep = false - modules[1].(*Module).sanitize.Properties.SanitizeDep = false + modules[0].(*Module).Properties.HideFromMake = true } } c.sanitize.Properties.SanitizeDep = false