Update flags to match make

Change-Id: I8ba24723d5b507fa178255c124b11356719700cb
diff --git a/cc/arm64_device.go b/cc/arm64_device.go
index 201c0f2..887e1a4 100644
--- a/cc/arm64_device.go
+++ b/cc/arm64_device.go
@@ -21,7 +21,6 @@
 		"-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 @@
 		"-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 b935348..58553b2 100644
--- a/cc/arm_device.go
+++ b/cc/arm_device.go
@@ -22,7 +22,6 @@
 		"-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 @@
 	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 2ade59c..f918087 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -97,7 +97,10 @@
 
 	commonGlobalCppflags = []string{
 		"-Wsign-promo",
-		"-std=gnu++11",
+	}
+
+	illegalFlags = []string{
+		"-w",
 	}
 )
 
@@ -560,6 +563,20 @@
 
 	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 @@
 			} 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 347efbe..92061f3 100644
--- a/cc/clang.go
+++ b/cc/clang.go
@@ -10,10 +10,13 @@
 	"-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 @@
 
 	// mips + mips64
 	"-msynci",
+	"-mno-synci",
 	"-mno-fused-madd",
 
 	// x86 + x86_64
@@ -70,6 +74,7 @@
 
 		// 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 bed977d..be40933 100644
--- a/cc/x86_darwin_host.go
+++ b/cc/x86_darwin_host.go
@@ -14,7 +14,6 @@
 
 		"-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 @@
 	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 b39c0b4..8f24b05 100644
--- a/cc/x86_linux_host.go
+++ b/cc/x86_linux_host.go
@@ -16,11 +16,9 @@
 
 		"-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 @@
 		"-mfpmath=sse",
 		"-m32",
 		"-march=prescott",
+		"-D_FILE_OFFSET_BITS=64",
+		"-D_LARGEFILE_SOURCE=1",
 	}
 
 	linuxX8664Cflags = []string{
@@ -55,11 +55,13 @@
 	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{