Merge "Include license texts and kinds for VNDK snapshot"
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 05c888a..8a02a4a 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -7101,7 +7101,7 @@
native_shared_libs: ["mylib"],
java_libs: ["myjar"],
updatable: true,
- min_sdk_version: "current",
+ min_sdk_version: "33",
}
apex_key {
@@ -7124,7 +7124,7 @@
"myapex.updatable",
"//apex_available:platform",
],
- min_sdk_version: "current",
+ min_sdk_version: "33",
}
cc_library {
@@ -7137,7 +7137,7 @@
"myapex.updatable",
"//apex_available:platform",
],
- min_sdk_version: "current",
+ min_sdk_version: "33",
}
cc_library {
@@ -7151,7 +7151,7 @@
"myapex.updatable",
"//apex_available:platform",
],
- min_sdk_version: "current",
+ min_sdk_version: "33",
}
java_library {
@@ -7165,7 +7165,7 @@
"myapex.updatable",
"//apex_available:platform",
],
- min_sdk_version: "current",
+ min_sdk_version: "33",
}
java_library {
@@ -7178,7 +7178,7 @@
"myapex.updatable",
"//apex_available:platform",
],
- min_sdk_version: "current",
+ min_sdk_version: "33",
}
`
diff --git a/apex/builder.go b/apex/builder.go
index e3b6f8e..94aef49 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -71,6 +71,9 @@
pctx.HostBinToolVariable("make_erofs", "make_erofs")
pctx.HostBinToolVariable("apex_compression_tool", "apex_compression_tool")
pctx.HostBinToolVariable("dexdeps", "dexdeps")
+ pctx.HostBinToolVariable("apex_sepolicy_tests", "apex_sepolicy_tests")
+ pctx.HostBinToolVariable("deapexer", "deapexer")
+ pctx.HostBinToolVariable("debugfs_static", "debugfs_static")
pctx.SourcePathVariable("genNdkUsedbyApexPath", "build/soong/scripts/gen_ndk_usedby_apex.sh")
}
@@ -226,7 +229,12 @@
Description: "Generate symbol list used by Apex",
}, "image_dir", "readelf")
- // Don't add more rules here. Consider using android.NewRuleBuilder instead.
+ apexSepolicyTestsRule = pctx.StaticRule("apexSepolicyTestsRule", blueprint.RuleParams{
+ Command: `${deapexer} --debugfs_path ${debugfs_static} list -Z ${in} > ${out}.fc` +
+ `&& ${apex_sepolicy_tests} -f ${out}.fc && touch ${out}`,
+ CommandDeps: []string{"${apex_sepolicy_tests}", "${deapexer}", "${debugfs_static}"},
+ Description: "run apex_sepolicy_tests",
+ })
)
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
@@ -872,6 +880,10 @@
args["implicits"] = strings.Join(implicits.Strings(), ",")
args["outCommaList"] = signedOutputFile.String()
}
+ var validations android.Paths
+ if suffix == imageApexSuffix {
+ validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
+ }
ctx.Build(pctx, android.BuildParams{
Rule: rule,
Description: "signapk",
@@ -879,6 +891,7 @@
Input: unsignedOutputFile,
Implicits: implicits,
Args: args,
+ Validations: validations,
})
if suffix == imageApexSuffix {
a.outputApexFile = signedOutputFile
@@ -1172,3 +1185,17 @@
return cannedFsConfig.OutputPath
}
+
+// Runs apex_sepolicy_tests
+//
+// $ deapexer list -Z {apex_file} > {file_contexts}
+// $ apex_sepolicy_tests -f {file_contexts}
+func runApexSepolicyTests(ctx android.ModuleContext, apexFile android.OutputPath) android.Path {
+ timestamp := android.PathForModuleOut(ctx, "sepolicy_tests.timestamp")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexSepolicyTestsRule,
+ Input: apexFile,
+ Output: timestamp,
+ })
+ return timestamp
+}
diff --git a/cc/config/global.go b/cc/config/global.go
index 5b2191a..4277bcf 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -111,6 +111,9 @@
// Turn off FMA which got enabled by default in clang-r445002 (http://b/218805949)
"-ffp-contract=off",
+
+ // Turn off stack protector check for noreturn calls. (http://b/264965700)
+ "-mllvm -disable-check-noreturn-call",
}
commonGlobalConlyflags = []string{}
@@ -147,6 +150,9 @@
commonGlobalLldflags = []string{
"-fuse-ld=lld",
"-Wl,--icf=safe",
+
+ // Turn off stack protector check for noreturn calls. (http://b/264965700)
+ "-Wl,-mllvm,-disable-check-noreturn-call",
}
deviceGlobalCppflags = []string{
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 622558e..dffc6c6 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -142,6 +142,13 @@
staticLibInstallPaths, library.ndkSysrootPath)
}
}
+
+ if object, ok := m.linker.(*objectLinker); ok {
+ if object.ndkSysrootPath != nil {
+ staticLibInstallPaths = append(
+ staticLibInstallPaths, object.ndkSysrootPath)
+ }
+ }
}
})
diff --git a/cc/object.go b/cc/object.go
index ef44467..d65cdea 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -44,6 +44,10 @@
type objectLinker struct {
*baseLinker
Properties ObjectLinkerProperties
+
+ // Location of the object in the sysroot. Empty if the object is not
+ // included in the NDK.
+ ndkSysrootPath android.Path
}
type objectBazelHandler struct {
@@ -99,6 +103,10 @@
// Indicates that this module is a CRT object. CRT objects will be split
// into a variant per-API level between min_sdk_version and current.
Crt *bool
+
+ // Indicates that this module should not be included in the NDK sysroot.
+ // Only applies to CRT objects. Defaults to false.
+ Exclude_from_ndk_sysroot *bool
}
func newObject(hod android.HostOrDeviceSupported) *Module {
@@ -268,17 +276,28 @@
objs = objs.Append(deps.Objs)
- var outputFile android.Path
+ var output android.WritablePath
builderFlags := flagsToBuilderFlags(flags)
outputName := ctx.ModuleName()
if !strings.HasSuffix(outputName, objectExtension) {
outputName += objectExtension
}
- if len(objs.objFiles) == 1 && String(object.Properties.Linker_script) == "" {
- output := android.PathForModuleOut(ctx, outputName)
- outputFile = output
+ // isForPlatform is terribly named and actually means isNotApex.
+ if Bool(object.Properties.Crt) &&
+ !Bool(object.Properties.Exclude_from_ndk_sysroot) && ctx.useSdk() &&
+ ctx.isSdkVariant() && ctx.isForPlatform() {
+ output = getVersionedLibraryInstallPath(ctx,
+ nativeApiLevelOrPanic(ctx, ctx.sdkVersion())).Join(ctx, outputName)
+ object.ndkSysrootPath = output
+ } else {
+ output = android.PathForModuleOut(ctx, outputName)
+ }
+
+ outputFile := output
+
+ if len(objs.objFiles) == 1 && String(object.Properties.Linker_script) == "" {
if String(object.Properties.Prefix_symbols) != "" {
transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), objs.objFiles[0],
builderFlags, output)
@@ -290,9 +309,6 @@
})
}
} else {
- output := android.PathForModuleOut(ctx, outputName)
- outputFile = output
-
if String(object.Properties.Prefix_symbols) != "" {
input := android.PathForModuleOut(ctx, "unprefixed", outputName)
transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), input,
diff --git a/cc/object_test.go b/cc/object_test.go
index 5359a35..b1e2a0f 100644
--- a/cc/object_test.go
+++ b/cc/object_test.go
@@ -65,7 +65,7 @@
variant := "android_arm64_armv8-a_sdk"
crt := ctx.ModuleForTests("bin", variant).Rule("ld").Args["crtBegin"]
android.AssertStringDoesContain(t, "crt dep of sdk variant", crt,
- variant+"_29/crtbegin_dynamic.o")
+ "29/crtbegin_dynamic.o")
// platform variant uses the crt object built for platform
variant = "android_arm64_armv8-a"