remove rust deps on clang prebuilts

Prebuilt modules for some clang tools were created in aosp/2746469, but they do not exist for darwin builds. Adding the same modules in prebuilts/clang/host/darwin-x86/Android.bp results in duplicate module names. Instead we can just get a path to these files directly in Soong.

Test: CI
Test: https://android-build.googleplex.com/builds/abtd/run/L90700000963131594
Change-Id: I620cfd7b1ab34bd0959feea562d599b963717198
diff --git a/rust/builder.go b/rust/builder.go
index 0740518..09933d3 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -22,6 +22,7 @@
 	"github.com/google/blueprint"
 
 	"android/soong/android"
+	cc_config "android/soong/cc/config"
 	"android/soong/rust/config"
 )
 
@@ -204,7 +205,9 @@
 		}
 	}
 
-	envVars = append(envVars, "AR="+cmd.PathForTool(deps.Llvm_ar))
+	envVars = append(envVars, "AR="+cmd.PathForInput(
+		cc_config.ClangPath(ctx, "bin/llvm-ar")),
+	)
 
 	if ctx.Darwin() {
 		envVars = append(envVars, "ANDROID_RUST_DARWIN=true")
@@ -292,11 +295,6 @@
 	}
 
 	if flags.Clippy {
-		// TODO(b/298461712) remove this hack to let slim manifest branches build
-		if deps.Clippy_driver == nil {
-			deps.Clippy_driver = config.RustPath(ctx, "bin/clippy-driver")
-		}
-
 		clippyRule := getRuleBuilder(ctx, pctx, false, "clippy")
 		clippyCmd := clippyRule.Command()
 		clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy")
@@ -305,7 +303,7 @@
 
 		clippyCmd.
 			Flags(rustEnvVars(ctx, deps, clippyCmd)).
-			Tool(deps.Clippy_driver).
+			Tool(config.RustPath(ctx, "bin/clippy-driver")).
 			Flag("--emit metadata").
 			FlagWithOutput("-o ", clippyFile).
 			FlagWithOutput("--emit dep-info=", clippyDepInfoFile).
@@ -365,14 +363,18 @@
 		}
 	}
 
-	// TODO(b/298461712) remove this hack to let slim manifest branches build
-	if deps.Rustc == nil {
-		deps.Rustc = config.RustPath(ctx, "bin/rustc")
+	clangTools := android.Paths{
+		cc_config.ClangPath(ctx, "bin/llvm-ar"),
+	}
+	if ctx.Config().BuildOS != android.Darwin {
+		clangTools = append(clangTools,
+			cc_config.ClangPath(ctx, "lib/libc++.so"),
+		)
 	}
 
 	rustcCmd.
 		Flags(rustEnvVars(ctx, deps, rustcCmd)).
-		Tool(deps.Rustc).
+		Tool(config.RustPath(ctx, "bin/rustc")).
 		FlagWithInput("-C linker=", android.PathForSource(ctx, "build", "soong", "scripts", "mkcratersp.py")).
 		Flag("--emit link").
 		Flag("-o").
@@ -380,6 +382,7 @@
 		FlagWithOutput("--emit dep-info=", depInfoFile).
 		Inputs(inputs).
 		Flags(libFlags).
+		Implicits(clangTools).
 		ImplicitTools(toolImplicits).
 		Implicits(implicits).
 		Flags(rustcFlags).
@@ -406,9 +409,20 @@
 		// those need to be renamed/symlinked to something in the rustLink sandbox
 		// if we want to separate the rules
 		linkerSboxOutputFile := android.PathForModuleOut(ctx, sboxDirectory, outputFile.Base())
+		clangTools := android.Paths{
+			cc_config.ClangPath(ctx, "bin/clang++"),
+			cc_config.ClangPath(ctx, "bin/lld"),
+			cc_config.ClangPath(ctx, "bin/ld.lld"),
+		}
+		if ctx.Config().BuildOS != android.Darwin {
+			clangTools = append(clangTools,
+				cc_config.ClangPath(ctx, "bin/clang++.real"),
+				cc_config.ClangPath(ctx, "lib/libc++.so"),
+			)
+		}
 		rustLinkCmd := rustcRule.Command()
 		rustLinkCmd.
-			Tool(deps.Clang).
+			Tool(cc_config.ClangPath(ctx, "bin/clang++")).
 			Flag("-o").
 			Output(linkerSboxOutputFile).
 			Inputs(deps.CrtBegin).
@@ -416,6 +430,7 @@
 			FlagWithInput("@", rustSboxOutputFile).
 			Flags(linkFlags).
 			Inputs(deps.CrtEnd).
+			ImplicitTools(clangTools).
 			ImplicitTools(toolImplicits).
 			Implicits(rustcImplicitOutputs.Paths()).
 			Implicits(implicits).
@@ -441,7 +456,7 @@
 			Flag("KYTHE_CANONICALIZE_VNAME_PATHS=prefer-relative").
 			Tool(ctx.Config().PrebuiltBuildTool(ctx, "rust_extractor")).
 			Flags(rustEnvVars(ctx, deps, kytheCmd)).
-			Tool(deps.Rustc).
+			Tool(config.RustPath(ctx, "bin/rustc")).
 			Flag("-C linker=true").
 			Inputs(inputs).
 			Flags(makeLibFlags(deps, kytheCmd)).
@@ -455,11 +470,6 @@
 }
 
 func Rustdoc(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags) android.ModuleOutPath {
-	// TODO(b/298461712) remove this hack to let slim manifest branches build
-	if deps.Rustdoc == nil {
-		deps.Rustdoc = config.RustPath(ctx, "bin/rustdoc")
-	}
-
 	rustdocRule := getRuleBuilder(ctx, pctx, false, "rustdoc")
 	rustdocCmd := rustdocRule.Command()
 
@@ -498,7 +508,7 @@
 
 	rustdocCmd.
 		Flags(rustEnvVars(ctx, deps, rustdocCmd)).
-		Tool(deps.Rustdoc).
+		Tool(config.RustPath(ctx, "bin/rustdoc")).
 		Flags(rustdocFlags).
 		Input(main).
 		Flag("-o "+docDir.String()).