Skip to content

Commit cc5b631

Browse files
committed
Fix thin archive member reproducer paths
Include the thin archive member name and child offset in the generated input identity. This prevents members with identical basenames from colliding in --reproduce archives and preserves both files during replay. Resolves #1737
1 parent c7cda1a commit cc5b631

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/Support/OutputTarWriter.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,17 @@ void OutputTarWriter::addInputFile(const InputFile *File, bool IsLTOObject) {
7474
}
7575

7676
std::string OutputTarWriter::getHashAndExtension(const Input *Ipt) const {
77+
uint64_t InputHash = Ipt->getResolvedPathHash();
78+
if (const auto *ArchiveMember = llvm::dyn_cast<ArchiveMemberInput>(Ipt))
79+
// Thin archive members share the parent archive's resolved path. Include
80+
// the member identity so members with the same basename cannot collide.
81+
InputHash = llvm::hash_combine(InputHash, ArchiveMember->getMemberName(),
82+
ArchiveMember->getChildOffset());
83+
7784
// Returns filename passed to the linker along with the file hash.
7885
return std::string(
7986
llvm::sys::path::filename(Ipt->getInputFile()->getMappedPath())) +
80-
"." + std::to_string(Ipt->getResolvedPathHash());
87+
"." + std::to_string(InputHash);
8188
}
8289

8390
/// Create mapping.ini file of input filepath to its sha2 hash + file extension

0 commit comments

Comments
 (0)