Merge "build_flag: when printing all flags, sort them." into main
diff --git a/apex/apex.go b/apex/apex.go
index e79afad..4c97fdb 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2128,7 +2128,7 @@
 			}
 		case prebuiltTag:
 			if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
-				filesToCopy, _ := prebuilt.OutputFiles("")
+				filesToCopy := android.OutputFilesForModule(ctx, prebuilt, "")
 				for _, etcFile := range filesToCopy {
 					vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile))
 				}
@@ -2274,7 +2274,7 @@
 		// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
 	} else if java.IsXmlPermissionsFileDepTag(depTag) {
 		if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
-			filesToCopy, _ := prebuilt.OutputFiles("")
+			filesToCopy := android.OutputFilesForModule(ctx, prebuilt, "")
 			for _, etcFile := range filesToCopy {
 				vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile))
 			}
diff --git a/cc/builder.go b/cc/builder.go
index 7a3394a..8719d4f 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -485,7 +485,7 @@
 		coverageFiles = make(android.Paths, 0, len(srcFiles))
 	}
 	var kytheFiles android.Paths
-	if flags.emitXrefs {
+	if flags.emitXrefs && ctx.Module() == ctx.PrimaryModule() {
 		kytheFiles = make(android.Paths, 0, len(srcFiles))
 	}
 
@@ -664,7 +664,7 @@
 		})
 
 		// Register post-process build statements (such as for tidy or kythe).
-		if emitXref {
+		if emitXref && ctx.Module() == ctx.PrimaryModule() {
 			kytheFile := android.ObjPathWithExt(ctx, subdir, srcFile, "kzip")
 			ctx.Build(pctx, android.BuildParams{
 				Rule:        kytheExtract,
diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go
index 5712d5e..9ac6350 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -489,16 +489,23 @@
 		return "library"
 	case *testBinary:
 		return "executable"
+	case *benchmarkDecorator:
+		return "executable"
 	}
-	panic(fmt.Sprintf("Unexpected module type: %T", m.compiler))
+	panic(fmt.Sprintf("Unexpected module type: %T", m.linker))
 }
 
 func getExtraLibs(m *Module) []string {
 	switch decorator := m.linker.(type) {
 	case *testBinary:
 		if decorator.testDecorator.gtest() {
-			return []string{"libgtest"}
+			return []string{
+				"libgtest",
+				"libgtest_main",
+			}
 		}
+	case *benchmarkDecorator:
+		return []string{"libgoogle-benchmark"}
 	}
 	return nil
 }
diff --git a/cc/config/global.go b/cc/config/global.go
index 290a27d..62a4765 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -300,6 +300,9 @@
 		// New warnings to be fixed after clang-r475365
 		"-Wno-error=single-bit-bitfield-constant-conversion", // http://b/243965903
 		"-Wno-error=enum-constexpr-conversion",               // http://b/243964282
+		// New warnings to be fixed after clang-r522817
+		"-Wno-error=invalid-offsetof",
+		"-Wno-error=thread-safety-reference-return",
 
 		// Irrelevant on Android because _we_ don't use exceptions, but causes
 		// lots of build noise because libcxx/libcxxabi do. This can probably
@@ -307,6 +310,9 @@
 		// until then because it causes warnings in the _callers_, not the
 		// project itself.
 		"-Wno-deprecated-dynamic-exception-spec",
+
+		// Allow using VLA CXX extension.
+		"-Wno-vla-cxx-extension",
 	}
 
 	noOverride64GlobalCflags = []string{}
@@ -391,7 +397,7 @@
 
 	// prebuilts/clang default settings.
 	ClangDefaultBase         = "prebuilts/clang/host"
-	ClangDefaultVersion      = "clang-r510928"
+	ClangDefaultVersion      = "clang-r522817"
 	ClangDefaultShortVersion = "18"
 
 	// Directories with warnings from Android.bp files.
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 5b86c64..d612e9e 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -15,9 +15,10 @@
 package cc
 
 import (
+	"strings"
+
 	"android/soong/android"
 	"android/soong/etc"
-	"strings"
 )
 
 var (
@@ -96,7 +97,6 @@
 }
 
 var _ etc.PrebuiltEtcModule = &llndkLibrariesTxtModule{}
-var _ android.OutputFileProducer = &llndkLibrariesTxtModule{}
 
 // llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries
 // generated by Soong but can be referenced by other modules.
@@ -118,6 +118,8 @@
 
 	installPath := android.PathForModuleInstall(ctx, "etc")
 	ctx.InstallFile(installPath, filename, txt.outputFile)
+
+	ctx.SetOutputFiles(android.Paths{txt.outputFile}, "")
 }
 
 func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.SingletonContext) {
@@ -162,11 +164,6 @@
 }
 
 // PrebuiltEtcModule interface
-func (txt *llndkLibrariesTxtModule) OutputFile() android.OutputPath {
-	return txt.outputFile
-}
-
-// PrebuiltEtcModule interface
 func (txt *llndkLibrariesTxtModule) BaseDir() string {
 	return "etc"
 }
diff --git a/cc/sanitize.go b/cc/sanitize.go
index e6075ad..3abba80 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1798,7 +1798,6 @@
 }
 
 var _ etc.PrebuiltEtcModule = (*sanitizerLibrariesTxtModule)(nil)
