Consolidate -std flags
Define the default -std values in global.go, export them in makevars.go,
and use them in compiler.go.
Test: builds
Change-Id: Ia2ae01f63e182d0ad7f371e6d32184bff35a8897
diff --git a/cc/compiler.go b/cc/compiler.go
index 198b792..0e65c17 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -278,13 +278,22 @@
}
if !ctx.sdk() {
- if ctx.Host() && !flags.Clang {
+ cStd := config.CStdVersion
+ cppStd := config.CppStdVersion
+
+ if !flags.Clang {
+ // GCC uses an invalid C++14 ABI (emits calls to
+ // __cxa_throw_bad_array_length, which is not a valid C++ RT ABI).
+ // http://b/25022512
+ cppStd = config.GccCppStdVersion
+ } else if ctx.Host() && !flags.Clang {
// The host GCC doesn't support C++14 (and is deprecated, so likely
// never will). Build these modules with C++11.
- flags.CppFlags = append(flags.CppFlags, "-std=gnu++11")
- } else {
- flags.CppFlags = append(flags.CppFlags, "-std=gnu++14")
+ cppStd = config.GccCppStdVersion
}
+
+ flags.ConlyFlags = append([]string{"-std=" + cStd}, flags.ConlyFlags...)
+ flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...)
}
// We can enforce some rules more strictly in the code we own. strict