[PATCH] D51055: [ELF] -thinlto-object-suffix-replace=: don't error if the path does not end with old suffix

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 21 16:29:05 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340364: [ELF] -thinlto-object-suffix-replace=: don't error if the path does not end… (authored by MaskRay, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D51055

Files:
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/test/ELF/lto/thinlto-object-suffix-replace.ll


Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -1290,12 +1290,9 @@
   StringRef Suffix = Config->ThinLTOObjectSuffixReplace.first;
   StringRef Repl = Config->ThinLTOObjectSuffixReplace.second;
 
-  if (!Path.endswith(Suffix)) {
-    error("-thinlto-object-suffix-replace=" + Suffix + ";" + Repl +
-          " was given, but " + Path + " does not end with the suffix");
-    return "";
-  }
-  return (Path.drop_back(Suffix.size()) + Repl).str();
+  if (Path.consume_back(Suffix))
+    return (Path + Repl).str();
+  return Path;
 }
 
 template void ArchiveFile::parse<ELF32LE>();
Index: lld/trunk/test/ELF/lto/thinlto-object-suffix-replace.ll
===================================================================
--- lld/trunk/test/ELF/lto/thinlto-object-suffix-replace.ll
+++ lld/trunk/test/ELF/lto/thinlto-object-suffix-replace.ll
@@ -29,12 +29,12 @@
 ; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR1
 ; ERR1: --plugin-opt=thinlto-object-suffix-replace= expects 'old;new' format, but got abc:def
 
-; Ensure lld generates error if old suffix doesn't exist in file name
-; RUN: rm -f %t1.o
-; RUN: not ld.lld --plugin-opt=thinlto-index-only \
-; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc \
-; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR2
-; ERR2: error: -thinlto-object-suffix-replace=.abc;.o was given, but {{.*}} does not end with the suffix
+; If filename does not end with old suffix, no suffix change should occur,
+; so ".thinlto.bc" will simply be appended to the input file name.
+; RUN: rm -f %t1.thinlink.bc.thinlto.bc
+; RUN: ld.lld --plugin-opt=thinlto-index-only \
+; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc -o /dev/null
+; RUN: ls %t1.thinlink.bc.thinlto.bc
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51055.161839.patch
Type: text/x-patch
Size: 2000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180821/6054f2cd/attachment.bin>


More information about the llvm-commits mailing list