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(); 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"