Export asan configuration to make

am: cbceaab39c

Change-Id: I04245d14e155c3ed1cadcc87ad14efebbb7f7954
This commit is contained in:
Dan Willemsen
2016-10-14 02:28:28 +00:00
committed by android-build-merger
2 changed files with 13 additions and 3 deletions

View File

@@ -44,6 +44,10 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", asanCflags)
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", asanLibs)
includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes} ${config.CommonGlobalSystemIncludes}")
if err != nil {
panic(err)

View File

@@ -24,6 +24,12 @@ import (
"android/soong/cc/config"
)
const (
asanCflags = "-fno-omit-frame-pointer"
asanLdflags = "-Wl,-u,__asan_preinit"
asanLibs = "libasan"
)
type sanitizerType int
func boolPtr(v bool) *bool {
@@ -175,7 +181,7 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
if ctx.Device() {
if Bool(sanitize.Properties.Sanitize.Address) {
deps.StaticLibs = append(deps.StaticLibs, "libasan")
deps.StaticLibs = append(deps.StaticLibs, asanLibs)
}
if Bool(sanitize.Properties.Sanitize.Address) || Bool(sanitize.Properties.Sanitize.Thread) {
deps.SharedLibs = append(deps.SharedLibs, "libdl")
@@ -236,8 +242,8 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
// TODO: put in flags?
flags.RequiredInstructionSet = "arm"
}
flags.CFlags = append(flags.CFlags, "-fno-omit-frame-pointer")
flags.LdFlags = append(flags.LdFlags, "-Wl,-u,__asan_preinit")
flags.CFlags = append(flags.CFlags, asanCflags)
flags.LdFlags = append(flags.LdFlags, asanLdflags)
// ASan runtime library must be the first in the link order.
runtimeLibrary := config.AddressSanitizerRuntimeLibrary(ctx.toolchain())