From 843c0638d6721cac5028e3075b7a2a3a37ebdcf0 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Mon, 25 Sep 2023 15:26:30 +0800 Subject: [PATCH] Let header-abi-linker filter symbols by API level In a trunk stable branch, the ABI-monitored libraries under different release configurations share the source code. The exported symbols are filtered by version scripts and API level. header-abi-linker needs to take the API level as a parameter. Test: make Bug: 308192597 Change-Id: I4b55b7ec023451b3a4cd1da308a1de10842d51d2 --- cc/builder.go | 8 +++++++- cc/library.go | 17 +++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index f5e0dcca5..c8fa1e451 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -875,7 +875,8 @@ func transformObjToDynamicBinary(ctx android.ModuleContext, // into a single .ldump sAbi dump file func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path, baseName, exportedHeaderFlags string, symbolFile android.OptionalPath, - excludedSymbolVersions, excludedSymbolTags []string) android.OptionalPath { + excludedSymbolVersions, excludedSymbolTags []string, + api string) android.OptionalPath { outputFile := android.PathForModuleOut(ctx, baseName+".lsdump") @@ -892,6 +893,11 @@ func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path for _, tag := range excludedSymbolTags { symbolFilterStr += " --exclude-symbol-tag " + tag } + apiLevelsJson := android.GetApiLevelsJson(ctx) + implicits = append(implicits, apiLevelsJson) + symbolFilterStr += " --api-map " + apiLevelsJson.String() + symbolFilterStr += " --api " + api + rule := sAbiLink args := map[string]string{ "symbolFilter": symbolFilterStr, diff --git a/cc/library.go b/cc/library.go index 21615121d..7332939ca 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1904,17 +1904,19 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec } exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx) - library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags, - android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)), - headerAbiChecker.Exclude_symbol_versions, - headerAbiChecker.Exclude_symbol_tags) - - addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String()) - // The logic must be consistent with classifySourceAbiDump. isVndk := ctx.useVndk() && ctx.isVndk() isNdk := ctx.isNdk(ctx.Config()) isLlndk := ctx.isImplementationForLLNDKPublic() + currVersion := currRefAbiDumpVersion(ctx, isVndk) + library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags, + android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)), + headerAbiChecker.Exclude_symbol_versions, + headerAbiChecker.Exclude_symbol_tags, + currVersion) + + addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String()) + dumpDir := getRefAbiDumpDir(isNdk, isVndk) binderBitness := ctx.DeviceConfig().BinderBitness() // If NDK or PLATFORM library, check against previous version ABI. @@ -1930,7 +1932,6 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec } } // Check against the current version. - currVersion := currRefAbiDumpVersion(ctx, isVndk) currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness) currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName) if currDumpFile.Valid() {