Remove -include <file> when compiling stubs.

Otherwise, the force included headers might cause conflicting types
error with the symbols in the generated stubs source code. e.g.

double acos(double); // in header
void acos() {} // in the generated source code

Bug: 120266448
Test: m (apex_test also updated, and passing)
Change-Id: I717df990959d1b24ec515f0f52a4e28b94e92f32
diff --git a/cc/library.go b/cc/library.go
index 36f3a86..524b886 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -351,6 +351,24 @@
 
 	flags = library.baseCompiler.compilerFlags(ctx, flags, deps)
 	if library.buildStubs() {
+		// Remove -include <file> when compiling stubs. Otherwise, the force included
+		// headers might cause conflicting types error with the symbols in the
+		// generated stubs source code. e.g.
+		// double acos(double); // in header
+		// void acos() {} // in the generated source code
+		removeInclude := func(flags []string) []string {
+			ret := flags[:0]
+			for _, f := range flags {
+				if strings.HasPrefix(f, "-include ") {
+					continue
+				}
+				ret = append(ret, f)
+			}
+			return ret
+		}
+		flags.GlobalFlags = removeInclude(flags.GlobalFlags)
+		flags.CFlags = removeInclude(flags.CFlags)
+
 		flags = addStubLibraryCompilerFlags(flags)
 	}
 	return flags