Monitor the ABI declared in CommonGlobalIncludes
The modules linked with the libraries in APEX implicitly include
CommonGlobalIncludes. A function declared in CommonGlobalIncludes can be
defined in any APEX. Therefore the ABI tool should consider
CommonGlobalIncludes to be exported by every APEX.
Test: make
Bug: 385733305
Change-Id: Iae08a42e17f8131e9e0f71b3899b96f62d5f741a
diff --git a/cc/library.go b/cc/library.go
index c9114fd..4c6c215 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -616,10 +616,17 @@
}
if library.sabi.shouldCreateSourceAbiDump() {
dirs := library.exportedIncludeDirsForAbiCheck(ctx)
- flags.SAbiFlags = make([]string, 0, len(dirs))
+ flags.SAbiFlags = make([]string, 0, len(dirs)+1)
for _, dir := range dirs {
flags.SAbiFlags = append(flags.SAbiFlags, "-I"+dir)
}
+ // If this library does not export any include directory, do not append the flags
+ // so that the ABI tool dumps everything without filtering by the include directories.
+ // requiresGlobalIncludes returns whether this library can include CommonGlobalIncludes.
+ // If the library cannot include them, it cannot export them.
+ if len(dirs) > 0 && requiresGlobalIncludes(ctx) {
+ flags.SAbiFlags = append(flags.SAbiFlags, "${config.CommonGlobalIncludes}")
+ }
totalLength := len(srcs) + len(deps.GeneratedSources) +
len(sharedSrcs) + len(staticSrcs)
if totalLength > 0 {
@@ -1306,13 +1313,15 @@
deps PathDeps, sAbiDumpFiles android.Paths, soFile android.Path, libFileName string,
excludeSymbolVersions, excludeSymbolTags []string,
sdkVersionForVendorApiLevel string) android.Path {
+ // Though LLNDK is implemented in system, the callers in vendor cannot include CommonGlobalIncludes,
+ // so commonGlobalIncludes is false.
return transformDumpToLinkedDump(ctx,
sAbiDumpFiles, soFile, libFileName+".llndk",
library.llndkIncludeDirsForAbiCheck(ctx, deps),
android.OptionalPathForModuleSrc(ctx, library.Properties.Llndk.Symbol_file),
append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
append([]string{"platform-only"}, excludeSymbolTags...),
- []string{"llndk"}, sdkVersionForVendorApiLevel)
+ []string{"llndk"}, sdkVersionForVendorApiLevel, false /* commonGlobalIncludes */)
}
func (library *libraryDecorator) linkApexSAbiDumpFiles(ctx ModuleContext,
@@ -1325,7 +1334,7 @@
android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file),
append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
append([]string{"platform-only"}, excludeSymbolTags...),
- []string{"apex", "systemapi"}, sdkVersion)
+ []string{"apex", "systemapi"}, sdkVersion, requiresGlobalIncludes(ctx))
}
func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
@@ -1463,7 +1472,7 @@
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
headerAbiChecker.Exclude_symbol_versions,
headerAbiChecker.Exclude_symbol_tags,
- []string{} /* includeSymbolTags */, currSdkVersion)
+ []string{} /* includeSymbolTags */, currSdkVersion, requiresGlobalIncludes(ctx))
var llndkDump, apexVariantDump android.Path
tags := classifySourceAbiDump(ctx.Module().(*Module))