Merge "Revert "C++17: switch the default.""
diff --git a/android/arch.go b/android/arch.go
index 7fe1b18..1637a47 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1083,6 +1083,7 @@
 		{"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"}},
 		{"arm", "armv7-a-neon", "exynos-m1", []string{"armeabi-v7a"}},
 		{"arm", "armv7-a-neon", "exynos-m2", []string{"armeabi-v7a"}},
 		{"arm64", "armv8-a", "cortex-a53", []string{"arm64-v8a"}},
@@ -1094,6 +1095,7 @@
 		{"arm64", "armv8-a", "exynos-m2", []string{"arm64-v8a"}},
 		{"arm64", "armv8-2a", "cortex-a75", []string{"arm64-v8a"}},
 		{"arm64", "armv8-2a", "cortex-a76", []string{"arm64-v8a"}},
+		{"arm64", "armv8-2a", "kryo385", []string{"arm64-v8a"}},
 		{"mips", "mips32-fp", "", []string{"mips"}},
 		{"mips", "mips32r2-fp", "", []string{"mips"}},
 		{"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
diff --git a/android/variable.go b/android/variable.go
index 4534774..f496008 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -54,10 +54,6 @@
 			Cflags []string
 		}
 
-		Device_uses_hwc2 struct {
-			Cflags []string
-		}
-
 		Override_rs_driver struct {
 			Cflags []string
 		}
@@ -190,7 +186,6 @@
 	UseGoma                    *bool `json:",omitempty"`
 	Debuggable                 *bool `json:",omitempty"`
 	Eng                        *bool `json:",omitempty"`
-	Device_uses_hwc2           *bool `json:",omitempty"`
 	Treble_linker_namespaces   *bool `json:",omitempty"`
 	Enforce_vintf_manifest     *bool `json:",omitempty"`
 	Pdk                        *bool `json:",omitempty"`
diff --git a/cc/cc.go b/cc/cc.go
index 9fa7c3a..4d06c60 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -247,6 +247,7 @@
 	baseModuleName() string
 	getVndkExtendsModuleName() string
 	isPgoCompile() bool
+	useClangLld(actx ModuleContext) bool
 }
 
 type ModuleContext interface {
@@ -287,6 +288,7 @@
 	linkerDeps(ctx DepsContext, deps Deps) Deps
 	linkerFlags(ctx ModuleContext, flags Flags) Flags
 	linkerProps() []interface{}
+	useClangLld(actx ModuleContext) bool
 
 	link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
 	appendLdflags([]string)
@@ -635,6 +637,10 @@
 	return ""
 }
 
+func (ctx *moduleContextImpl) useClangLld(actx ModuleContext) bool {
+	return ctx.mod.linker.useClangLld(actx)
+}
+
 func (ctx *moduleContextImpl) baseModuleName() string {
 	return ctx.mod.ModuleBase.BaseModuleName()
 }
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 6a63828..299799d 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -68,6 +68,10 @@
 		"kryo": []string{
 			"-mcpu=kryo",
 		},
+		"kryo385": []string{
+			// Use cortex-a53 because kryo385 is not supported in GCC/clang.
+			"-mcpu=cortex-a53",
+		},
 		"exynos-m1": []string{
 			"-mcpu=exynos-m1",
 		},
@@ -92,6 +96,7 @@
 		"cortex-a75",
 		"cortex-a76",
 		"kryo",
+		"kryo385",
 		"exynos-m1",
 		"exynos-m2",
 		"denver64")
@@ -144,6 +149,7 @@
 		"cortex-a75": "${config.Arm64ClangCortexA55Cflags}",
 		"cortex-a76": "${config.Arm64ClangCortexA55Cflags}",
 		"kryo":       "${config.Arm64ClangKryoCflags}",
+		"kryo385":    "${config.Arm64ClangCortexA53Cflags}",
 		"exynos-m1":  "${config.Arm64ClangExynosM1Cflags}",
 		"exynos-m2":  "${config.Arm64ClangExynosM2Cflags}",
 	}
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index d759125..29378c6 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -151,6 +151,15 @@
 			// better solution comes around. See Bug 27340895
 			"-D__ARM_FEATURE_LPAE=1",
 		},
+		"kryo385": []string{
+			// Use cortex-a53 because kryo385 is not supported in GCC/clang.
+			"-mcpu=cortex-a53",
+			// Fake an ARM compiler flag as these processors support LPAE which GCC/clang
+			// don't advertise.
+			// TODO This is a hack and we need to add it for each processor that supports LPAE until some
+			// better solution comes around. See Bug 27340895
+			"-D__ARM_FEATURE_LPAE=1",
+		},
 	}
 )
 
@@ -180,6 +189,7 @@
 		"cortex-a76",
 		"krait",
 		"kryo",
+		"kryo385",
 		"exynos-m1",
 		"exynos-m2",
 		"denver")
@@ -242,7 +252,7 @@
 		"armv7-a":      "${config.ArmClangArmv7ACflags}",
 		"armv7-a-neon": "${config.ArmClangArmv7ANeonCflags}",
 		"armv8-a":      "${config.ArmClangArmv8ACflags}",
