Merge changes from topic 'std'
* changes: Allow disabling gnu extensions Consolidate -std flags
This commit is contained in:
@@ -84,6 +84,9 @@ type BaseCompilerProperties struct {
|
|||||||
// pass -frtti instead of -fno-rtti
|
// pass -frtti instead of -fno-rtti
|
||||||
Rtti *bool
|
Rtti *bool
|
||||||
|
|
||||||
|
// if set to false, use -std=c++* instead of -std=gnu++*
|
||||||
|
Gnu_extensions *bool
|
||||||
|
|
||||||
Debug, Release struct {
|
Debug, Release struct {
|
||||||
// list of module-specific flags that will be used for C and C++ compiles in debug or
|
// list of module-specific flags that will be used for C and C++ compiles in debug or
|
||||||
// release builds
|
// release builds
|
||||||
@@ -278,13 +281,27 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.sdk() {
|
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
|
// The host GCC doesn't support C++14 (and is deprecated, so likely
|
||||||
// never will). Build these modules with C++11.
|
// never will). Build these modules with C++11.
|
||||||
flags.CppFlags = append(flags.CppFlags, "-std=gnu++11")
|
cppStd = config.GccCppStdVersion
|
||||||
} else {
|
|
||||||
flags.CppFlags = append(flags.CppFlags, "-std=gnu++14")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can enforce some rules more strictly in the code we own. strict
|
// We can enforce some rules more strictly in the code we own. strict
|
||||||
@@ -306,6 +323,8 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var gnuToCReplacer = strings.NewReplacer("gnu", "c")
|
||||||
|
|
||||||
func ndkPathDeps(ctx ModuleContext) android.Paths {
|
func ndkPathDeps(ctx ModuleContext) android.Paths {
|
||||||
if ctx.sdk() {
|
if ctx.sdk() {
|
||||||
// The NDK sysroot timestamp file depends on all the NDK sysroot files
|
// The NDK sysroot timestamp file depends on all the NDK sysroot files
|
||||||
|
@@ -37,9 +37,7 @@ var (
|
|||||||
"-UDEBUG",
|
"-UDEBUG",
|
||||||
}
|
}
|
||||||
|
|
||||||
commonGlobalConlyflags = []string{
|
commonGlobalConlyflags = []string{}
|
||||||
"-std=gnu99",
|
|
||||||
}
|
|
||||||
|
|
||||||
deviceGlobalCflags = []string{
|
deviceGlobalCflags = []string{
|
||||||
"-fdiagnostics-color",
|
"-fdiagnostics-color",
|
||||||
@@ -66,6 +64,10 @@ var (
|
|||||||
IllegalFlags = []string{
|
IllegalFlags = []string{
|
||||||
"-w",
|
"-w",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStdVersion = "gnu99"
|
||||||
|
CppStdVersion = "gnu++14"
|
||||||
|
GccCppStdVersion = "gnu++11"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pctx = android.NewPackageContext("android/soong/cc/config")
|
var pctx = android.NewPackageContext("android/soong/cc/config")
|
||||||
|
@@ -48,6 +48,10 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
|
||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", asanLibs)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", asanLibs)
|
||||||
|
|
||||||
|
ctx.Strict("DEFAULT_C_STD_VERSION", config.CStdVersion)
|
||||||
|
ctx.Strict("DEFAULT_CPP_STD_VERSION", config.CppStdVersion)
|
||||||
|
ctx.Strict("DEFAULT_GCC_CPP_STD_VERSION", config.GccCppStdVersion)
|
||||||
|
|
||||||
includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes} ${config.CommonGlobalSystemIncludes}")
|
includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes} ${config.CommonGlobalSystemIncludes}")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Reference in New Issue
Block a user