diff options
-rw-r--r-- | lld/ELF/DriverUtils.cpp | 30 | ||||
-rw-r--r-- | lld/test/ELF/reproduce.s | 7 |
2 files changed, 23 insertions, 14 deletions
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index 8174722d22b..9fd869cb549 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -137,6 +137,12 @@ static std::string quote(StringRef S) { return ("\"" + S + "\"").str(); } +static std::string rewritePath(StringRef S) { + if (fs::exists(S)) + return getDestPath(S); + return S; +} + // Copies all input files to Config->Reproduce directory and // create a response file as "response.txt", so that you can re-run // the same command with the same inputs just by executing @@ -157,25 +163,25 @@ void elf::createResponseFile(const llvm::opt::InputArgList &Args) { raw_fd_ostream OS(Path, EC, sys::fs::OpenFlags::F_None); check(EC); - // Dump the command line to response.txt while copying files - // and rewriting paths. + // Copy the command line to response.txt while rewriting paths. for (auto *Arg : Args) { switch (Arg->getOption().getID()) { case OPT_reproduce: break; + case OPT_INPUT: + OS << quote(rewritePath(Arg->getValue())) << "\n"; + break; + case OPT_L: + case OPT_dynamic_list: + case OPT_export_dynamic_symbol: + case OPT_rpath: case OPT_script: - OS << "--script "; - // fallthrough - case OPT_INPUT: { - StringRef Path = Arg->getValue(); - if (fs::exists(Path)) - OS << quote(getDestPath(Path)) << "\n"; - else - OS << quote(Path) << "\n"; + case OPT_version_script: + OS << Arg->getSpelling() << " " + << quote(rewritePath(Arg->getValue())) << "\n"; break; - } default: - OS << Arg->getAsString(Args) << "\n"; + OS << quote(Arg->getAsString(Args)) << "\n"; } } } diff --git a/lld/test/ELF/reproduce.s b/lld/test/ELF/reproduce.s index e182f06f7f7..e263cc9166c 100644 --- a/lld/test/ELF/reproduce.s +++ b/lld/test/ELF/reproduce.s @@ -19,10 +19,13 @@ # RUN: ld.lld ./../../../foo.o -o bar -shared --as-needed --reproduce repro # RUN: diff %t.dir/build2/foo.o repro/%:t.dir/build2/foo.o -# RUN: not ld.lld build1/foo.o --reproduce repro2 'foo bar' -soname=foo +# RUN: touch file +# RUN: not ld.lld --reproduce repro2 'foo bar' -L"foo bar" -Lfile -version-script file # RUN: FileCheck %s --check-prefix=RSP2 < repro2/response.txt # RSP2: "foo bar" -# RSP2-NEXT: -soname=foo +# RSP2-NEXT: -L "foo bar" +# RSP2-NEXT: -L {{.+}}file +# RSP2-NEXT: -version-script {{.+}}file # RUN: not ld.lld build1/foo.o -o bar -shared --as-needed --reproduce . 2>&1 \ # RUN: | FileCheck --check-prefix=ERROR %s |