Copy prebuilt objects to the intermediates directory

Copy prebuilt objects to the intermediate directory so that their
output file name matches the module name.  This simplifies using
the clang crt objects, whose input names vary by architecture,
in the musl sysroot genrule.

Bug: 216192129
Test: m checkbuild
Change-Id: I467d699f718e2cc5c6bf0a5c35820dedd51c5930
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 5980319..1f9c3fe 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -510,7 +510,16 @@
 func (p *prebuiltObjectLinker) link(ctx ModuleContext,
 	flags Flags, deps PathDeps, objs Objects) android.Path {
 	if len(p.properties.Srcs) > 0 {
-		return p.Prebuilt.SingleSourcePath(ctx)
+		// Copy objects to a name matching the final installed name
+		in := p.Prebuilt.SingleSourcePath(ctx)
+		outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".o")
+		ctx.Build(pctx, android.BuildParams{
+			Rule:        android.CpExecutable,
+			Description: "prebuilt",
+			Output:      outputFile,
+			Input:       in,
+		})
+		return outputFile
 	}
 	return nil
 }