Merge "improve error handling for SourceRootDirs"
diff --git a/bp2build/bp2build_product_config.go b/bp2build/bp2build_product_config.go
index fdda35b..ab2f821 100644
--- a/bp2build/bp2build_product_config.go
+++ b/bp2build/bp2build_product_config.go
@@ -78,20 +78,18 @@
 	# currently lunched, product, turn this into a select with an arm for each product.
 	actual = "@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}",
 )
-
-alias(
-	name = "product_vars",
-	actual = select({
-		# TODO: When we start generating the platforms for more than just the
-		# currently lunched, product, this select should have an arm for each product.
-		"@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_constraint_value": "@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_product_vars",
-		"@soong_injection//product_config_platforms/products/aosp_arm_for_testing:aosp_arm_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_arm_for_testing:aosp_arm_for_testing_product_vars",
-		"@soong_injection//product_config_platforms/products/aosp_arm64_for_testing:aosp_arm64_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_arm64_for_testing:aosp_arm64_for_testing_product_vars",
-		"@soong_injection//product_config_platforms/products/aosp_x86_for_testing:aosp_x86_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_x86_for_testing:aosp_x86_for_testing_product_vars",
-		"@soong_injection//product_config_platforms/products/aosp_x86_64_for_testing:aosp_x86_64_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_x86_64_for_testing:aosp_x86_64_for_testing_product_vars",
-		"@soong_injection//product_config_platforms/products/aosp_arm64_for_testing_no_compression:aosp_arm64_for_testing_no_compression_constraint_value": "@soong_injection//product_config_platforms/products/aosp_arm64_for_testing_no_compression:aosp_arm64_for_testing_no_compression_product_vars",
-	}),
-)
+`)),
+		newFile(
+			"product_config_platforms",
+			"product_labels.bzl",
+			productReplacer.Replace(`
+# This file keeps a list of all the products in the android source tree, because they're
+# discovered as part of a preprocessing step before bazel runs.
+# TODO: When we start generating the platforms for more than just the
+# currently lunched product, they should all be listed here
+product_labels = [
+  "@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}"
+]
 `)),
 		newFile(
 			"product_config_platforms",
@@ -127,42 +125,5 @@
 `)),
 	}
 
-	// Add some products for testing
-	for _, arch := range []string{"arm", "arm64", "x86", "x86_64"} {
-		result = append(result, newFile(
-			fmt.Sprintf("product_config_platforms/products/aosp_%s_for_testing", arch),
-			"BUILD",
-			fmt.Sprintf(`
-package(default_visibility=[
-    "@soong_injection//product_config_platforms:__subpackages__",
-    "@//build/bazel/product_config:__subpackages__",
-])
-load("@//build/bazel/tests/products:aosp_%s.variables.bzl", _soong_variables = "variables")
-load("@//build/bazel/product_config:android_product.bzl", "android_product")
-
-android_product(
-    name = "aosp_%s_for_testing",
-    soong_variables = _soong_variables,
-)
-`, arch, arch)))
-	}
-	result = append(result, newFile(
-		"product_config_platforms/products/aosp_arm64_for_testing_no_compression",
-		"BUILD",
-		`
-package(default_visibility=[
-    "@soong_injection//product_config_platforms:__subpackages__",
-    "@//build/bazel/product_config:__subpackages__",
-])
-load("@bazel_skylib//lib:dicts.bzl", "dicts")
-load("@//build/bazel/tests/products:aosp_arm64.variables.bzl", _soong_variables = "variables")
-load("@//build/bazel/product_config:android_product.bzl", "android_product")
-
-android_product(
-    name = "aosp_arm64_for_testing_no_compression",
-    soong_variables = dicts.add(_soong_variables, {"CompressedApex": False}),
-)
-`))
-
 	return result, nil
 }
diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go
index 35c57f9..76c8e5d 100644
--- a/cc/config/riscv64_device.go
+++ b/cc/config/riscv64_device.go
@@ -28,6 +28,9 @@
 		"-fno-emulated-tls",
 		// For -fsanitize=shadow-call-stack.
 		"-ffixed-x18",
+		// A temporary fix for SExtWRemoval miscompilation bug.
+		"-mllvm",
+		"-riscv-disable-sextw-removal=true",
 	}
 
 	riscv64ArchVariantCflags = map[string][]string{}
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index 91e3540..fc56dd5 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -390,7 +390,7 @@
 		}
 	}
 
-	const maxErrors = 10
+	const maxErrors = 25
 
 	if len(incorrectOutputDirectoryErrors) > 0 {
 		errorMessage := ""
diff --git a/rust/protobuf.go b/rust/protobuf.go
index 88e80fe..e30f25d 100644
--- a/rust/protobuf.go
+++ b/rust/protobuf.go
@@ -73,7 +73,7 @@
 	outDir := android.PathForModuleOut(ctx)
 	protoFiles := android.PathsForModuleSrc(ctx, proto.Properties.Protos)
 	grpcFiles := android.PathsForModuleSrc(ctx, proto.Properties.Grpc_protos)
-	protoPluginPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+	protoPluginPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust-deprecated")
 
 	commonProtoFlags = append(commonProtoFlags, defaultProtobufFlags...)
 	commonProtoFlags = append(commonProtoFlags, proto.Properties.Proto_flags...)
@@ -206,7 +206,7 @@
 
 func (proto *protobufDecorator) SourceProviderDeps(ctx DepsContext, deps Deps) Deps {
 	deps = proto.BaseSourceProvider.SourceProviderDeps(ctx, deps)
-	deps.Rustlibs = append(deps.Rustlibs, "libprotobuf")
+	deps.Rustlibs = append(deps.Rustlibs, "libprotobuf_deprecated")
 	deps.HeaderLibs = append(deps.SharedLibs, proto.Properties.Header_libs...)
 
 	if len(proto.Properties.Grpc_protos) > 0 {
diff --git a/rust/protobuf_test.go b/rust/protobuf_test.go
index f0f5ec0..0aa4549 100644
--- a/rust/protobuf_test.go
+++ b/rust/protobuf_test.go
@@ -42,14 +42,14 @@
 	`)
 	// Check that libprotobuf is added as a dependency.
 	librust_proto := ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_dylib").Module().(*Module)
-	if !android.InList("libprotobuf", librust_proto.Properties.AndroidMkDylibs) {
-		t.Errorf("libprotobuf dependency missing for rust_protobuf (dependency missing from AndroidMkDylibs)")
+	if !android.InList("libprotobuf_deprecated", librust_proto.Properties.AndroidMkDylibs) {
+		t.Errorf("libprotobuf_deprecated dependency missing for rust_protobuf (dependency missing from AndroidMkDylibs)")
 	}
 
 	// Make sure the correct plugin is being used.
 	librust_proto_out := ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_source").Output("buf.rs")
 	cmd := librust_proto_out.RuleParams.Command
-	if w := "protoc-gen-rust"; !strings.Contains(cmd, w) {
+	if w := "protoc-gen-rust-deprecated"; !strings.Contains(cmd, w) {
 		t.Errorf("expected %q in %q", w, cmd)
 	}
 
diff --git a/rust/testing.go b/rust/testing.go
index 24ca3d6..a33d948 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -127,7 +127,7 @@
 			min_sdk_version: "29",
 		}
 		rust_library {
-			name: "libprotobuf",
+			name: "libprotobuf_deprecated",
 			crate_name: "protobuf",
 			srcs: ["foo.rs"],
 			host_supported: true,