Stop using prebuilt NDK CRT objects.

We don't need the prebuilt versions. The NDK CRT objects are (now)
built from the platform sources and the only difference is that the
NDK CRT objects also include an ELF note that identifies the NDK
version, which isn't helpful for anything built by the platform.

Add a `crt` property to cc_object that allows CRT objects to identify
themselves. CRT objects, unlike other modules, will have a variant
built per-API level they support, rather than just an SDK variant and
a platform variant. This is needed because new CRT objects will rely
on APIs not available in old libcs and old CRT objects will not
support all the features of a modern one.

Test: treehugger
Bug: http://b/159925977
Change-Id: I6595485fa1bfe0ad4945193d344b863f64eec654
This commit is contained in:
Dan Albert
2020-07-15 13:33:30 -07:00
parent a57e56a684
commit 92fe740677
10 changed files with 113 additions and 121 deletions

View File

@@ -531,16 +531,6 @@ func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) {
system_shared_libs: [],
sdk_version: "29",
}
ndk_prebuilt_object {
name: "ndk_crtbegin_so.29",
sdk_version: "29",
}
ndk_prebuilt_object {
name: "ndk_crtend_so.29",
sdk_version: "29",
}
`
fs := map[string][]byte{
"prebuilts/ndk/current/platforms/android-29/arch-arm64/usr/lib/crtbegin_so.o": nil,
@@ -553,16 +543,28 @@ func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) {
inputs := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_sdk_shared").Description("link").Implicits
var crtbeginFound, crtendFound bool
expectedCrtBegin := ctx.ModuleForTests("crtbegin_so",
"android_arm64_armv8-a_sdk_29").Rule("partialLd").Output
expectedCrtEnd := ctx.ModuleForTests("crtend_so",
"android_arm64_armv8-a_sdk_29").Rule("partialLd").Output
implicits := []string{}
for _, input := range inputs {
switch input.String() {
case "prebuilts/ndk/current/platforms/android-29/arch-arm64/usr/lib/crtbegin_so.o":
implicits = append(implicits, input.String())
if strings.HasSuffix(input.String(), expectedCrtBegin.String()) {
crtbeginFound = true
case "prebuilts/ndk/current/platforms/android-29/arch-arm64/usr/lib/crtend_so.o":
} else if strings.HasSuffix(input.String(), expectedCrtEnd.String()) {
crtendFound = true
}
}
if !crtbeginFound || !crtendFound {
t.Error("should link with ndk_crtbegin_so.29 and ndk_crtend_so.29")
if !crtbeginFound {
t.Error(fmt.Sprintf(
"expected implicit with suffix %q, have the following implicits:\n%s",
expectedCrtBegin, strings.Join(implicits, "\n")))
}
if !crtendFound {
t.Error(fmt.Sprintf(
"expected implicit with suffix %q, have the following implicits:\n%s",
expectedCrtEnd, strings.Join(implicits, "\n")))
}
}