diff --git a/cc/cc_test.go b/cc/cc_test.go index 719661598..781778714 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -3628,6 +3628,18 @@ func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) { } } +func TestMinSdkVersionInClangTriple(t *testing.T) { + ctx := testCc(t, ` + cc_library_shared { + name: "libfoo", + srcs: ["foo.c"], + min_sdk_version: "29", + }`) + + cFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"] + android.AssertStringDoesContain(t, "min sdk version", cFlags, "-target aarch64-linux-android29") +} + type MemtagNoteType int const ( diff --git a/cc/compiler.go b/cc/compiler.go index bcad1ad2e..2729e61c5 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -411,12 +411,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps target := "-target " + tc.ClangTriple() if ctx.Os().Class == android.Device { - // When built for the non-updateble part of platform, minSdkVersion doesn't matter. - // It matters only when building we are building for modules that can be unbundled. - version := "current" - if !ctx.isForPlatform() || ctx.isSdkVariant() { - version = ctx.minSdkVersion() - } + version := ctx.minSdkVersion() if version == "" || version == "current" { target += strconv.Itoa(android.FutureApiLevelInt) } else {