[PATCH] use response files to pass arguments to the linker, fixes PR 15171

Tim Northover t.p.northover at gmail.com
Fri Mar 15 04:00:46 PDT 2013


> The attached patch fixes this issue by simply using a response file all the time for passing arguments to the linker.

I'm a little concerned about the debugging implications of this. It
adds an extra step to finding out just what Clang is doing with your
command-line when things go wrong. For example, before the change:

$ bin/clang tmp.o tmp1.o -otmp -###
clang version 3.3
Target: aarch64-oe-linux
Thread model: posix
 "/opt/aarch64-oe/sysroots/x86_64-oesdk-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-ld"
"--sysroot=/opt/aarch64-oe/sysroots/aarch64-oe-linux" "--eh-frame-hdr"
"-m" "aarch64linux" "-dynamic-linker" "/lib/ld-linux-aarch64.so.1"
"-o" "tmp" "/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/../../crt1.o"
"/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/../../crti.o"
"/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/crtbegin.o"
"-L/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3"
"-L/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/../../aarch64-oe-linux"
"-L/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux"
"-L/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/../.."
"-L/opt/aarch64-oe/sysroots/aarch64-oe-linux/lib"
"-L/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib" "tmp.o" "tmp1.o"
"-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc"
"--as-needed" "-lgcc_s" "--no-as-needed"
"/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/crtend.o"
"/opt/aarch64-oe/sysroots/aarch64-oe-linux/usr/lib/aarch64-oe-linux/4.7.3/../../crtn.o"

after:

$ bin/clang tmp.o tmp1.o -otmp -###
clang version 3.3
Target: aarch64-oe-linux
Thread model: posix
 "/opt/aarch64-oe/sysroots/x86_64-oesdk-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-ld"
"@/tmp/response-file-6psWPX..tmp"

I suppose on the other hand, the format of that temporary file is
actually easier to look at than the original since it's split onto
multiple lines.

There also appears to be a typo in the patch you sent (using "JS"
instead of "JA"):

@@ -4550,9 +4596,7 @@ void darwin::Link::ConstructJob(Compilation &C,
const JobAction &JA,
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_F);

-  const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath("ld"));
-  C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+  AddLinkerJob(C, JS, *this, Args, CmdArgs, "ld", true);
 }

Finally, it causes about 20 test failures (presumably because tests
were relying on the command-line inspection ability I mentioned
above).

Cheers.

Tim.



More information about the cfe-commits mailing list