From 3bf6b472299efa1a0e666010d68351bae949f826 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 11 Sep 2015 17:41:10 -0700 Subject: [PATCH] Update flags to match make Change-Id: I8ba24723d5b507fa178255c124b11356719700cb --- cc/arm64_device.go | 2 +- cc/arm_device.go | 2 +- cc/cc.go | 23 ++++++++++++++++++++++- cc/clang.go | 5 +++++ cc/x86_darwin_host.go | 3 ++- cc/x86_linux_host.go | 8 +++++--- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/cc/arm64_device.go b/cc/arm64_device.go index 201c0f212..887e1a4ca 100644 --- a/cc/arm64_device.go +++ b/cc/arm64_device.go @@ -21,7 +21,6 @@ var ( "-fno-short-enums", "-no-canonical-prefixes", "-fno-canonical-system-headers", - "-include ${SrcDir}/build/core/combo/include/arch/linux-arm64/AndroidConfig.h", // Help catch common 32/64-bit errors. "-Werror=pointer-to-int-cast", @@ -47,6 +46,7 @@ var ( "-Wl,--fatal-warnings", "-Wl,-maarch64linux", "-Wl,--hash-style=gnu", + "-Wl,--fix-cortex-a53-843419", // Disable transitive dependency library symbol resolving. "-Wl,--allow-shlib-undefined", diff --git a/cc/arm_device.go b/cc/arm_device.go index b9353481b..58553b2bd 100644 --- a/cc/arm_device.go +++ b/cc/arm_device.go @@ -22,7 +22,6 @@ var ( "-fno-short-enums", "-no-canonical-prefixes", "-fno-canonical-system-headers", - "-include ${SrcDir}/build/core/combo/include/arch/linux-arm/AndroidConfig.h", "-fno-builtin-sin", "-fno-strict-volatile-bitfields", @@ -130,6 +129,7 @@ func init() { replaceFirst(armClangArchVariantCflags["armv5te"], "-march=armv5te", "-march=armv5t") armClangCpuVariantCflags["krait"] = []string{ "-mcpu=krait", + "-mfpu=neon-vfpv4", } pctx.StaticVariable("armGccVersion", "4.9") diff --git a/cc/cc.go b/cc/cc.go index 2ade59cc1..f91808703 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -97,7 +97,10 @@ var ( commonGlobalCppflags = []string{ "-Wsign-promo", - "-std=gnu++11", + } + + illegalFlags = []string{ + "-w", } ) @@ -560,6 +563,20 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha flags = c.ccModuleType().flags(ctx, flags) + if c.Properties.Sdk_version == "" { + if ctx.Host() && !flags.Clang { + // The host GCC doesn't support C++14 (and is deprecated, so likely + // never will). Build these modules with C++11. + flags.CppFlags = append(flags.CppFlags, "-std=gnu++11") + } else { + flags.CppFlags = append(flags.CppFlags, "-std=gnu++14") + } + } + + flags.CFlags, _ = filterList(flags.CFlags, illegalFlags) + flags.CppFlags, _ = filterList(flags.CppFlags, illegalFlags) + flags.ConlyFlags, _ = filterList(flags.ConlyFlags, illegalFlags) + // Optimization to reduce size of build.ninja // Replace the long list of flags for each file with a module-local variable ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " ")) @@ -822,6 +839,10 @@ func (c *CCLinked) flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlags } else { flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs...) } + } else { + if ctx.Arch().ArchType == common.Arm { + flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,libunwind_llvm.a") + } } case "stlport", "stlport_static": if ctx.Device() { diff --git a/cc/clang.go b/cc/clang.go index 347efbe08..92061f3c2 100644 --- a/cc/clang.go +++ b/cc/clang.go @@ -10,10 +10,13 @@ var clangUnknownCflags = []string{ "-finline-functions", "-finline-limit=64", "-fno-canonical-system-headers", + "-Wno-clobbered", + "-fno-devirtualize", "-fno-tree-sra", "-fprefetch-loop-arrays", "-funswitch-loops", "-Wmaybe-uninitialized", + "-Wno-error=clobbered", "-Wno-error=maybe-uninitialized", "-Wno-error=unused-but-set-parameter", "-Wno-error=unused-but-set-variable", @@ -50,6 +53,7 @@ var clangUnknownCflags = []string{ // mips + mips64 "-msynci", + "-mno-synci", "-mno-fused-madd", // x86 + x86_64 @@ -70,6 +74,7 @@ func init() { // Disable overly aggressive warning for macros defined with a leading underscore // This happens in AndroidConfig.h, which is included nearly everywhere. + // TODO: can we remove this now? "-Wno-reserved-id-macro", // Disable overly aggressive warning for format strings. diff --git a/cc/x86_darwin_host.go b/cc/x86_darwin_host.go index bed977d41..be4093343 100644 --- a/cc/x86_darwin_host.go +++ b/cc/x86_darwin_host.go @@ -14,7 +14,6 @@ var ( "-fPIC", "-funwind-tables", - "-include ${SrcDir}/build/core/combo/include/arch/darwin-x86/AndroidConfig.h", // Workaround differences in inttypes.h between host and target. //See bug 12708004. @@ -52,11 +51,13 @@ var ( darwinX86Ldflags = []string{ "-m32", "-Wl,-rpath,@loader_path/../lib", + "-Wl,-rpath,@loader_path/lib", } darwinX8664Ldflags = []string{ "-m64", "-Wl,-rpath,@loader_path/../lib64", + "-Wl,-rpath,@loader_path/lib64", } darwinClangCflags = append([]string{ diff --git a/cc/x86_linux_host.go b/cc/x86_linux_host.go index b39c0b483..8f24b056a 100644 --- a/cc/x86_linux_host.go +++ b/cc/x86_linux_host.go @@ -16,11 +16,9 @@ var ( "-fPIC", "-no-canonical-prefixes", - "-include ${SrcDir}/build/core/combo/include/arch/linux-x86/AndroidConfig.h", - // TODO: Set _FORTIFY_SOURCE=2. Bug 20558757. "-U_FORTIFY_SOURCE", - "-D_FORTIFY_SOURCE=0", + "-D_FORTIFY_SOURCE=2", "-fstack-protector", // Workaround differences in inttypes.h between host and target. @@ -46,6 +44,8 @@ var ( "-mfpmath=sse", "-m32", "-march=prescott", + "-D_FILE_OFFSET_BITS=64", + "-D_LARGEFILE_SOURCE=1", } linuxX8664Cflags = []string{ @@ -55,11 +55,13 @@ var ( linuxX86Ldflags = []string{ "-m32", `-Wl,-rpath,\$$ORIGIN/../lib`, + `-Wl,-rpath,\$$ORIGIN/lib`, } linuxX8664Ldflags = []string{ "-m64", `-Wl,-rpath,\$$ORIGIN/../lib64`, + `-Wl,-rpath,\$$ORIGIN/lib64`, } linuxClangCflags = append([]string{