-		"armv8-2a":      "${config.ArmClangArmv82ACflags}",
+		"armv8-2a":     "${config.ArmClangArmv82ACflags}",
 	}
 
 	armClangCpuVariantCflagsVar = map[string]string{
@@ -258,6 +268,7 @@
 		"cortex-a75":     "${config.ArmClangCortexA55Cflags}",
 		"krait":          "${config.ArmClangKraitCflags}",
 		"kryo":           "${config.ArmClangKryoCflags}",
+		"kryo385":        "${config.ArmClangCortexA53Cflags}",
 		"exynos-m1":      "${config.ArmClangCortexA53Cflags}",
 		"exynos-m2":      "${config.ArmClangCortexA53Cflags}",
 		"denver":         "${config.ArmClangCortexA15Cflags}",
diff --git a/cc/config/x86_windows_host.go b/cc/config/x86_windows_host.go
index 6300a1b..e23c0a0 100644
--- a/cc/config/x86_windows_host.go
+++ b/cc/config/x86_windows_host.go
@@ -140,6 +140,9 @@
 	pctx.StaticVariable("WindowsX8664ClangCppflags", strings.Join(windowsX8664ClangCppflags, " "))
 
 	pctx.StaticVariable("WindowsIncludeFlags", strings.Join(windowsIncludeFlags, " "))
+	// Yasm flags
+	pctx.StaticVariable("WindowsX86YasmFlags", "-f win32 -m x86")
+	pctx.StaticVariable("WindowsX8664YasmFlags", "-f win64 -m amd64")
 }
 
 type toolchainWindows struct {
@@ -228,6 +231,14 @@
 	return "${config.WindowsClangLldflags} ${config.WindowsX8664ClangLldflags}"
 }
 
+func (t *toolchainWindowsX86) YasmFlags() string {
+	return "${config.WindowsX86YasmFlags}"
+}
+
+func (t *toolchainWindowsX8664) YasmFlags() string {
+	return "${config.WindowsX8664YasmFlags}"
+}
+
 func (t *toolchainWindows) ShlibSuffix() string {
 	return ".dll"
 }
diff --git a/cc/xom.go b/cc/xom.go
index f65fc24..182069f 100644
--- a/cc/xom.go
+++ b/cc/xom.go
@@ -66,7 +66,8 @@
 	// Enable execute-only if none of the dependencies disable it,
 	// also if it's explicitly set true (allows overriding dependencies disabling it).
 	if !disableXom || (xom.Properties.Xom != nil && *xom.Properties.Xom) {
-		if ctx.Arch().ArchType == android.Arm64 {
+		// XOM is only supported on AArch64 when using lld.
+		if ctx.Arch().ArchType == android.Arm64 && ctx.useClangLld(ctx) {
 			flags.LdFlags = append(flags.LdFlags, "-Wl,-execute-only")
 		}
 	}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 0c4877a..9cde189 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -1129,9 +1129,9 @@
 		Inputs:      d.Javadoc.srcFiles,
 		Implicits:   implicits,
 		Args: map[string]string{
-			"outDir":        android.PathForModuleOut(ctx, "out").String(),
-			"srcJarDir":     android.PathForModuleOut(ctx, "srcjars").String(),
-			"stubsDir":      android.PathForModuleOut(ctx, "stubsDir").String(),
+			"outDir":        android.PathForModuleOut(ctx, "dokka-out").String(),
+			"srcJarDir":     android.PathForModuleOut(ctx, "dokka-srcjars").String(),
+			"stubsDir":      android.PathForModuleOut(ctx, "dokka-stubsDir").String(),
 			"srcJars":       strings.Join(d.Javadoc.srcJars.Strings(), " "),
 			"classpathArgs": classpathArgs,
 			"opts":          opts,
@@ -1585,7 +1585,7 @@
 		Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile},
 			implicits...),
 		Args: map[string]string{
-			"srcJarDir":         android.PathForModuleOut(ctx, "srcjars").String(),
+			"srcJarDir":         android.PathForModuleOut(ctx, "apicheck-srcjars").String(),
 			"srcJars":           strings.Join(d.Javadoc.srcJars.Strings(), " "),
 			"javaVersion":       javaVersion,
 			"bootclasspathArgs": bootclasspathArgs,
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index 5e68db8..a81011f 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -113,7 +113,6 @@
 	"mktemp":    Allowed,
 	"mv":        Allowed,
 	"openssl":   Allowed,
-	"paste":     Allowed,
 	"patch":     Allowed,
 	"pgrep":     Allowed,
 	"pkill":     Allowed,
@@ -125,7 +124,6 @@
 	"readlink":  Allowed,
 	"realpath":  Allowed,
 	"rm":        Allowed,
-	"rmdir":     Allowed,
 	"rsync":     Allowed,
 	"sed":       Allowed,
 	"setsid":    Allowed,
@@ -171,7 +169,9 @@
 	"env":    Toybox,
 	"id":     Toybox,
 	"od":     Toybox,
+	"paste":  Toybox,
 	"pwd":    Toybox,
+	"rmdir":  Toybox,
 	"sleep":  Toybox,
 	"tail":   Toybox,
 	"true":   Toybox,