diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-10-13 16:44:07 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2016-10-13 23:46:10 +0000 |
commit | cbceaab39cc246cc863e56366574b605147cec58 (patch) | |
tree | 6e4e9854d1c9b50684d037011b7b8a130fdcb758 | |
parent | 556566e5ad4c925d2f8785e6148e9efcb5e60033 (diff) | |
download | build_soong-cbceaab39cc246cc863e56366574b605147cec58.tar.gz build_soong-cbceaab39cc246cc863e56366574b605147cec58.tar.bz2 build_soong-cbceaab39cc246cc863e56366574b605147cec58.zip |
Export asan configuration to make
Test: Ninja files for ASAN'd aosp_flounder-eng identical
Change-Id: Ib29cac0bc391dadd9ff27992c7b356415182767f
-rw-r--r-- | cc/makevars.go | 4 | ||||
-rw-r--r-- | cc/sanitize.go | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/cc/makevars.go b/cc/makevars.go index 3dd0f745..098ec02c 100644 --- a/cc/makevars.go +++ b/cc/makevars.go @@ -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) diff --git a/cc/sanitize.go b/cc/sanitize.go index bb1a2ad6..2676373f 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -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()) |