Reimplement ART_NDEBUG_OPT_FLAG
Use ART_NDEBUG_OPT_FLAG or ART_DEBUG_OPT_FLAG to override the default -O
compiler arguments.
Fixes: 31653144
Test: mmma -j art
Test: m -j dex2oat dex2oatd ART_NDEBUG_OPT_FLAG=-O1 ART_DEBUG_OPT_FLAG=-O0
Change-Id: I9d48d94f5e262148ddac5c70068144a645ac9566
diff --git a/build/art.go b/build/art.go
index ba5521a..0ae6c8f 100644
--- a/build/art.go
+++ b/build/art.go
@@ -30,6 +30,9 @@
var cflags []string
var asflags []string
+ opt := envDefault(ctx, "ART_NDEBUG_OPT_FLAG", "-O3")
+ cflags = append(cflags, opt)
+
tlab := false
gcType := envDefault(ctx, "ART_DEFAULT_GC_TYPE", "CMS")
@@ -75,6 +78,15 @@
return cflags, asflags
}
+func debugFlags(ctx android.BaseContext) []string {
+ var cflags []string
+
+ opt := envDefault(ctx, "ART_DEBUG_OPT_FLAG", "-O2")
+ cflags = append(cflags, opt)
+
+ return cflags
+}
+
func deviceFlags(ctx android.BaseContext) []string {
var cflags []string
deviceFrameSizeLimit := 1736
@@ -143,6 +155,16 @@
ctx.AppendProperties(p)
}
+func debugDefaults(ctx android.LoadHookContext) {
+ type props struct {
+ Cflags []string
+ }
+
+ p := &props{}
+ p.Cflags = debugFlags(ctx)
+ ctx.AppendProperties(p)
+}
+
func customLinker(ctx android.LoadHookContext) {
linker := envDefault(ctx, "CUSTOM_TARGET_LINKER", "")
if linker != "" {
@@ -206,6 +228,7 @@
soong.RegisterModuleType("art_cc_test_library", artTestLibrary)
soong.RegisterModuleType("art_cc_defaults", artDefaultsFactory)
soong.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory)
+ soong.RegisterModuleType("art_debug_defaults", artDebugDefaultsFactory)
}
func artGlobalDefaultsFactory() (blueprint.Module, []interface{}) {
@@ -215,6 +238,13 @@
return module, props
}
+func artDebugDefaultsFactory() (blueprint.Module, []interface{}) {
+ module, props := artDefaultsFactory()
+ android.AddLoadHook(module, debugDefaults)
+
+ return module, props
+}
+
func artDefaultsFactory() (blueprint.Module, []interface{}) {
c := &codegenProperties{}
module, props := cc.DefaultsFactory(c)