Use @files for ld and ar

ld and ar command lines often end up larger than ARG_MAX, use Ninja's
rsp file support to automatically write the object files to a temporary
file and pass it in using @file support.

This isn't going to work on Darwin host builds, where the host
toolchains don't support @.

Change-Id: Ida2f4e114ab02df6967e863577fa324e197827d5
diff --git a/cc/builder.go b/cc/builder.go
index c843c2d..cb2bf9a 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -47,9 +47,11 @@
 
 	ld = pctx.StaticRule("ld",
 		blueprint.RuleParams{
-			Command: "$ldCmd ${ldDirFlags} ${crtBegin} ${in} " +
+			Command: "$ldCmd ${ldDirFlags} ${crtBegin} @${out}.rsp " +
 				"${libFlags} ${crtEnd} -o ${out} ${ldFlags} ${ldLibs}",
-			Description: "ld $out",
+			Description:    "ld $out",
+			Rspfile:        "${out}.rsp",
+			RspfileContent: "${in}",
 		},
 		"ldCmd", "ldDirFlags", "crtBegin", "libFlags", "crtEnd", "ldFlags", "ldLibs")
 
@@ -62,8 +64,10 @@
 
 	ar = pctx.StaticRule("ar",
 		blueprint.RuleParams{
-			Command:     "rm -f ${out} && $arCmd $arFlags $out $in",
-			Description: "ar $out",
+			Command:        "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
+			Description:    "ar $out",
+			Rspfile:        "${out}.rsp",
+			RspfileContent: "${in}",
 		},
 		"arCmd", "arFlags")