Merge "Add zip-apex"
diff --git a/android/arch.go b/android/arch.go
index 1637a47..bee09b0 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1080,7 +1080,6 @@
 		{"arm", "armv7-a-neon", "cortex-a73", []string{"armeabi-v7a"}},
 		{"arm", "armv7-a-neon", "cortex-a75", []string{"armeabi-v7a"}},
 		{"arm", "armv7-a-neon", "cortex-a76", []string{"armeabi-v7a"}},
-		{"arm", "armv7-a-neon", "denver", []string{"armeabi-v7a"}},
 		{"arm", "armv7-a-neon", "krait", []string{"armeabi-v7a"}},
 		{"arm", "armv7-a-neon", "kryo", []string{"armeabi-v7a"}},
 		{"arm", "armv7-a-neon", "kryo385", []string{"armeabi-v7a"}},
@@ -1089,7 +1088,6 @@
 		{"arm64", "armv8-a", "cortex-a53", []string{"arm64-v8a"}},
 		{"arm64", "armv8-a", "cortex-a72", []string{"arm64-v8a"}},
 		{"arm64", "armv8-a", "cortex-a73", []string{"arm64-v8a"}},
-		{"arm64", "armv8-a", "denver64", []string{"arm64-v8a"}},
 		{"arm64", "armv8-a", "kryo", []string{"arm64-v8a"}},
 		{"arm64", "armv8-a", "exynos-m1", []string{"arm64-v8a"}},
 		{"arm64", "armv8-a", "exynos-m2", []string{"arm64-v8a"}},
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 299799d..f98e1be 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -98,8 +98,7 @@
 		"kryo",
 		"kryo385",
 		"exynos-m1",
-		"exynos-m2",
-		"denver64")
+		"exynos-m2")
 
 	pctx.StaticVariable("arm64GccVersion", arm64GccVersion)
 
@@ -226,10 +225,7 @@
 
 	var extraLdflags string
 	switch arch.CpuVariant {
-	case "cortex-a53", "cortex-a72", "cortex-a73", "kryo", "exynos-m1", "exynos-m2",
-		// This variant might not need the workaround but leave it
-		// in the list since it has had the workaround on before.
-		"denver64":
+	case "cortex-a53", "cortex-a72", "cortex-a73", "kryo", "exynos-m1", "exynos-m2":
 		extraLdflags = "-Wl,--fix-cortex-a53-843419"
 	}
 
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index 29378c6..60bb91a 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -191,8 +191,7 @@
 		"kryo",
 		"kryo385",
 		"exynos-m1",
-		"exynos-m2",
-		"denver")
+		"exynos-m2")
 
 	android.RegisterArchVariantFeatures(android.Arm, "armv7-a-neon", "neon")
 	android.RegisterArchVariantFeatures(android.Arm, "armv8-a", "neon")
@@ -271,7 +270,6 @@
 		"kryo385":        "${config.ArmClangCortexA53Cflags}",
 		"exynos-m1":      "${config.ArmClangCortexA53Cflags}",
 		"exynos-m2":      "${config.ArmClangCortexA53Cflags}",
-		"denver":         "${config.ArmClangCortexA15Cflags}",
 	}
 )
 
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 89e567d..46d8528 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -91,7 +91,9 @@
 	"-Wl,-m,aarch64_elf64_le_vec",
 })
 
