Update flags to match make

Change-Id: I8ba24723d5b507fa178255c124b11356719700cb
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() {