Turn overriding command warnings into errors by default
am: 9dc69a43b0

Change-Id: I2622062c9f39f86653b4721b1d9ef14fee27fdc9
diff --git a/android/api_levels.go b/android/api_levels.go
index 64d3d5d..b1b954c 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -16,7 +16,6 @@
 
 import (
 	"encoding/json"
-	"strconv"
 )
 
 func init() {
@@ -51,46 +50,28 @@
 	return PathForOutput(ctx, "api_levels.json")
 }
 
-func getApiLevelsMap(config Config) map[string]int {
-	return config.Once("ApiLevelsMap", func() interface{} {
-		baseApiLevel := 9000
-		apiLevelsMap := map[string]int{
-			"G":     9,
-			"I":     14,
-			"J":     16,
-			"J-MR1": 17,
-			"J-MR2": 18,
-			"K":     19,
-			"L":     21,
-			"L-MR1": 22,
-			"M":     23,
-			"N":     24,
-			"N-MR1": 25,
-			"O":     26,
-		}
-		for i, codename := range config.PlatformVersionCombinedCodenames() {
-			apiLevelsMap[codename] = baseApiLevel + i
-		}
-
-		return apiLevelsMap
-	}).(map[string]int)
-}
-
-// Converts an API level string into its numeric form.
-// * Codenames are decoded.
-// * Numeric API levels are simply converted.
-// * "minimum" and "current" are not currently handled since the former is
-//   NDK specific and the latter has inconsistent meaning.
-func ApiStrToNum(ctx BaseContext, apiLevel string) (int, error) {
-	num, ok := getApiLevelsMap(ctx.Config())[apiLevel]
-	if ok {
-		return num, nil
-	}
-	return strconv.Atoi(apiLevel)
-}
-
 func (a *apiLevelsSingleton) GenerateBuildActions(ctx SingletonContext) {
-	apiLevelsMap := getApiLevelsMap(ctx.Config())
+	baseApiLevel := 9000
+	apiLevelsMap := map[string]int{
+		"G":     9,
+		"I":     14,
+		"J":     16,
+		"J-MR1": 17,
+		"J-MR2": 18,
+		"K":     19,
+		"L":     21,
+		"L-MR1": 22,
+		"M":     23,
+		"N":     24,
+		"N-MR1": 25,
+		"O":     26,
+		"O-MR1": 27,
+		"P":     28,
+	}
+	for i, codename := range ctx.Config().PlatformVersionCombinedCodenames() {
+		apiLevelsMap[codename] = baseApiLevel + i
+	}
+
 	apiLevelsJson := GetApiLevelsJson(ctx)
 	createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
 }
diff --git a/android/variable.go b/android/variable.go
index d97fc0b..b4ed1b7 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -104,6 +104,19 @@
 		Uml struct {
 			Cppflags []string
 		}
+
+		Use_lmkd_stats_log struct {
+			Cflags []string
+		}
+
+		Arc struct {
+			Cflags       []string
+			Exclude_srcs []string
+			Include_dirs []string
+			Shared_libs  []string
+			Static_libs  []string
+			Srcs         []string
+		}
 	} `android:"arch_variant"`
 }
 
@@ -174,6 +187,8 @@
 	Enforce_vintf_manifest     *bool `json:",omitempty"`
 	Pdk                        *bool `json:",omitempty"`
 	Uml                        *bool `json:",omitempty"`
+	Use_lmkd_stats_log         *bool `json:",omitempty"`
+	Arc                        *bool `json:",omitempty"`
 	MinimizeJavaDebugInfo      *bool `json:",omitempty"`
 
 	IntegerOverflowExcludePaths *[]string `json:",omitempty"`
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 172784a..f412583 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -174,7 +174,6 @@
 	toolchain64Bit
 
 	ldflags              string
-	lldflags             string
 	toolchainCflags      string
 	toolchainClangCflags string
 }
@@ -232,7 +231,7 @@
 }
 
 func (t *toolchainArm64) ClangLldflags() string {
-	return t.lldflags
+	return "${config.Arm64Lldflags}"
 }
 
 func (t *toolchainArm64) ToolchainClangCflags() string {
@@ -270,10 +269,6 @@
 			"${config.Arm64Ldflags}",
 			extraLdflags,
 		}, " "),
