From 26f14509d13563c9ae52d433663ac302ba0c76cf Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 6 Nov 2017 13:59:48 -0800 Subject: [PATCH 1/3] Move -fvisibility-inlines-hidden to global device cppflags It was previously set on arm[64] and mips[64], this will cause it to be set for x86[_64] too. Bug: 68855788 Test: m checkbuild Change-Id: I75af16e7d259963ad633cc664929144332bb435d --- cc/compiler.go | 1 + cc/config/arm64_device.go | 4 +--- cc/config/arm_device.go | 4 +--- cc/config/global.go | 8 ++++++++ cc/config/mips64_device.go | 4 +--- cc/config/mips_device.go | 4 +--- cc/makevars.go | 2 ++ 7 files changed, 15 insertions(+), 12 deletions(-) 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{ From ea3141d06d611fdb3d9beb48dc0a0a30d944076c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 6 Nov 2017 14:02:02 -0800 Subject: [PATCH 2/3] Move some flags to affect all devices Move -fdata-sections and -fno-short-enums to global device flags. -fdata-sections was not previously set on x86[_64], -fno-short-enums was not previously set on mips[64]. Bug: 68855788 Test: m checkbuild Change-Id: I68e64888d5414fc022366eb2b6c5cd92c28a5542 --- cc/config/arm64_device.go | 3 --- cc/config/arm_device.go | 3 --- cc/config/global.go | 2 ++ cc/config/mips64_device.go | 1 - cc/config/mips_device.go | 1 - cc/config/x86_64_device.go | 1 - cc/config/x86_device.go | 1 - 7 files changed, 2 insertions(+), 10 deletions(-) diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index c206675fe..c3dd8e840 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -23,9 +23,6 @@ import ( var ( arm64Cflags = []string{ - "-fdata-sections", - "-fno-short-enums", - // Help catch common 32/64-bit errors. "-Werror=implicit-function-declaration", diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 5c050fa5a..1b09242e7 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -28,9 +28,6 @@ var ( } armCflags = []string{ - "-fdata-sections", - "-fno-short-enums", - "-fno-builtin-sin", "-fno-strict-volatile-bitfields", diff --git a/cc/config/global.go b/cc/config/global.go index 92cd98b4c..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", diff --git a/cc/config/mips64_device.go b/cc/config/mips64_device.go index 9b5d4d91d..97d6a7201 100644 --- a/cc/config/mips64_device.go +++ b/cc/config/mips64_device.go @@ -25,7 +25,6 @@ var ( "-fomit-frame-pointer", "-funswitch-loops", "-Umips", - "-fdata-sections", // Help catch common 32/64-bit errors. "-Werror=implicit-function-declaration", diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go index a8c48b4b6..9cd8b5fb0 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -25,7 +25,6 @@ var ( "-fomit-frame-pointer", "-funswitch-loops", "-Umips", - "-fdata-sections", // TARGET_RELEASE_CFLAGS "-fgcse-after-reload", diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 1eab9dd65..e461c457f 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -24,7 +24,6 @@ var ( x86_64Cflags = []string{ "-finline-functions", "-finline-limit=300", - "-fno-short-enums", "-funswitch-loops", // Help catch common 32/64-bit errors. diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go index 8aea64d9c..8fd65f7ac 100644 --- a/cc/config/x86_device.go +++ b/cc/config/x86_device.go @@ -24,7 +24,6 @@ var ( x86Cflags = []string{ "-finline-functions", "-finline-limit=300", - "-fno-short-enums", "-funswitch-loops", } From b37620f8704a2267e52317fe2e201d455a418cfe Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 6 Nov 2017 14:05:51 -0800 Subject: [PATCH 3/3] Remove gcc-specific optimizations These flags were added for gcc, but are always stripped out when compiling for clang. Since gcc is barely used, removed them. Bug: 68855788 Bug: 68947919 Test: m checkbuild Change-Id: Iae2bda9808dd9499848ce145ccdf71c4c490b80e --- cc/config/arm64_device.go | 7 ------- cc/config/arm_device.go | 9 --------- cc/config/mips64_device.go | 7 ------- cc/config/mips_device.go | 6 ------ cc/config/x86_64_device.go | 4 ---- cc/config/x86_device.go | 6 +----- 6 files changed, 1 insertion(+), 38 deletions(-) diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index c3dd8e840..5bb7749a8 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -25,13 +25,6 @@ var ( arm64Cflags = []string{ // 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{ diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 1b09242e7..0f28d1e28 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -28,14 +28,6 @@ var ( } armCflags = []string{ - "-fno-builtin-sin", - "-fno-strict-volatile-bitfields", - - // TARGET_RELEASE_CFLAGS - "-fgcse-after-reload", - "-frerun-cse-after-loop", - "-frename-registers", - "-fomit-frame-pointer", } @@ -49,7 +41,6 @@ var ( armArmCflags = []string{ "-fstrict-aliasing", - "-funswitch-loops", } armThumbCflags = []string{ diff --git a/cc/config/mips64_device.go b/cc/config/mips64_device.go index 97d6a7201..a6191b653 100644 --- a/cc/config/mips64_device.go +++ b/cc/config/mips64_device.go @@ -22,17 +22,10 @@ import ( var ( mips64Cflags = []string{ - "-fomit-frame-pointer", - "-funswitch-loops", "-Umips", // 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{ diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go index 9cd8b5fb0..9709ada47 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -23,13 +23,7 @@ import ( var ( mipsCflags = []string{ "-fomit-frame-pointer", - "-funswitch-loops", "-Umips", - - // TARGET_RELEASE_CFLAGS - "-fgcse-after-reload", - "-frerun-cse-after-loop", - "-frename-registers", } mipsClangCflags = append(mipsCflags, []string{ diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index e461c457f..12f3e6fa2 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -22,10 +22,6 @@ import ( var ( x86_64Cflags = []string{ - "-finline-functions", - "-finline-limit=300", - "-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 8fd65f7ac..b9ce4af3e 100644 --- a/cc/config/x86_device.go +++ b/cc/config/x86_device.go @@ -21,11 +21,7 @@ import ( ) var ( - x86Cflags = []string{ - "-finline-functions", - "-finline-limit=300", - "-funswitch-loops", - } + x86Cflags = []string{} x86ClangCflags = append(x86Cflags, []string{ "-msse3",