[llvm-branch-commits] [lld] d20abb1 - [mac/lld] Add support for response files

Nico Weber via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 30 05:28:37 PST 2020


Author: Nico Weber
Date: 2020-11-30T08:23:58-05:00
New Revision: d20abb1ec3b6ff90cc4221e6a5865ae22fa2f5e9

URL: https://github.com/llvm/llvm-project/commit/d20abb1ec3b6ff90cc4221e6a5865ae22fa2f5e9
DIFF: https://github.com/llvm/llvm-project/commit/d20abb1ec3b6ff90cc4221e6a5865ae22fa2f5e9.diff

LOG: [mac/lld] Add support for response files

ld64 learned about them in Xcode 12, so we should too.

Differential Revision: https://reviews.llvm.org/D92149

Added: 
    lld/test/MachO/responsefile.test

Modified: 
    lld/MachO/DriverUtils.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 0322c20fcb69..d17a8215f6a3 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
 #include "llvm/TextAPI/MachO/TextAPIReader.h"
 
@@ -68,6 +69,9 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
   unsigned missingCount;
   SmallVector<const char *, 256> vec(argv.data(), argv.data() + argv.size());
 
+  // Expand response files (arguments in the form of @<filename>)
+  // and then parse the argument again.
+  cl::ExpandResponseFiles(saver, cl::TokenizeGNUCommandLine, vec);
   opt::InputArgList args = ParseArgs(vec, missingIndex, missingCount);
 
   if (missingCount)

diff  --git a/lld/test/MachO/responsefile.test b/lld/test/MachO/responsefile.test
new file mode 100644
index 000000000000..1db3ae93e720
--- /dev/null
+++ b/lld/test/MachO/responsefile.test
@@ -0,0 +1,4 @@
+# RUN: echo --help > %t.rsp
+
+# RUN: %lld @%t.rsp | FileCheck %s
+CHECK: OVERVIEW: LLVM Linker


        


More information about the llvm-branch-commits mailing list