-		lldflags: strings.Join([]string{
-			"${config.Arm64Lldflags}",
-			extraLdflags,
-		}, " "),
 		toolchainCflags:      variantOrDefault(arm64CpuVariantCflagsVar, arch.CpuVariant),
 		toolchainClangCflags: strings.Join(toolchainClangCflags, " "),
 	}
diff --git a/cc/config/global.go b/cc/config/global.go
index dee7640..a49e509 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -192,7 +192,7 @@
 	// This is used by non-NDK modules to get jni.h. export_include_dirs doesn't help
 	// with this, since there is no associated library.
 	pctx.PrefixedExistentPathsForSourcesVariable("CommonNativehelperInclude", "-I",
-		[]string{"libnativehelper/include_deprecated"})
+		[]string{"libnativehelper/include_jni"})
 
 	pctx.SourcePathVariable("ClangDefaultBase", ClangDefaultBase)
 	pctx.VariableFunc("ClangBase", func(ctx android.PackageVarContext) string {
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index db96325..5a76666 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -156,11 +156,11 @@
 	return strconv.Atoi(firstSupportedVersion)
 }
 
-func shouldUseVersionScript(ctx android.BaseContext, stub *stubDecorator) (bool, error) {
-	// https://github.com/android-ndk/ndk/issues/622
-	// The loader spews warnings to stderr on L-MR1 when loading a library that
-	// has symbol versioning.
-	firstVersionSupportingRelease := 23
+func shouldUseVersionScript(stub *stubDecorator) (bool, error) {
+	// unversioned_until is normally empty, in which case we should use the version script.
+	if String(stub.properties.Unversioned_until) == "" {
+		return true, nil
+	}
 
 	if String(stub.properties.Unversioned_until) == "current" {
 		if stub.properties.ApiLevel == "current" {
@@ -174,31 +174,16 @@
 		return true, nil
 	}
 
-	version, err := android.ApiStrToNum(ctx, stub.properties.ApiLevel)
+	unversionedUntil, err := strconv.Atoi(String(stub.properties.Unversioned_until))
 	if err != nil {
 		return true, err
 	}
 
-	// unversioned_until is normally empty, in which case we use the version
-	// script as long as we are on a supported API level.
-	if String(stub.properties.Unversioned_until) == "" {
-		return version >= firstVersionSupportingRelease, nil
-	}
-
-	unversionedUntil, err := android.ApiStrToNum(ctx, String(stub.properties.Unversioned_until))
+	version, err := strconv.Atoi(stub.properties.ApiLevel)
 	if err != nil {
 		return true, err
 	}
 
-	if unversionedUntil < firstVersionSupportingRelease {
-		return true, fmt.Errorf("unversioned_until must be at least %d",
-			firstVersionSupportingRelease)
-	}
-
-	if version < firstVersionSupportingRelease {
-		return false, nil
-	}
-
 	return version >= unversionedUntil, nil
 }
 
@@ -333,7 +318,7 @@
 func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
 	objs Objects) android.Path {
 
-	useVersionScript, err := shouldUseVersionScript(ctx, stub)
+	useVersionScript, err := shouldUseVersionScript(stub)
 	if err != nil {
 		ctx.ModuleErrorf(err.Error())
 	}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 4c8a611..1037181 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -236,8 +236,8 @@
 		}
 	}
 
-	// Enable CFI for all components in the include paths
-	if s.Cfi == nil && ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) {
+	// Enable CFI for all components in the include paths (for Aarch64 only)
+	if s.Cfi == nil && ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
 		s.Cfi = boolPtr(true)
 		if inList("cfi", ctx.Config().SanitizeDeviceDiag()) {
 			s.Diag.Cfi = boolPtr(true)
@@ -272,6 +272,12 @@
 		s.Integer_overflow = nil
 	}
 
+	// Also disable CFI for VNDK variants of components
+	if ctx.isVndk() && ctx.useVndk() {
+		s.Cfi = nil
+		s.Diag.Cfi = nil
+	}
+
 	if ctx.staticBinary() {
 		s.Address = nil
 		s.Coverage = nil
diff --git a/java/config/config.go b/java/config/config.go
index ae497a6..4863fec 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -41,6 +41,8 @@
 		"services",
 		"android.car",
 		"android.car7",
+		"core-oj",
+		"core-libart",
 	}
 
 	ManifestMergerClasspath = []string{