From d20abb1ec3b6ff90cc4221e6a5865ae22fa2f5e9 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 25 Nov 2020 21:48:27 -0500 Subject: [PATCH] [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 --- lld/MachO/DriverUtils.cpp | 4 ++++ lld/test/MachO/responsefile.test | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 lld/test/MachO/responsefile.test diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp index 0322c20..d17a821 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 argv) { unsigned missingCount; SmallVector vec(argv.data(), argv.data() + argv.size()); + // Expand response files (arguments in the form of @) + // 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 0000000..1db3ae9 --- /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 -- 2.7.4