Merge "Automatically export bootclasspath_fragment stubs from sdk"
diff --git a/android/apex.go b/android/apex.go
index 25a07b8..60da45b 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -847,7 +847,6 @@
 	"libprocpartition":                                         30,
 	"libprotobuf-java-lite":                                    30,
 	"libprotoutil":                                             30,
-	"libqemu_pipe":                                             30,
 	"libsync":                                                  30,
 	"libtextclassifier_hash_headers":                           30,
 	"libtextclassifier_hash_static":                            30,
diff --git a/android/bazel.go b/android/bazel.go
index 49fc0ad..e436a7e 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -200,7 +200,7 @@
 
 		// Linker error
 		"libc_malloc_hooks", // jingwen@, cc_library, undefined symbol: __malloc_hook, etc.
-		"libdl",             // jingwen@, cc_library, no input files
+		"libdl",             // jingwen@, cc_library, clang failed
 		"libstdc++",         // jingwen@, cc_library, undefined symbol: free
 
 		// Includes not found
@@ -213,7 +213,6 @@
 		"libBionicBenchmarksUtils", // ruperts@, cc_library_static, 'map' file not found
 		"libc_syscalls",            // ruperts@, cc_library_static, mutator panic cannot get direct dep syscalls-arm64.S of libc_syscalls
 		"libc_ndk",                 // ruperts@, cc_library_static, depends on libc_bionic_ndk, libc_jemalloc_wrapper, libc_syscalls, libc_tzcode, libstdc++
-		"libdl_static",             // ruperts@, cc_library_static, conflicts with libdl
 
 		"libc", // jingwen@, cc_library, depends on //external/gwp_asan
 	}
@@ -221,10 +220,9 @@
 	// Per-module denylist to opt modules out of mixed builds. Such modules will
 	// still be generated via bp2build.
 	mixedBuildsDisabledList = []string{
-		"libasync_safe", // lberki@, cc_library_static, 'async_safe/log.h not found' for out/combined-aosp_arm64.ninja out/soong/.intermediates/system/unwinding/libbacktrace/libbacktrace/android_arm64_armv8-a_shared/obj/system/unwinding/libbacktrace/ThreadEntry.o
-		"libc_gdtoa",    // ruperts@, cc_library_static, OK for bp2build but undefined symbol: __strtorQ for mixed builds
-		"libc_netbsd",   // lberki@, cc_library_static, version script assignment of 'LIBC_PRIVATE' to symbol 'SHA1Final' failed: symbol not defined
-		"libc_openbsd",  // ruperts@, cc_library_static, OK for bp2build but error: duplicate symbol: strcpy for mixed builds
+		"libc_gdtoa",   // ruperts@, cc_library_static, OK for bp2build but undefined symbol: __strtorQ for mixed builds
+		"libc_netbsd",  // lberki@, cc_library_static, version script assignment of 'LIBC_PRIVATE' to symbol 'SHA1Final' failed: symbol not defined
+		"libc_openbsd", // ruperts@, cc_library_static, OK for bp2build but error: duplicate symbol: strcpy for mixed builds
 	}
 
 	// Used for quicker lookups
diff --git a/cc/cc.go b/cc/cc.go
index 4d8f4e1..c35f628 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1121,13 +1121,6 @@
 	return c.VendorProperties.IsLLNDK && !c.VendorProperties.IsVNDKPrivate
 }
 
