llvm.org GIT mirror llvm / 1f25117
[gold] -thinlto-object-suffix-replace: don't append new suffix if path does not end with old suffix Summary: This is to be consistent with lld behavior since rLLD340364. Reviewers: tejohnson Reviewed By: tejohnson Subscribers: steven_wu, eraman, mehdi_amini, inglorion, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D51060 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340380 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 2 years ago
2 changed file(s) with 14 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
2626 ; RUN: -shared %t1.thinlink.bc -o %t3
2727 ; RUN: diff %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
2828
29 ; If filename does not end with old suffix, no suffix change should occur,
30 ; so ".thinlto.bc" will simply be appended to the input file name.
31 ; RUN: rm -f %t1.thinlink.bc.thinlto.bc
32 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
33 ; RUN: -m elf_x86_64 \
34 ; RUN: --plugin-opt=thinlto \
35 ; RUN: --plugin-opt=thinlto-index-only \
36 ; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" \
37 ; RUN: -shared %t1.thinlink.bc -o /dev/null
38 ; RUN: ls %t1.thinlink.bc.thinlto.bc
39
2940 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3041 target triple = "x86_64-unknown-linux-gnu"
3142
666666 /// suffix matching \p OldSuffix with \p NewSuffix.
667667 static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix,
668668 StringRef NewSuffix) {
669 if (OldSuffix.empty() && NewSuffix.empty())
670 return Path;
671 StringRef NewPath = Path;
672 NewPath.consume_back(OldSuffix);
673 std::string NewNewPath = NewPath;
674 NewNewPath += NewSuffix;
675 return NewNewPath;
669 if (Path.consume_back(OldSuffix))
670 return (Path + NewSuffix).str();
671 return Path;
676672 }
677673
678674 // Returns true if S is valid as a C language identifier.