-var _ android.OutputFileProducer = (*sanitizerLibrariesTxtModule)(nil)
 
 func RegisterSanitizerLibrariesTxtType(ctx android.RegistrationContext) {
 	ctx.RegisterModuleType("sanitizer_libraries_txt", sanitizerLibrariesTxtFactory)
@@ -1886,6 +1885,8 @@
 
 	installPath := android.PathForModuleInstall(ctx, "etc")
 	ctx.InstallFile(installPath, filename, txt.outputFile)
+
+	ctx.SetOutputFiles(android.Paths{txt.outputFile}, "")
 }
 
 func (txt *sanitizerLibrariesTxtModule) AndroidMkEntries() []android.AndroidMkEntries {
@@ -1896,11 +1897,6 @@
 }
 
 // PrebuiltEtcModule interface
-func (txt *sanitizerLibrariesTxtModule) OutputFile() android.OutputPath {
-	return txt.outputFile
-}
-
-// PrebuiltEtcModule interface
 func (txt *sanitizerLibrariesTxtModule) BaseDir() string {
 	return "etc"
 }
diff --git a/cc/vndk.go b/cc/vndk.go
index ea55835..7141ea8 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -396,7 +396,6 @@
 }
 
 var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
-var _ android.OutputFileProducer = &vndkLibrariesTxt{}
 
 // vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries
 // generated by Soong but can be referenced by other modules.
@@ -455,6 +454,8 @@
 
 	installPath := android.PathForModuleInstall(ctx, "etc")
 	ctx.InstallFile(installPath, filename, txt.outputFile)
+
+	ctx.SetOutputFiles(android.Paths{txt.outputFile}, "")
 }
 
 func (txt *vndkLibrariesTxt) GenerateSingletonBuildActions(ctx android.SingletonContext) {
@@ -497,11 +498,6 @@
 }
 
 // PrebuiltEtcModule interface
-func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
-	return txt.outputFile
-}
-
-// PrebuiltEtcModule interface
 func (txt *vndkLibrariesTxt) BaseDir() string {
 	return "etc"
 }
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index fd3b27f..c1a0b9c 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -133,10 +133,6 @@
 
 	// Returns the sub install directory relative to BaseDir().
 	SubDir() string
-
-	// Returns an android.OutputPath to the intermediate file, which is the renamed prebuilt source
-	// file.
-	OutputFiles(tag string) (android.Paths, error)
 }
 
 type PrebuiltEtc struct {
diff --git a/java/base.go b/java/base.go
index b4f800b..1a6584b 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1852,7 +1852,7 @@
 	classes := android.PathForModuleOut(ctx, "javac", jarName).OutputPath
 	TransformJavaToClasses(ctx, classes, idx, srcFiles, srcJars, annoSrcJar, flags, extraJarDeps)
 
-	if ctx.Config().EmitXrefRules() {
+	if ctx.Config().EmitXrefRules() && ctx.Module() == ctx.PrimaryModule() {
 		extractionFile := android.PathForModuleOut(ctx, kzipName)
 		emitXrefRule(ctx, extractionFile, idx, srcFiles, srcJars, flags, extraJarDeps)
 		j.kytheFiles = append(j.kytheFiles, extractionFile)
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 6c1a38d..e9fa83a 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -3252,11 +3252,6 @@
 	return "permissions"
 }
 
-// from android.PrebuiltEtcModule
-func (module *sdkLibraryXml) OutputFiles(tag string) (android.Paths, error) {
-	return android.OutputPaths{module.outputFilePath}.Paths(), nil
-}
-
 var _ etc.PrebuiltEtcModule = (*sdkLibraryXml)(nil)
 
 // from android.ApexModule
@@ -3400,6 +3395,8 @@
 
 	module.installDirPath = android.PathForModuleInstall(ctx, "etc", module.SubDir())
 	ctx.PackageFile(module.installDirPath, libName+".xml", module.outputFilePath)
+
+	ctx.SetOutputFiles(android.OutputPaths{module.outputFilePath}.Paths(), "")
 }
 
 func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index 98aa408..3a8d3cf 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -15,7 +15,6 @@
 package linkerconfig
 
 import (
-	"fmt"
 	"sort"
 	"strings"
 
@@ -73,17 +72,6 @@
 	return l.outputFilePath
 }
 
-var _ android.OutputFileProducer = (*linkerConfig)(nil)
-
-func (l *linkerConfig) OutputFiles(tag string) (android.Paths, error) {
-	switch tag {
-	case "":
-		return android.Paths{l.outputFilePath}, nil
-	default:
-		return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-	}
-}
-
 func (l *linkerConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	input := android.PathForModuleSrc(ctx, android.String(l.properties.Src))
 	output := android.PathForModuleOut(ctx, "linker.config.pb").OutputPath
@@ -98,6 +86,8 @@
 		l.SkipInstall()
 	}
 	ctx.InstallFile(l.installDirPath, l.outputFilePath.Base(), l.outputFilePath)
+
+	ctx.SetOutputFiles(android.Paths{l.outputFilePath}, "")
 }
 
 func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder,
diff --git a/rust/config/global.go b/rust/config/global.go
index e83e23a..6943467 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
 var (
 	pctx = android.NewPackageContext("android/soong/rust/config")
 
-	RustDefaultVersion = "1.77.1.p1"
+	RustDefaultVersion = "1.78.0"
 	RustDefaultBase    = "prebuilts/rust/"
 	DefaultEdition     = "2021"
 	Stdlibs            = []string{