Switch host native tests to -Og
This helps to reduce build artifact size significantly, by 1.33GB for
`m cts` in the `out` directory on aosp-main. This should also make them
a lot faster to run.
Also turns off unused-result warning. This analysis is not run on -O0,
leaving behind a ton of code that triggers this warning. Since it is not
an important warning for tests anyway, turn it off by default for tests.
Right now, -Og is just an alias for -O1 in Clang. If the debuggability
is affected due to this change, we can identify and disable the relevant
optimization pass in -Og.
Change-Id: I84383cbc05a53d89c322ecb3679320f1338542e6
Bug: 294796809
Test: presubmit
diff --git a/cc/test.go b/cc/test.go
index a96af31..007932e 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -277,7 +277,10 @@
flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_HAS_STD_STRING")
if ctx.Host() {
- flags.Local.CFlags = append(flags.Local.CFlags, "-O0", "-g")
+ flags.Local.CFlags = append([]string{"-Og", "-g"}, flags.Local.CFlags...)
+
+ // Turn off unused-result warning since it is not important for tests.
+ flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-error=unused-result")
switch ctx.Os() {
case android.Windows: