Separate LLNDK ABI diff reports from the other variants

- Soong generates the rules to compare prebuilts/abi-dumps/vndk and
  the intermediate dumps tagged with LLNDK.
- The LLNDK ABI diff report names contain ".llndk". Because LLNDK
  versioning has not been implemented, the reports are identical to
  those for NDK and PLATFORM.
- optInAbiDiff does not take isLlndkOrNdk as a parameter, as it is
  false for all known use cases.

Test: m libnativewindow
Bug: 314010764
Change-Id: I17097505472b9d6ab97a605f3f8dca8ea53d22c8
This commit is contained in:
Hsin-Yi Chen
2024-02-06 15:43:17 +08:00
parent c9d4eab9fe
commit 362c1883d1
2 changed files with 66 additions and 48 deletions

View File

@@ -1354,18 +1354,6 @@ func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
fileName+".lsdump") fileName+".lsdump")
} }
func getRefAbiDumpDir(isNdk, isLlndk bool) string {
var dirName string
if isNdk {
dirName = "ndk"
} else if isLlndk {
dirName = "vndk"
} else {
dirName = "platform"
}
return filepath.Join("prebuilts", "abi-dumps", dirName)
}
func prevRefAbiDumpVersion(ctx ModuleContext, dumpDir string) int { func prevRefAbiDumpVersion(ctx ModuleContext, dumpDir string) int {
sdkVersionInt := ctx.Config().PlatformSdkVersion().FinalInt() sdkVersionInt := ctx.Config().PlatformSdkVersion().FinalInt()
sdkVersionStr := ctx.Config().PlatformSdkVersion().String() sdkVersionStr := ctx.Config().PlatformSdkVersion().String()
@@ -1435,17 +1423,17 @@ func (library *libraryDecorator) crossVersionAbiDiff(ctx android.ModuleContext,
} }
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path, func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
baseName string, isLlndkOrNdk bool) { baseName, nameExt string, isLlndkOrNdk bool) {
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName)) libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
library.sourceAbiDiff(ctx, referenceDump, baseName, "", library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage) isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
} }
func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referenceDump android.Path, func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
baseName, nameExt string, isLlndkOrNdk bool, refDumpDir string) { baseName, nameExt string, refDumpDir string) {
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName)) libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName + " -ref-dump-dir $$ANDROID_BUILD_TOP/" + refDumpDir errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName + " -ref-dump-dir $$ANDROID_BUILD_TOP/" + refDumpDir
@@ -1455,7 +1443,7 @@ func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referen
} }
library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt, library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage) false /* isLlndkOrNdk */, false /* allowExtensions */, "current", errorMessage)
} }
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) { func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
@@ -1470,9 +1458,6 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
} }
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx) headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
// The logic must be consistent with classifySourceAbiDump.
isNdk := ctx.isNdk(ctx.Config())
isLlndk := ctx.isImplementationForLLNDKPublic()
currVersion := currRefAbiDumpVersion(ctx) currVersion := currRefAbiDumpVersion(ctx)
library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags, library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)), android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
@@ -1481,27 +1466,37 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
currVersion) currVersion)
for _, tag := range classifySourceAbiDump(ctx) { for _, tag := range classifySourceAbiDump(ctx) {
addLsdumpPath(tag + ":" + library.sAbiOutputFile.String()) addLsdumpPath(string(tag) + ":" + library.sAbiOutputFile.String())
}
dumpDir := getRefAbiDumpDir(isNdk, isLlndk) dumpDirName := tag.dirName()
binderBitness := ctx.DeviceConfig().BinderBitness() if dumpDirName == "" {
// Check against the previous version. continue
prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir) }
prevVersion := strconv.Itoa(prevVersionInt) dumpDir := filepath.Join("prebuilts", "abi-dumps", dumpDirName)
prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness) isLlndk := (tag == llndkLsdumpTag)
prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName) isNdk := (tag == ndkLsdumpTag)
if prevDumpFile.Valid() { binderBitness := ctx.DeviceConfig().BinderBitness()
library.crossVersionAbiDiff(ctx, prevDumpFile.Path(), nameExt := ""
fileName, isLlndk || isNdk, if isLlndk {
strconv.Itoa(prevVersionInt+1), prevVersion) nameExt = "llndk"
} }
// Check against the current version. // Check against the previous version.
currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness) prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir)
currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName) prevVersion := strconv.Itoa(prevVersionInt)
if currDumpFile.Valid() { prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
library.sameVersionAbiDiff(ctx, currDumpFile.Path(), prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
fileName, isLlndk || isNdk) if prevDumpFile.Valid() {
library.crossVersionAbiDiff(ctx, prevDumpFile.Path(),
fileName, isLlndk || isNdk,
strconv.Itoa(prevVersionInt+1), nameExt+prevVersion)
}
// Check against the current version.
currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
if currDumpFile.Valid() {
library.sameVersionAbiDiff(ctx, currDumpFile.Path(),
fileName, nameExt, isLlndk || isNdk)
}
} }
// Check against the opt-in reference dumps. // Check against the opt-in reference dumps.
for i, optInDumpDir := range headerAbiChecker.Ref_dump_dirs { for i, optInDumpDir := range headerAbiChecker.Ref_dump_dirs {
@@ -1513,8 +1508,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
continue continue
} }
library.optInAbiDiff(ctx, optInDumpFile.Path(), library.optInAbiDiff(ctx, optInDumpFile.Path(),
fileName, "opt"+strconv.Itoa(i), isLlndk || isNdk, fileName, "opt"+strconv.Itoa(i), optInDumpDirPath.String())
optInDumpDirPath.String())
} }
} }
} }

View File

@@ -26,6 +26,30 @@ var (
lsdumpPathsLock sync.Mutex lsdumpPathsLock sync.Mutex
) )
type lsdumpTag string
const (
llndkLsdumpTag lsdumpTag = "LLNDK"
ndkLsdumpTag lsdumpTag = "NDK"
platformLsdumpTag lsdumpTag = "PLATFORM"
productLsdumpTag lsdumpTag = "PRODUCT"
vendorLsdumpTag lsdumpTag = "VENDOR"
)
// Return the prebuilt ABI dump directory for a tag; an empty string for an opt-in dump.
func (tag *lsdumpTag) dirName() string {
switch *tag {
case ndkLsdumpTag:
return "ndk"
case llndkLsdumpTag:
return "vndk"
case platformLsdumpTag:
return "platform"
default:
return ""
}
}
// Properties for ABI compatibility checker in Android.bp. // Properties for ABI compatibility checker in Android.bp.
type headerAbiCheckerProperties struct { type headerAbiCheckerProperties struct {
// Enable ABI checks (even if this is not an LLNDK/VNDK lib) // Enable ABI checks (even if this is not an LLNDK/VNDK lib)
@@ -98,8 +122,8 @@ func (sabi *sabi) shouldCreateSourceAbiDump() bool {
} }
// Returns a slice of strings that represent the ABI dumps generated for this module. // Returns a slice of strings that represent the ABI dumps generated for this module.
func classifySourceAbiDump(ctx android.BaseModuleContext) []string { func classifySourceAbiDump(ctx android.BaseModuleContext) []lsdumpTag {
result := []string{} result := []lsdumpTag{}
m := ctx.Module().(*Module) m := ctx.Module().(*Module)
headerAbiChecker := m.library.getHeaderAbiCheckerProperties(ctx) headerAbiChecker := m.library.getHeaderAbiCheckerProperties(ctx)
if headerAbiChecker.explicitlyDisabled() { if headerAbiChecker.explicitlyDisabled() {
@@ -107,21 +131,21 @@ func classifySourceAbiDump(ctx android.BaseModuleContext) []string {
} }
if !m.InProduct() && !m.InVendor() { if !m.InProduct() && !m.InVendor() {
if m.isImplementationForLLNDKPublic() { if m.isImplementationForLLNDKPublic() {
result = append(result, "LLNDK") result = append(result, llndkLsdumpTag)
} }
// Return NDK if the library is both NDK and APEX. // Return NDK if the library is both NDK and APEX.
// TODO(b/309880485): Split NDK and APEX ABI. // TODO(b/309880485): Split NDK and APEX ABI.
if m.IsNdk(ctx.Config()) { if m.IsNdk(ctx.Config()) {
result = append(result, "NDK") result = append(result, ndkLsdumpTag)
} else if m.library.hasStubsVariants() || headerAbiChecker.enabled() { } else if m.library.hasStubsVariants() || headerAbiChecker.enabled() {
result = append(result, "PLATFORM") result = append(result, platformLsdumpTag)
} }
} else if headerAbiChecker.enabled() { } else if headerAbiChecker.enabled() {
if m.InProduct() { if m.InProduct() {
result = append(result, "PRODUCT") result = append(result, productLsdumpTag)
} }
if m.InVendor() { if m.InVendor() {
result = append(result, "VENDOR") result = append(result, vendorLsdumpTag)
} }
} }
return result return result