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/builder.go b/cc/builder.go
index b98bef9..f261c0d 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -945,13 +945,18 @@
 func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
 	baseName string, exportedIncludeDirs []string, symbolFile android.OptionalPath,
 	excludedSymbolVersions, excludedSymbolTags, includedSymbolTags []string,
-	api string) android.Path {
+	api string, commonGlobalIncludes bool) android.Path {
 
 	outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
 
 	implicits := android.Paths{soFile}
 	symbolFilterStr := "-so " + soFile.String()
 	exportedHeaderFlags := android.JoinWithPrefix(exportedIncludeDirs, "-I")
+	// 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.
+	if commonGlobalIncludes && len(exportedIncludeDirs) > 0 {
+		exportedHeaderFlags += " ${config.CommonGlobalIncludes}"
+	}
 
 	if symbolFile.Valid() {
 		implicits = append(implicits, symbolFile.Path())