Merge "Add android/uapi kernel header."
diff --git a/android/androidmk.go b/android/androidmk.go
index 8d2951d..7d7707f 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -146,7 +146,7 @@
 	}
 
 	if data.SubName != "" {
-		name += "_" + data.SubName
+		name += data.SubName
 	}
 
 	if data.Custom != nil {
diff --git a/android/config.go b/android/config.go
index 0f65410..ae04756 100644
--- a/android/config.go
+++ b/android/config.go
@@ -20,6 +20,7 @@
 	"os"
 	"path/filepath"
 	"runtime"
+	"strconv"
 	"strings"
 	"sync"
 
@@ -278,7 +279,7 @@
 }
 
 func (c *config) PlatformSdkVersion() string {
-	return "22"
+	return strconv.Itoa(*c.ProductVariables.Platform_sdk_version)
 }
 
 func (c *config) BuildNumber() string {
diff --git a/android/defs.go b/android/defs.go
index be28e8b..9c6527d 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -52,6 +52,13 @@
 		},
 		"cpFlags")
 
+	// A timestamp touch rule.
+	Touch = pctx.StaticRule("Touch",
+		blueprint.RuleParams{
+			Command:     "touch $out",
+			Description: "touch $out",
+		})
+
 	// A symlink rule.
 	Symlink = pctx.StaticRule("Symlink",
 		blueprint.RuleParams{
diff --git a/android/variable.go b/android/variable.go
index a2313d5..b0639ae 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -115,7 +115,7 @@
 
 func (v *productVariables) SetDefaultConfig() {
 	*v = productVariables{
-		Platform_sdk_version:       intPtr(22),
+		Platform_sdk_version:       intPtr(23),
 		HostArch:                   stringPtr("x86_64"),
 		HostSecondaryArch:          stringPtr("x86"),
 		DeviceName:                 stringPtr("flounder"),
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 7f18155..70e1f47 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -134,7 +134,7 @@
 func (test *testBinaryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
 	test.binaryLinker.AndroidMk(ctx, ret)
 	if Bool(test.testLinker.Properties.Test_per_src) {
-		ret.SubName = test.binaryLinker.Properties.Stem
+		ret.SubName = "_" + test.binaryLinker.Properties.Stem
 	}
 }
 
diff --git a/cc/cc.go b/cc/cc.go
index 89f40b3..b5545fc 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -193,7 +193,7 @@
 		if override := config.(android.Config).Getenv("LLVM_PREBUILTS_VERSION"); override != "" {
 			return override, nil
 		}
-		return "clang-2812033", nil
+		return "clang-3016494", nil
 	})
 	pctx.StaticVariable("clangPath", "${clangBase}/${HostPrebuiltTag}/${clangVersion}")
 	pctx.StaticVariable("clangBin", "${clangPath}/bin")
diff --git a/cc/clang.go b/cc/clang.go
index e9dca32..be2bfe1 100644
--- a/cc/clang.go
+++ b/cc/clang.go
@@ -88,6 +88,9 @@
 		// Force clang to always output color diagnostics. Ninja will strip the ANSI
 		// color codes if it is not running in a terminal.
 		"-fcolor-diagnostics",
+
+		// http://b/29823425 Disable -Wexpansion-to-defined for Clang update to r271374
+		"-Wno-expansion-to-defined",
 	}, " "))
 
 	pctx.StaticVariable("clangExtraConlyflags", strings.Join([]string{
@@ -98,6 +101,10 @@
 		// Disable -Winconsistent-missing-override until we can clean up the existing
 		// codebase for it.
 		"-Wno-inconsistent-missing-override",
+
+		// Bug: http://b/29823425 Disable -Wnull-dereference until the
+		// new instances detected by this warning are fixed.
+		"-Wno-null-dereference",
 	}, " "))
 
 	pctx.StaticVariable("clangExtraTargetCflags", strings.Join([]string{
@@ -106,7 +113,10 @@
 
 	pctx.StaticVariable("clangExtraNoOverrideCflags", strings.Join([]string{
 		"-Werror=address-of-temporary",
-		"-Werror=null-dereference",
+		// Bug: http://b/29823425 Disable -Wnull-dereference until the
+		// new cases detected by this warning in Clang r271374 are
+		// fixed.
+		//"-Werror=null-dereference",
 		"-Werror=return-type",
 	}, " "))
 }
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 172aae7..08ffff4 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -141,9 +141,10 @@
 			ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0])
 		}
 	}
-	if Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) ||
-		Bool(s.Thread) || Bool(s.Coverage) || Bool(s.Safestack) {
-		sanitize.Properties.SanitizerEnabled = true
+
+	if ctx.staticBinary() {
+		s.Address = nil
+		s.Thread = nil
 	}
 
 	if Bool(s.All_undefined) {
@@ -157,6 +158,11 @@
 		// TODO(ccross): error for compile_multilib = "32"?
 	}
 
+	if Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) ||
+		Bool(s.Thread) || Bool(s.Coverage) || Bool(s.Safestack) {
+		sanitize.Properties.SanitizerEnabled = true
+	}
+
 	if Bool(s.Coverage) {
 		if !Bool(s.Address) {
 			ctx.ModuleErrorf(`Use of "coverage" also requires "address"`)