[lld] r293792 - Strip file path from the -o option while creating reproduce.txt.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 10:04:45 PST 2017
Author: rafael
Date: Wed Feb 1 12:04:45 2017
New Revision: 293792
URL: http://llvm.org/viewvc/llvm-project?rev=293792&view=rev
Log:
Strip file path from the -o option while creating reproduce.txt.
This is a fix for Bugzilla 28579.
The problem is that in --reproduce links the file path in -o option is
copied verbatim. When "lld @response.txt" link is run against the
extracted test case, if -o contains anything other that a plain file
name, the link will likely fail because the target directory in -o may
not exists. Stripping the directory path will create the output file
in the top level test directory.
Patch by Dmitry Mikulin!
Modified:
lld/trunk/ELF/DriverUtils.cpp
lld/trunk/test/ELF/reproduce.s
Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=293792&r1=293791&r2=293792&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Wed Feb 1 12:04:45 2017
@@ -135,6 +135,13 @@ std::string elf::createResponseFile(cons
case OPT_INPUT:
OS << quote(rewritePath(Arg->getValue())) << "\n";
break;
+ case OPT_o:
+ // If -o path contains directories, "lld @response.txt" will likely
+ // fail because the archive we are creating doesn't contain empty
+ // directories for the output path (-o doesn't create directories).
+ // Strip directories to prevent the issue.
+ OS << "-o " << quote(sys::path::filename(Arg->getValue())) << "\n";
+ break;
case OPT_L:
case OPT_dynamic_list:
case OPT_rpath:
Modified: lld/trunk/test/ELF/reproduce.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/reproduce.s?rev=293792&r1=293791&r2=293792&view=diff
==============================================================================
--- lld/trunk/test/ELF/reproduce.s (original)
+++ lld/trunk/test/ELF/reproduce.s Wed Feb 1 12:04:45 2017
@@ -60,6 +60,14 @@
# CHECK-NEXT: repro2/{{.*}}/file2
# CHECK-NEXT: repro2/{{.*}}/file
+## Check that directory path is stripped from -o <file-path>
+# RUN: mkdir -p %t.dir/build3/a/b/c
+# RUN: cd %t.dir
+# RUN: ld.lld build1/foo.o -o build3/a/b/c/bar -shared --as-needed --reproduce repro3.tar
+# RUN: tar xf repro3.tar
+# RUN: FileCheck %s --check-prefix=RSP3 < repro3/response.txt
+# RSP3: -o bar
+
.globl _start
_start:
mov $60, %rax
More information about the llvm-commits
mailing list