diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp index 0322c20fcb6936..d17a8215f6a3f1 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 00000000000000..1db3ae93e7208c --- /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