pass ldflags to partial ld rules

x86 crt partial ld steps need to pass -m32 through ldflags.  Use gcc to
run partial ld instead of going directly to ld.  Allows reusing
ToolchainLdflags, which have linker arguments prefixed with "-Wl,".

Change-Id: I1e01ca5831061a11c9f550ab198d8e5b8dccf8bd
diff --git a/cc/builder.go b/cc/builder.go
index a1d7f2c..e3b9983 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -63,11 +63,11 @@
 
 	partialLd = pctx.StaticRule("partialLd",
 		blueprint.RuleParams{
-			Command:     "$ldCmd -r ${in} -o ${out}",
+			Command:     "$ldCmd -nostdlib -Wl,-r ${in} -o ${out} ${ldFlags}",
 			CommandDeps: []string{"$ldCmd"},
 			Description: "partialLd $out",
 		},
-		"ldCmd")
+		"ldCmd", "ldFlags")
 
 	ar = pctx.StaticRule("ar",
 		blueprint.RuleParams{
@@ -370,7 +370,12 @@
 func TransformObjsToObj(ctx common.AndroidModuleContext, objFiles []string,
 	flags builderFlags, outputFile string) {
 
-	ldCmd := gccCmd(flags.toolchain, "ld")
+	var ldCmd string
+	if flags.clang {
+		ldCmd = "${clangPath}clang++"
+	} else {
+		ldCmd = gccCmd(flags.toolchain, "g++")
+	}
 
 	ctx.Build(pctx, blueprint.BuildParams{
 		Rule:    partialLd,
@@ -378,6 +383,7 @@
 		Inputs:  objFiles,
 		Args: map[string]string{
 			"ldCmd": ldCmd,
+			"ldFlags": flags.ldFlags,
 		},
 	})
 }