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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -25,9 +25,6 @@ import (
var (
darwinCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fdiagnostics-color",
"-fPIC",
@@ -38,10 +35,6 @@ var (
"-D__STDC_FORMAT_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}",
"-mmacosx-version-min=${macMinVersion}",
"-DMACOSX_DEPLOYMENT_TARGET=${macMinVersion}",

View File

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

View File

@@ -22,15 +22,11 @@ import (
var (
linuxBionicCflags = ClangFilterUnknownCflags([]string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fdiagnostics-color",
"-Wa,--noexecstack",
"-fPIC",
"-no-canonical-prefixes",
"-U_FORTIFY_SOURCE",
"-D_FORTIFY_SOURCE=2",
@@ -43,14 +39,8 @@ var (
"-fno-short-enums",
"-funswitch-loops",
"-funwind-tables",
"-no-canonical-prefixes",
"-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
"--gcc-toolchain=${LinuxBionicGccRoot}",

View File

@@ -22,15 +22,11 @@ import (
var (
linuxCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-fdiagnostics-color",
"-Wa,--noexecstack",
"-fPIC",
"-no-canonical-prefixes",
"-U_FORTIFY_SOURCE",
"-D_FORTIFY_SOURCE=2",
@@ -40,11 +36,6 @@ var (
//See bug 12708004.
"-D__STDC_FORMAT_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{

View File

@@ -22,9 +22,6 @@ import (
var (
windowsCflags = []string{
"-fno-exceptions", // from build/core/combo/select.mk
"-Wno-multichar", // from build/core/combo/select.mk
"-DUSE_MINGW",
"-DWIN32_LEAN_AND_MEAN",
"-Wno-unused-parameter",
@@ -43,11 +40,6 @@ var (
"-D_FILE_OFFSET_BITS=64",
"--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{