-var ClangLibToolingUnknownCflags []string = nil
+var ClangLibToolingUnknownCflags = sorted([]string{
+	"-fno-sanitize=implicit-integer-sign-change",
+})
 
 func init() {
 	pctx.StaticVariable("ClangExtraCflags", strings.Join([]string{
diff --git a/cc/config/global.go b/cc/config/global.go
index 31f64fe..92969b0 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -120,8 +120,8 @@
 
 	// prebuilts/clang default settings.
 	ClangDefaultBase         = "prebuilts/clang/host"
-	ClangDefaultVersion      = "clang-r344140b"
-	ClangDefaultShortVersion = "8.0.4"
+	ClangDefaultVersion      = "clang-r346389"
+	ClangDefaultShortVersion = "8.0.5"
 
 	// Directories with warnings from Android.bp files.
 	WarningAllowedProjects = []string{
diff --git a/cc/library.go b/cc/library.go
index 822274a..2257e2d 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -415,11 +415,11 @@
 	buildFlags := flagsToBuilderFlags(flags)
 
 	if library.static() {
-		srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
+		srcs := ctx.ExpandSources(library.Properties.Static.Srcs, nil)
 		objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
 			srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
 	} else if library.shared() {
-		srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
+		srcs := ctx.ExpandSources(library.Properties.Shared.Srcs, nil)
 		objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
 			srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
 	}
@@ -491,6 +491,18 @@
 	}
 }
 
+func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
+	deps = library.baseCompiler.compilerDeps(ctx, deps)
+
+	if library.static() {
+		android.ExtractSourcesDeps(ctx, library.Properties.Static.Srcs)
+	} else if library.shared() {
+		android.ExtractSourcesDeps(ctx, library.Properties.Shared.Srcs)
+	}
+
+	return deps
+}
+
 func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
 	if library.static() {
 		if library.Properties.Static.System_shared_libs != nil {
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 56013b6..08c672c 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -376,6 +376,22 @@
 	return deps
 }
 
+func toDisableImplicitIntegerChange(flags []string) bool {
+	// Returns true if any flag is fsanitize*integer, and there is
+	// no explicit flag about sanitize=implicit-integer-sign-change.
+	for _, f := range flags {
+		if strings.Contains(f, "sanitize=implicit-integer-sign-change") {
+			return false
+		}
+	}
+	for _, f := range flags {
+		if strings.HasPrefix(f, "-fsanitize") && strings.Contains(f, "integer") {
+			return true
+		}
+	}
+	return false
+}
+
 func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
 	minimalRuntimeLib := config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a"
 	minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib
@@ -533,6 +549,10 @@
 				flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
 			}
 		}
+		// http://b/119329758, Android core does not boot up with this sanitizer yet.
+		if toDisableImplicitIntegerChange(flags.CFlags) {
+			flags.CFlags = append(flags.CFlags, "-fno-sanitize=implicit-integer-sign-change")
+		}
 	}
 
 	if len(diagSanitizers) > 0 {
diff --git a/python/builder.go b/python/builder.go
index 7ecd4b5..cbbe56e 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -54,8 +54,10 @@
 
 	embeddedPar = pctx.AndroidStaticRule("embeddedPar",
 		blueprint.RuleParams{
-			// `echo -n` to trim the newline, since the python code just wants the name
-			Command: `echo -n '$main' > $entryPoint &&` +
+			// `echo -n` to trim the newline, since the python code just wants the name.
+			// /bin/sh (used by ninja) on Mac turns off posix mode, and stops supporting -n.
+			// Explicitly use bash instead.
+			Command: `/bin/bash -c "echo -n '$main' > $entryPoint" &&` +
 				`$mergeParCmd -p --prefix $launcher -e $entryPoint $out $srcsZips && ` +
 				`chmod +x $out && (rm -f $entryPoint)`,
 			CommandDeps: []string{"$mergeParCmd"},
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index db2e3bb..3ece649 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -75,7 +75,6 @@
 
 var Configuration = map[string]PathConfig{
 	"awk":       Allowed,
-	"basename":  Allowed,
 	"bash":      Allowed,
 	"bc":        Allowed,
 	"bzip2":     Allowed,
@@ -161,23 +160,24 @@
 	"pkg-config": Forbidden,
 
 	// On linux we'll use the toybox version of these instead
-	"cat":    Toybox,
-	"comm":   Toybox,
-	"env":    Toybox,
-	"id":     Toybox,
-	"od":     Toybox,
-	"paste":  Toybox,
-	"pwd":    Toybox,
-	"rmdir":  Toybox,
-	"setsid": Toybox,
-	"sleep":  Toybox,
-	"tail":   Toybox,
-	"tee":    Toybox,
-	"true":   Toybox,
-	"uname":  Toybox,
-	"uniq":   Toybox,
-	"whoami": Toybox,
-	"xxd":    Toybox,
+	"basename": Toybox,
+	"cat":      Toybox,
+	"comm":     Toybox,
+	"env":      Toybox,
+	"id":       Toybox,
+	"od":       Toybox,
+	"paste":    Toybox,
+	"pwd":      Toybox,
+	"rmdir":    Toybox,
+	"setsid":   Toybox,
+	"sleep":    Toybox,
+	"tail":     Toybox,
+	"tee":      Toybox,
+	"true":     Toybox,
+	"uname":    Toybox,
+	"uniq":     Toybox,
+	"whoami":   Toybox,
+	"xxd":      Toybox,
 }
 
 func init() {