Support sanitizer builds inside make
am: 30d5f514dd
* commit '30d5f514dd1b43366440d6aff0b53124de5dd7b5':
Support sanitizer builds inside make
Change-Id: I839262ee6f1abcbba9a0dc6f3cca75671b79c799
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
func (c *Module) AndroidMk() (ret common.AndroidMkData, err error) {
|
||||
ret.OutputFile = c.outputFile
|
||||
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) (err error) {
|
||||
fmt.Fprintln(w, "LOCAL_SANITIZE := never")
|
||||
if len(c.Properties.AndroidMkSharedLibs) > 0 {
|
||||
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
|
||||
}
|
||||
|
8
cc/cc.go
8
cc/cc.go
@@ -1482,7 +1482,7 @@ func (library *libraryLinker) flags(ctx ModuleContext, flags Flags) Flags {
|
||||
flags.Nocrt = Bool(library.Properties.Nocrt)
|
||||
|
||||
if !library.static() {
|
||||
libName := ctx.ModuleName()
|
||||
libName := ctx.ModuleName() + library.Properties.VariantName
|
||||
// GCC for Android assumes that -shared means -Bsymbolic, use -Wl,-shared instead
|
||||
sharedFlag := "-Wl,-shared"
|
||||
if flags.Clang || ctx.Host() {
|
||||
@@ -1664,6 +1664,7 @@ type libraryInstaller struct {
|
||||
baseInstaller
|
||||
|
||||
linker *libraryLinker
|
||||
sanitize *sanitize
|
||||
}
|
||||
|
||||
func (library *libraryInstaller) install(ctx ModuleContext, file common.Path) {
|
||||
@@ -1672,6 +1673,10 @@ func (library *libraryInstaller) install(ctx ModuleContext, file common.Path) {
|
||||
}
|
||||
}
|
||||
|
||||
func (library *libraryInstaller) inData() bool {
|
||||
return library.baseInstaller.inData() || library.sanitize.inData()
|
||||
}
|
||||
|
||||
func NewLibrary(hod common.HostOrDeviceSupported, shared, static bool) *Module {
|
||||
module := newModule(hod, common.MultilibBoth)
|
||||
|
||||
@@ -1689,6 +1694,7 @@ func NewLibrary(hod common.HostOrDeviceSupported, shared, static bool) *Module {
|
||||
dir64: "lib64",
|
||||
},
|
||||
linker: linker,
|
||||
sanitize: module.sanitize,
|
||||
}
|
||||
|
||||
return module
|
||||
|
@@ -69,6 +69,7 @@ type SanitizeProperties struct {
|
||||
|
||||
SanitizerEnabled bool `blueprint:"mutated"`
|
||||
SanitizeDep bool `blueprint:"mutated"`
|
||||
InData bool `blueprint:"mutated"`
|
||||
}
|
||||
|
||||
type sanitize struct {
|
||||
@@ -266,6 +267,10 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
||||
return flags
|
||||
}
|
||||
|
||||
func (sanitize *sanitize) inData() bool {
|
||||
return sanitize.Properties.InData
|
||||
}
|
||||
|
||||
func (sanitize *sanitize) Sanitizer(t sanitizerType) bool {
|
||||
if sanitize == nil {
|
||||
return false
|
||||
@@ -314,8 +319,17 @@ func sanitizerMutator(t sanitizerType) func(common.AndroidBottomUpMutatorContext
|
||||
return func(mctx common.AndroidBottomUpMutatorContext) {
|
||||
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
|
||||
if d, ok := c.linker.(baseLinkerInterface); ok && d.isDependencyRoot() && c.sanitize.Sanitizer(t) {
|
||||
mctx.CreateVariations(t.String())
|
||||
modules := mctx.CreateVariations(t.String())
|
||||
modules[0].(*Module).sanitize.SetSanitizer(t, true)
|
||||
if mctx.AConfig().EmbeddedInMake() {
|
||||
modules[0].(*Module).sanitize.Properties.InData = true
|
||||
}
|
||||
} else if c.sanitize.Properties.SanitizeDep {
|
||||
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)
|
||||
@@ -323,6 +337,7 @@ func sanitizerMutator(t sanitizerType) func(common.AndroidBottomUpMutatorContext
|
||||
modules[0].(*Module).sanitize.Properties.SanitizeDep = false
|
||||
modules[1].(*Module).sanitize.Properties.SanitizeDep = false
|
||||
}
|
||||
}
|
||||
c.sanitize.Properties.SanitizeDep = false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user