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..c206675fe 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -45,9 +45,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..5c050fa5a 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -42,9 +42,7 @@ var ( "-fomit-frame-pointer", } - armCppflags = []string{ - "-fvisibility-inlines-hidden", - } + armCppflags = []string{} armLdflags = []string{ "-Wl,--icf=safe", diff --git a/cc/config/global.go b/cc/config/global.go index de4fa116c..92cd98b4c 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -71,6 +71,10 @@ var ( "-Werror=format-security", } + deviceGlobalCppflags = []string{ + "-fvisibility-inlines-hidden", + } + deviceGlobalLdflags = []string{ "-Wl,-z,noexecstack", "-Wl,-z,relro", @@ -83,6 +87,8 @@ var ( hostGlobalCflags = []string{} + hostGlobalCppflags = []string{} + hostGlobalLdflags = []string{} commonGlobalCppflags = []string{ @@ -122,8 +128,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..9b5d4d91d 100644 --- a/cc/config/mips64_device.go +++ b/cc/config/mips64_device.go @@ -40,9 +40,7 @@ var ( "-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..a8c48b4b6 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -38,9 +38,7 @@ var ( "-fintegrated-as", }...) - mipsCppflags = []string{ - "-fvisibility-inlines-hidden", - } + mipsCppflags = []string{} mipsLdflags = []string{ "-Wl,--allow-shlib-undefined", 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{