aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-02-16 17:15:19 -0800
committerElliott Hughes <enh@google.com>2018-02-20 15:27:45 +0000
commit5789ca9f28eb0580084be24cf27c34c66d1f5bdf (patch)
treed7fe0b97fd0590dcb999b8fe78829f0ee99450df /cc
parentf28e32a2a5f9cc7bdd39881024933e440b46c2eb (diff)
downloadbuild_soong-5789ca9f28eb0580084be24cf27c34c66d1f5bdf.tar.gz
build_soong-5789ca9f28eb0580084be24cf27c34c66d1f5bdf.tar.bz2
build_soong-5789ca9f28eb0580084be24cf27c34c66d1f5bdf.zip
Use the platform -std= for sdk_version.
Bug: http://b/72571399 Test: builds Change-Id: I294cfadb7de54b1ae648e02ac9af34ed7a7405d8
Diffstat (limited to 'cc')
-rw-r--r--cc/compiler.go65
-rw-r--r--cc/stl.go3
2 files changed, 32 insertions, 36 deletions
diff --git a/cc/compiler.go b/cc/compiler.go
index dd1cdeed..ef222854 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -397,45 +397,42 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainCflags())
}
- if !ctx.useSdk() {
- cStd := config.CStdVersion
- if String(compiler.Properties.C_std) == "experimental" {
- cStd = config.ExperimentalCStdVersion
- } else if String(compiler.Properties.C_std) != "" {
- cStd = String(compiler.Properties.C_std)
- }
-
- cppStd := String(compiler.Properties.Cpp_std)
- switch String(compiler.Properties.Cpp_std) {
- case "":
- cppStd = config.CppStdVersion
- case "experimental":
- cppStd = config.ExperimentalCppStdVersion
- case "c++17", "gnu++17":
- // Map c++17 and gnu++17 to their 1z equivalents, until 17 is finalized.
- cppStd = strings.Replace(String(compiler.Properties.Cpp_std), "17", "1z", 1)
- }
+ cStd := config.CStdVersion
+ if String(compiler.Properties.C_std) == "experimental" {
+ cStd = config.ExperimentalCStdVersion
+ } else if String(compiler.Properties.C_std) != "" {
+ cStd = String(compiler.Properties.C_std)
+ }
- 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.
- cppStd = config.GccCppStdVersion
- }
+ cppStd := String(compiler.Properties.Cpp_std)
+ switch String(compiler.Properties.Cpp_std) {
+ case "":
+ cppStd = config.CppStdVersion
+ case "experimental":
+ cppStd = config.ExperimentalCppStdVersion
+ case "c++17", "gnu++17":
+ // Map c++17 and gnu++17 to their 1z equivalents, until 17 is finalized.
+ cppStd = strings.Replace(String(compiler.Properties.Cpp_std), "17", "1z", 1)
+ }
- if compiler.Properties.Gnu_extensions != nil && *compiler.Properties.Gnu_extensions == false {
- cStd = gnuToCReplacer.Replace(cStd)
- cppStd = gnuToCReplacer.Replace(cppStd)
- }
+ 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
+ // The host GCC doesn't support C++14 (and is deprecated, so likely
+ // never will).
+ // Build these modules with C++11.
+ cppStd = config.GccCppStdVersion
+ }
- flags.ConlyFlags = append([]string{"-std=" + cStd}, flags.ConlyFlags...)
- flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...)
+ if compiler.Properties.Gnu_extensions != nil && *compiler.Properties.Gnu_extensions == false {
+ cStd = gnuToCReplacer.Replace(cStd)
+ cppStd = gnuToCReplacer.Replace(cppStd)
}
+ flags.ConlyFlags = append([]string{"-std=" + cStd}, flags.ConlyFlags...)
+ flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...)
+
if ctx.useVndk() {
flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
}
diff --git a/cc/stl.go b/cc/stl.go
index c5757cd0..2da64718 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -176,8 +176,7 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
ndkSrcRoot := android.PathForSource(ctx, "prebuilts/ndk/current/sources/cxx-stl/system/include")
flags.CFlags = append(flags.CFlags, "-isystem "+ndkSrcRoot.String())
case "ndk_libc++_shared", "ndk_libc++_static":
- // TODO(danalbert): This really shouldn't be here...
- flags.CppFlags = append(flags.CppFlags, "-std=c++11")
+ // Nothing.
case "":
// None or error.
if !ctx.toolchain().Bionic() {