diff --git a/cc/compiler.go b/cc/compiler.go index 268a6637b..4112930ae 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -318,6 +318,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags) flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...) + flags.CppFlags = append([]string{fmt.Sprintf("${config.%sGlobalCppflags}", hod)}, flags.CppFlags...) if flags.Clang { flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags()) diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index 13e9a08ba..5bb7749a8 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -23,18 +23,8 @@ import ( var ( arm64Cflags = []string{ - "-fdata-sections", - "-fno-short-enums", - // Help catch common 32/64-bit errors. "-Werror=implicit-function-declaration", - - "-fno-strict-volatile-bitfields", - - // TARGET_RELEASE_CFLAGS - "-fgcse-after-reload", - "-frerun-cse-after-loop", - "-frename-registers", } arm64Ldflags = []string{ @@ -45,9 +35,7 @@ var ( "-Wl,--icf=safe", } - arm64Cppflags = []string{ - "-fvisibility-inlines-hidden", - } + arm64Cppflags = []string{} arm64CpuVariantCflags = map[string][]string{ "cortex-a53": []string{ diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 670396971..0f28d1e28 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -28,23 +28,10 @@ var ( } armCflags = []string{ - "-fdata-sections", - "-fno-short-enums", - - "-fno-builtin-sin", - "-fno-strict-volatile-bitfields", - - // TARGET_RELEASE_CFLAGS - "-fgcse-after-reload", - "-frerun-cse-after-loop", - "-frename-registers", - "-fomit-frame-pointer", } - armCppflags = []string{ - "-fvisibility-inlines-hidden", - } + armCppflags = []string{} armLdflags = []string{ "-Wl,--icf=safe", @@ -54,7 +41,6 @@ var ( armArmCflags = []string{ "-fstrict-aliasing", - "-funswitch-loops", } armThumbCflags = []string{ diff --git a/cc/config/global.go b/cc/config/global.go index de4fa116c..44ad30b43 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -56,6 +56,8 @@ var ( "-fdiagnostics-color", "-ffunction-sections", + "-fdata-sections", + "-fno-short-enums", "-funwind-tables", "-fstack-protector-strong", "-Wa,--noexecstack", @@ -71,6 +73,10 @@ var ( "-Werror=format-security", } + deviceGlobalCppflags = []string{ + "-fvisibility-inlines-hidden", + } + deviceGlobalLdflags = []string{ "-Wl,-z,noexecstack", "-Wl,-z,relro", @@ -83,6 +89,8 @@ var ( hostGlobalCflags = []string{} + hostGlobalCppflags = []string{} + hostGlobalLdflags = []string{} commonGlobalCppflags = []string{ @@ -122,8 +130,10 @@ func init() { pctx.StaticVariable("CommonGlobalCflags", strings.Join(commonGlobalCflags, " ")) pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " ")) pctx.StaticVariable("DeviceGlobalCflags", strings.Join(deviceGlobalCflags, " ")) + pctx.StaticVariable("DeviceGlobalCppflags", strings.Join(deviceGlobalCppflags, " ")) pctx.StaticVariable("DeviceGlobalLdflags", strings.Join(deviceGlobalLdflags, " ")) pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " ")) + pctx.StaticVariable("HostGlobalCppflags", strings.Join(hostGlobalCppflags, " ")) pctx.StaticVariable("HostGlobalLdflags", strings.Join(hostGlobalLdflags, " ")) pctx.StaticVariable("NoOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " ")) diff --git a/cc/config/mips64_device.go b/cc/config/mips64_device.go index 487b11a1a..a6191b653 100644 --- a/cc/config/mips64_device.go +++ b/cc/config/mips64_device.go @@ -22,27 +22,17 @@ import ( var ( mips64Cflags = []string{ - "-fomit-frame-pointer", - "-funswitch-loops", "-Umips", - "-fdata-sections", // Help catch common 32/64-bit errors. "-Werror=implicit-function-declaration", - - // TARGET_RELEASE_CFLAGS - "-fgcse-after-reload", - "-frerun-cse-after-loop", - "-frename-registers", } mips64ClangCflags = append(mips64Cflags, []string{ "-fintegrated-as", }...) - mips64Cppflags = []string{ - "-fvisibility-inlines-hidden", - } + mips64Cppflags = []string{} mips64Ldflags = []string{ "-Wl,--allow-shlib-undefined", diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go index f178b978c..9709ada47 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -23,14 +23,7 @@ import ( var ( mipsCflags = []string{ "-fomit-frame-pointer", - "-funswitch-loops", "-Umips", - "-fdata-sections", - - // TARGET_RELEASE_CFLAGS - "-fgcse-after-reload", - "-frerun-cse-after-loop", - "-frename-registers", } mipsClangCflags = append(mipsCflags, []string{ @@ -38,9 +31,7 @@ var ( "-fintegrated-as", }...) - mipsCppflags = []string{ - "-fvisibility-inlines-hidden", - } + mipsCppflags = []string{} mipsLdflags = []string{ "-Wl,--allow-shlib-undefined", diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 1eab9dd65..12f3e6fa2 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -22,11 +22,6 @@ import ( var ( x86_64Cflags = []string{ - "-finline-functions", - "-finline-limit=300", - "-fno-short-enums", - "-funswitch-loops", - // Help catch common 32/64-bit errors. "-Werror=implicit-function-declaration", } diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go index 8aea64d9c..b9ce4af3e 100644 --- a/cc/config/x86_device.go +++ b/cc/config/x86_device.go @@ -21,12 +21,7 @@ import ( ) var ( - x86Cflags = []string{ - "-finline-functions", - "-finline-limit=300", - "-fno-short-enums", - "-funswitch-loops", - } + x86Cflags = []string{} x86ClangCflags = append(x86Cflags, []string{ "-msse3", diff --git a/cc/makevars.go b/cc/makevars.go index f84ae24e2..7befb1198 100644 --- a/cc/makevars.go +++ b/cc/makevars.go @@ -171,6 +171,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string, }, " ")) ctx.Strict(makePrefix+"GLOBAL_CPPFLAGS", strings.Join([]string{ "${config.CommonGlobalCppflags}", + fmt.Sprintf("${config.%sGlobalCppflags}", hod), toolchain.Cppflags(), }, " ")) ctx.Strict(makePrefix+"GLOBAL_LDFLAGS", strings.Join([]string{ @@ -217,6 +218,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string, }, " ")) ctx.Strict(clangPrefix+"GLOBAL_CPPFLAGS", strings.Join([]string{ "${config.CommonClangGlobalCppflags}", + fmt.Sprintf("${config.%sGlobalCppflags}", hod), toolchain.ClangCppflags(), }, " ")) ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{