-func (c *Module) IsLlndkHeaders() bool {
-	if _, ok := c.linker.(*llndkHeadersDecorator); ok {
-		return true
-	}
-	return false
-}
-
 func (c *Module) IsLlndkLibrary() bool {
 	if _, ok := c.linker.(*llndkStubDecorator); ok {
 		return true
@@ -1608,8 +1601,7 @@
 	}
 
 	llndk := c.IsLlndk()
-	_, llndkHeader := c.linker.(*llndkHeadersDecorator)
-	if llndk || llndkHeader || (c.UseVndk() && c.HasNonSystemVariants()) {
+	if llndk || (c.UseVndk() && c.HasNonSystemVariants()) {
 		// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
 		// added for product variant only when we have vendor and product variants with core
 		// variant. The suffix is not added for vendor-only or product-only module.
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 3d2160f..49fffc9 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -557,8 +557,11 @@
 			export_llndk_headers: ["libllndk_headers"],
 		}
 
-		llndk_headers {
+		cc_library_headers {
 			name: "libllndk_headers",
+			llndk: {
+				llndk_headers: true,
+			},
 			export_include_dirs: ["include"],
 		}
 
@@ -903,8 +906,11 @@
 			export_llndk_headers: ["libllndk_headers"],
 		}
 
-		llndk_headers {
+		cc_library_headers {
 			name: "libllndk_headers",
+			llndk: {
+				symbol_file: "libllndk.map.txt",
+			},
 			export_include_dirs: ["include"],
 		}
 	`)
@@ -2920,17 +2926,19 @@
 
 func TestLlndkHeaders(t *testing.T) {
 	ctx := testCc(t, `
-	llndk_headers {
+	cc_library_headers {
 		name: "libllndk_headers",
 		export_include_dirs: ["my_include"],
-	}
-	llndk_library {
-		name: "libllndk.llndk",
-		export_llndk_headers: ["libllndk_headers"],
+		llndk: {
+			llndk_headers: true,
+		},
 	}
 	cc_library {
 		name: "libllndk",
-		llndk_stubs: "libllndk.llndk",
+		llndk: {
+			symbol_file: "libllndk.map.txt",
+			export_llndk_headers: ["libllndk_headers"],
+		}
 	}
 
 	cc_library {
diff --git a/cc/image.go b/cc/image.go
index 6265b13..66b02d9 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -437,7 +437,7 @@
 		productVndkVersion = platformVndkVersion
 	}
 
-	if m.IsLlndkLibrary() || m.IsLlndkHeaders() || m.NeedsLlndkVariants() {
+	if m.IsLlndkLibrary() || m.NeedsLlndkVariants() {
 		// This is an LLNDK library.  The implementation of the library will be on /system,
 		// and vendor and product variants will be created with LLNDK stubs.
 		// The LLNDK libraries need vendor variants even if there is no VNDK.
diff --git a/cc/library.go b/cc/library.go
index 3ac7e11..73215ed 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -402,11 +402,18 @@
 
 func (f *flagExporter) setProvider(ctx android.ModuleContext) {
 	ctx.SetProvider(FlagExporterInfoProvider, FlagExporterInfo{
-		IncludeDirs:       android.FirstUniquePaths(f.dirs),
+		// Comes from Export_include_dirs property, and those of exported transitive deps
+		IncludeDirs: android.FirstUniquePaths(f.dirs),
+		// Comes from Export_system_include_dirs property, and those of exported transitive deps
 		SystemIncludeDirs: android.FirstUniquePaths(f.systemDirs),
-		Flags:             f.flags,
-		Deps:              f.deps,
-		GeneratedHeaders:  f.headers,
+		// Used in very few places as a one-off way of adding extra defines.
+		Flags: f.flags,
+		// Used sparingly, for extra files that need to be explicitly exported to dependers,
+		// or for phony files to minimize ninja.
+		Deps: f.deps,
+		// For exported generated headers, such as exported aidl headers, proto headers, or
+		// sysprop headers.
+		GeneratedHeaders: f.headers,
 	})
 }
 
@@ -524,6 +531,8 @@
 			Direct(outputFilePath).
 			Build(),
 	})
+
+	ctx.SetProvider(FlagExporterInfoProvider, flagExporterInfoFromCcInfo(ctx, ccInfo))
 	if i, ok := handler.module.linker.(snapshotLibraryInterface); ok {
 		// Dependencies on this library will expect collectedSnapshotHeaders to
 		// be set, otherwise validation will fail. For now, set this to an empty
diff --git a/cc/linkable.go b/cc/linkable.go
index 8fe0b4a..7b5b446 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -106,9 +106,6 @@
 	// IsLlndkPublic returns true only for LLNDK (public) libs.
 	IsLlndkPublic() bool
 
-	// IsLlndkHeaders returns true if this module is an LLNDK headers module.
-	IsLlndkHeaders() bool
-
 	// IsLlndkLibrary returns true if this module is an LLNDK library module.
 	IsLlndkLibrary() bool
 
@@ -283,7 +280,7 @@
 	systemIncludes := android.PathsForBazelOut(ctx, ccInfo.SystemIncludes)
 
 	return FlagExporterInfo{
-		IncludeDirs:       includes,
-		SystemIncludeDirs: systemIncludes,
+		IncludeDirs:       android.FirstUniquePaths(includes),
+		SystemIncludeDirs: android.FirstUniquePaths(systemIncludes),
 	}
 }
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index ad19e47..88f3118 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -166,40 +166,6 @@
 	return ok
 }
 
-type llndkHeadersDecorator struct {
-	*libraryDecorator
-}
-
-func (llndk *llndkHeadersDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
-	deps.HeaderLibs = append(deps.HeaderLibs, llndk.Properties.Llndk.Export_llndk_headers...)
-	deps.ReexportHeaderLibHeaders = append(deps.ReexportHeaderLibHeaders,
-		llndk.Properties.Llndk.Export_llndk_headers...)
-	return deps
-}
-
-// llndk_headers contains a set of c/c++ llndk headers files which are imported
-// by other soongs cc modules.
-func llndkHeadersFactory() android.Module {
-	module, library := NewLibrary(android.DeviceSupported)
-	library.HeaderOnly()
-	module.stl = nil
-	module.sanitize = nil
-
-	decorator := &llndkHeadersDecorator{
-		libraryDecorator: library,
-	}
-
-	module.compiler = nil
-	module.linker = decorator
-	module.installer = nil
-	module.library = decorator
-
-	module.Init()
-
-	return module
-}
-
 func init() {
 	android.RegisterModuleType("llndk_library", LlndkLibraryFactory)
-	android.RegisterModuleType("llndk_headers", llndkHeadersFactory)
 }
diff --git a/cc/testing.go b/cc/testing.go
index ff32bff..bf89f62 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -569,7 +569,6 @@
 		ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
 		ctx.RegisterModuleType("cc_test", TestFactory)
 		ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
-		ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
 		ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
 		ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
 
@@ -686,7 +685,6 @@
 	ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
 	ctx.RegisterModuleType("cc_test", TestFactory)
 	ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
-	ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
 	ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
 	ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
 	ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index 2f68cca..c0082fb 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -180,16 +180,13 @@
 	if _, ok := m.linker.(*kernelHeadersDecorator); ok {
 		return false
 	}
-	// skip llndk_library and llndk_headers which are backward compatible
+	// skip LLNDK libraries which are backward compatible
 	if m.IsLlndk() {
 		return false
 	}
 	if _, ok := m.linker.(*llndkStubDecorator); ok {
 		return false
 	}
-	if _, ok := m.linker.(*llndkHeadersDecorator); ok {
-		return false
-	}
 
 	// Libraries
 	if l, ok := m.linker.(snapshotLibraryInterface); ok {
diff --git a/rust/rust.go b/rust/rust.go
index e1a69c0..74d2828 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -262,10 +262,6 @@
 	return false
 }
 
-func (m *Module) IsLlndkHeaders() bool {
-	return false
-}
-
 func (m *Module) IsLlndkLibrary() bool {
 	return false
 }