[lld] 7baf1db - [ELF] Strip directories for -Map when emitting reproducer rsp

Alex Brachet via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 09:18:11 PDT 2022


Author: Alex Brachet
Date: 2022-07-29T16:17:33Z
New Revision: 7baf1db3923cd959075ddf42b723d36240b30753

URL: https://github.com/llvm/llvm-project/commit/7baf1db3923cd959075ddf42b723d36240b30753
DIFF: https://github.com/llvm/llvm-project/commit/7baf1db3923cd959075ddf42b723d36240b30753.diff

LOG: [ELF] Strip directories for -Map when emitting reproducer rsp

Similarly to -o output directories will not be created so -Map being
copied verbatim will likely cause ld.lld @response.txt to fail.

Differential Revision: https://reviews.llvm.org/D130681

Added: 
    

Modified: 
    lld/ELF/DriverUtils.cpp
    lld/test/ELF/reproduce.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 51f3dc3a056e..150755f38181 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -169,11 +169,13 @@ std::string elf::createResponseFile(const opt::InputArgList &args) {
       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
+    case OPT_Map:
+      // If an output 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(path::filename(arg->getValue())) << "\n";
+      os << arg->getSpelling() << ' ' << quote(path::filename(arg->getValue()))
+         << "\n";
       break;
     case OPT_lto_sample_profile:
       os << arg->getSpelling() << quote(rewritePath(arg->getValue())) << "\n";

diff  --git a/lld/test/ELF/reproduce.s b/lld/test/ELF/reproduce.s
index f143752b64d3..4a0fe0328e9a 100644
--- a/lld/test/ELF/reproduce.s
+++ b/lld/test/ELF/reproduce.s
@@ -74,9 +74,10 @@
 ## Check that directory path is stripped from -o <file-path>
 # RUN: mkdir -p %t.dir/build4/a/b/c
 # RUN: cd %t.dir
-# RUN: ld.lld build1/foo.o -o build4/a/b/c/bar -shared --as-needed --reproduce=repro4.tar
+# RUN: ld.lld build1/foo.o -o build4/a/b/c/bar -Map build4/a/b/c/map -shared --as-needed --reproduce=repro4.tar
 # RUN: tar xOf repro4.tar repro4/response.txt | FileCheck %s --check-prefix=RSP4
 # RSP4: -o bar
+# RSP4: -Map map
 
 .globl _start
 _start:


        


More information about the llvm-commits mailing list