Add -allow-adding-removing-referenced-apis for bionic

This commit depends on
https://android-review.googlesource.com/c/platform/development/+/3396961

The option allows functions to be completely removed or added to
header files without changing the symbols. The exception was added for
the functions in C standard libraries, but caused inaccurate ABI diff
for the other libraries. It will be allowed for bionic only.

Test: make
Bug: 342516369
Change-Id: Ia9da0a7d2bf244ea80f54beab0b5844dca267c01
diff --git a/cc/library.go b/cc/library.go
index c9114fd..7cafcc1 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1387,6 +1387,11 @@
 		extraFlags = append(extraFlags,
 			"-allow-unreferenced-changes",
 			"-allow-unreferenced-elf-symbol-changes")
+		// The functions in standard libraries are not always declared in the headers.
+		// Allow them to be added or removed without changing the symbols.
+		if isBionic(ctx.ModuleName()) {
+			extraFlags = append(extraFlags, "-allow-adding-removing-referenced-apis")
+		}
 	}
 	if isLlndk {
 		extraFlags = append(extraFlags, "-consider-opaque-types-different")