Consolidate global cflags

Move all the flags that are used everywhere (or should be used
everywhere) into cc/config/global.go:
-no-canonical-prefixes
-fno-exceptions
-Wno-multichar
-O2
-g
-fno-strict-aliasing

Also remove flags that are already in noOverrideGlobalCflags:
-Werror=pointer-to-int-cast
-Werror=int-to-pointer-cast

x86 and x86_64 were specifying -fstrict-aliasing, but that was
being overriden later by -fno-strict-aliasing, so remove it.
ARM devices still override -fno-strict-aliasing to -fstrict-aliasing
when using ARM (vs. Thumb) instruction set.

Bug: 68855788
Test: m checkbuild
Change-Id: Ia2b5891bdefb60f974ad92b4b84a8548c2dcc7dc
This commit is contained in:
Colin Cross
2017-11-02 22:38:32 -07:00
parent f9e621603b
commit 7278afc5a8
11 changed files with 11 additions and 88 deletions

View File

@@ -23,9 +23,6 @@ import (
var ( var (
arm64Cflags = []string{ arm64Cflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fno-strict-aliasing",
"-fstack-protector-strong", "-fstack-protector-strong",
"-ffunction-sections", "-ffunction-sections",
"-fdata-sections", "-fdata-sections",
@@ -34,19 +31,14 @@ var (
"-Werror=format-security", "-Werror=format-security",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
"-fno-short-enums", "-fno-short-enums",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
// Help catch common 32/64-bit errors. // Help catch common 32/64-bit errors.
"-Werror=pointer-to-int-cast",
"-Werror=int-to-pointer-cast",
"-Werror=implicit-function-declaration", "-Werror=implicit-function-declaration",
"-fno-strict-volatile-bitfields", "-fno-strict-volatile-bitfields",
// TARGET_RELEASE_CFLAGS // TARGET_RELEASE_CFLAGS
"-DNDEBUG",
"-O2 -g",
"-Wstrict-aliasing=2", "-Wstrict-aliasing=2",
"-fgcse-after-reload", "-fgcse-after-reload",
"-frerun-cse-after-loop", "-frerun-cse-after-loop",

View File

@@ -28,8 +28,6 @@ var (
} }
armCflags = []string{ armCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-ffunction-sections", "-ffunction-sections",
"-fdata-sections", "-fdata-sections",
"-funwind-tables", "-funwind-tables",
@@ -38,15 +36,12 @@ var (
"-Werror=format-security", "-Werror=format-security",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
"-fno-short-enums", "-fno-short-enums",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
"-fno-builtin-sin", "-fno-builtin-sin",
"-fno-strict-volatile-bitfields", "-fno-strict-volatile-bitfields",
// TARGET_RELEASE_CFLAGS // TARGET_RELEASE_CFLAGS
"-DNDEBUG",
"-g",
"-Wstrict-aliasing=2", "-Wstrict-aliasing=2",
"-fgcse-after-reload", "-fgcse-after-reload",
"-frerun-cse-after-loop", "-frerun-cse-after-loop",
@@ -71,7 +66,6 @@ var (
} }
armArmCflags = []string{ armArmCflags = []string{
"-O2",
"-fomit-frame-pointer", "-fomit-frame-pointer",
"-fstrict-aliasing", "-fstrict-aliasing",
"-funswitch-loops", "-funswitch-loops",
@@ -81,7 +75,6 @@ var (
"-mthumb", "-mthumb",
"-Os", "-Os",
"-fomit-frame-pointer", "-fomit-frame-pointer",
"-fno-strict-aliasing",
} }
armArchVariantCflags = map[string][]string{ armArchVariantCflags = map[string][]string{

View File

@@ -34,9 +34,19 @@ var (
"-Winit-self", "-Winit-self",
"-Wpointer-arith", "-Wpointer-arith",
// COMMON_RELEASE_CFLAGS // Make paths in deps files relative
"-no-canonical-prefixes",
"-DNDEBUG", "-DNDEBUG",
"-UDEBUG", "-UDEBUG",
"-fno-exceptions",
"-Wno-multichar",
"-O2",
"-g",
"-fno-strict-aliasing",
} }
commonGlobalConlyflags = []string{} commonGlobalConlyflags = []string{}

View File

@@ -22,11 +22,7 @@ import (
var ( var (
mips64Cflags = []string{ mips64Cflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-O2",
"-fomit-frame-pointer", "-fomit-frame-pointer",
"-fno-strict-aliasing",
"-funswitch-loops", "-funswitch-loops",
"-Umips", "-Umips",
"-ffunction-sections", "-ffunction-sections",
@@ -36,17 +32,12 @@ var (
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-Werror=format-security", "-Werror=format-security",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
// Help catch common 32/64-bit errors. // Help catch common 32/64-bit errors.
"-Werror=pointer-to-int-cast",
"-Werror=int-to-pointer-cast",
"-Werror=implicit-function-declaration", "-Werror=implicit-function-declaration",
// TARGET_RELEASE_CFLAGS // TARGET_RELEASE_CFLAGS
"-DNDEBUG",
"-g",
"-Wstrict-aliasing=2", "-Wstrict-aliasing=2",
"-fgcse-after-reload", "-fgcse-after-reload",
"-frerun-cse-after-loop", "-frerun-cse-after-loop",

View File

@@ -22,11 +22,7 @@ import (
var ( var (
mipsCflags = []string{ mipsCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-O2",
"-fomit-frame-pointer", "-fomit-frame-pointer",
"-fno-strict-aliasing",
"-funswitch-loops", "-funswitch-loops",
"-Umips", "-Umips",
"-ffunction-sections", "-ffunction-sections",
@@ -36,12 +32,9 @@ var (
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-Werror=format-security", "-Werror=format-security",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
// TARGET_RELEASE_CFLAGS // TARGET_RELEASE_CFLAGS
"-DNDEBUG",
"-g",
"-Wstrict-aliasing=2", "-Wstrict-aliasing=2",
"-fgcse-after-reload", "-fgcse-after-reload",
"-frerun-cse-after-loop", "-frerun-cse-after-loop",

View File

@@ -22,9 +22,6 @@ import (
var ( var (
x86_64Cflags = []string{ x86_64Cflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-O2",
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-Werror=format-security", "-Werror=format-security",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
@@ -33,22 +30,13 @@ var (
"-finline-functions", "-finline-functions",
"-finline-limit=300", "-finline-limit=300",
"-fno-short-enums", "-fno-short-enums",
"-fstrict-aliasing",
"-funswitch-loops", "-funswitch-loops",
"-funwind-tables", "-funwind-tables",
"-fstack-protector-strong", "-fstack-protector-strong",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
// Help catch common 32/64-bit errors. // Help catch common 32/64-bit errors.
"-Werror=pointer-to-int-cast",
"-Werror=int-to-pointer-cast",
"-Werror=implicit-function-declaration", "-Werror=implicit-function-declaration",
// TARGET_RELEASE_CFLAGS from build/core/combo/select.mk
"-O2",
"-g",
"-fno-strict-aliasing",
} }
x86_64Cppflags = []string{} x86_64Cppflags = []string{}

View File

@@ -25,9 +25,6 @@ import (
var ( var (
darwinCflags = []string{ darwinCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fdiagnostics-color", "-fdiagnostics-color",
"-fPIC", "-fPIC",
@@ -38,10 +35,6 @@ var (
"-D__STDC_FORMAT_MACROS", "-D__STDC_FORMAT_MACROS",
"-D__STDC_CONSTANT_MACROS", "-D__STDC_CONSTANT_MACROS",
// HOST_RELEASE_CFLAGS
"-O2", // from build/core/combo/select.mk
"-g", // from build/core/combo/select.mk
"-fno-strict-aliasing", // from build/core/combo/select.mk
"-isysroot ${macSdkRoot}", "-isysroot ${macSdkRoot}",
"-mmacosx-version-min=${macMinVersion}", "-mmacosx-version-min=${macMinVersion}",
"-DMACOSX_DEPLOYMENT_TARGET=${macMinVersion}", "-DMACOSX_DEPLOYMENT_TARGET=${macMinVersion}",

View File

@@ -22,9 +22,6 @@ import (
var ( var (
x86Cflags = []string{ x86Cflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-O2",
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-Werror=format-security", "-Werror=format-security",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
@@ -33,17 +30,10 @@ var (
"-finline-functions", "-finline-functions",
"-finline-limit=300", "-finline-limit=300",
"-fno-short-enums", "-fno-short-enums",
"-fstrict-aliasing",
"-funswitch-loops", "-funswitch-loops",
"-funwind-tables", "-funwind-tables",
"-fstack-protector-strong", "-fstack-protector-strong",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
// TARGET_RELEASE_CFLAGS from build/core/combo/select.mk
"-O2",
"-g",
"-fno-strict-aliasing",
} }
x86ClangCflags = append(x86Cflags, []string{ x86ClangCflags = append(x86Cflags, []string{

View File

@@ -22,15 +22,11 @@ import (
var ( var (
linuxBionicCflags = ClangFilterUnknownCflags([]string{ linuxBionicCflags = ClangFilterUnknownCflags([]string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fdiagnostics-color", "-fdiagnostics-color",
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-fPIC", "-fPIC",
"-no-canonical-prefixes",
"-U_FORTIFY_SOURCE", "-U_FORTIFY_SOURCE",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
@@ -43,14 +39,8 @@ var (
"-fno-short-enums", "-fno-short-enums",
"-funswitch-loops", "-funswitch-loops",
"-funwind-tables", "-funwind-tables",
"-no-canonical-prefixes",
"-fno-canonical-system-headers", "-fno-canonical-system-headers",
// HOST_RELEASE_CFLAGS
"-O2", // from build/core/combo/select.mk
"-g", // from build/core/combo/select.mk
"-fno-strict-aliasing", // from build/core/combo/select.mk
// Tell clang where the gcc toolchain is // Tell clang where the gcc toolchain is
"--gcc-toolchain=${LinuxBionicGccRoot}", "--gcc-toolchain=${LinuxBionicGccRoot}",

View File

@@ -22,15 +22,11 @@ import (
var ( var (
linuxCflags = []string{ linuxCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fdiagnostics-color", "-fdiagnostics-color",
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-fPIC", "-fPIC",
"-no-canonical-prefixes",
"-U_FORTIFY_SOURCE", "-U_FORTIFY_SOURCE",
"-D_FORTIFY_SOURCE=2", "-D_FORTIFY_SOURCE=2",
@@ -40,11 +36,6 @@ var (
//See bug 12708004. //See bug 12708004.
"-D__STDC_FORMAT_MACROS", "-D__STDC_FORMAT_MACROS",
"-D__STDC_CONSTANT_MACROS", "-D__STDC_CONSTANT_MACROS",
// HOST_RELEASE_CFLAGS
"-O2", // from build/core/combo/select.mk
"-g", // from build/core/combo/select.mk
"-fno-strict-aliasing", // from build/core/combo/select.mk
} }
linuxLdflags = []string{ linuxLdflags = []string{

View File

@@ -22,9 +22,6 @@ import (
var ( var (
windowsCflags = []string{ windowsCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-DUSE_MINGW", "-DUSE_MINGW",
"-DWIN32_LEAN_AND_MEAN", "-DWIN32_LEAN_AND_MEAN",
"-Wno-unused-parameter", "-Wno-unused-parameter",
@@ -43,11 +40,6 @@ var (
"-D_FILE_OFFSET_BITS=64", "-D_FILE_OFFSET_BITS=64",
"--sysroot ${WindowsGccRoot}/${WindowsGccTriple}", "--sysroot ${WindowsGccRoot}/${WindowsGccTriple}",
// HOST_RELEASE_CFLAGS
"-O2", // from build/core/combo/select.mk
"-g", // from build/core/combo/select.mk
"-fno-strict-aliasing", // from build/core/combo/select.mk
} }
windowsIncludeFlags = []string{ windowsIncludeFlags = []string{