Index: lld/test/ELF/basic.s =================================================================== --- lld/test/ELF/basic.s +++ lld/test/ELF/basic.s @@ -218,6 +218,12 @@ # RUN: --check-prefix=INVRSP # INVRSP: invalid response file quoting: patatino +# Test erroring on a recursive response file, but only once. +# RUN: echo @%t.responsefile > %t.responsefile +# RUN: not ld.lld %t @%t.responsefile 2>&1 | FileCheck %s --check-prefix=RECRSP +# RECRSP: recursive expansion of: '{{.*}}.responsefile' +# RECRSP-NOT: recursive expansion of + # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \ # RUN: FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s # MISSING: cannot open {{.*}}.foo: [[MSG]] Index: lld/tools/lld/lld.cpp =================================================================== --- lld/tools/lld/lld.cpp +++ lld/tools/lld/lld.cpp @@ -89,7 +89,9 @@ SmallVector expandedArgs(v.data(), v.data() + v.size()); BumpPtrAllocator a; StringSaver saver(a); - cl::ExpandResponseFiles(saver, getDefaultQuotingStyle(), expandedArgs); + cl::ExpansionContext ECtx(saver.getAllocator(), getDefaultQuotingStyle()); + if (Error Err = ECtx.expandResponseFiles(expandedArgs)) + die(toString(std::move(Err))); for (auto it = expandedArgs.begin(); it + 1 != expandedArgs.end(); ++it) { if (StringRef(*it) != "-m") continue;