[llvm-bugs] [Bug 38542] New: llvm-ar 'Replace' option adds duplicate files to thin archives
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 13 06:27:35 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38542
Bug ID: 38542
Summary: llvm-ar 'Replace' option adds duplicate files to thin
archives
Product: tools
Version: 6.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: llvm-ar
Assignee: unassignedbugs at nondot.org
Reporter: wdelgenio at ocient.com
CC: llvm-bugs at lists.llvm.org
When creating thin archives, the 'Replace' option is buggy and will allow for
multiple copies of the same object file within the archive iff the object file
is not in the current directory.
Steps to reproduce:
mkdir foo
clang -c -x c /dev/null -o foo/test.o
llvm-ar Trcs test.a foo/test.o
llvm-ar Trcs test.a foo/test.o
llvm-ar t test.a
Output:
/foo/test.o
/foo/test.o
The bug appears to be in computerInsertAction() in llvm-ar.cpp:
auto MI = find_if(Members, [Name](StringRef Path) {
return Name == sys::path::filename(Path);
});
The objects files are stored with the full path in the thin archive format, but
sys::path::filename will throw out the path, making the find_if function fail
every time unless the object file is in the current directory. Ie in the
example above Name = "/foo/test.o" and sys::path::filename(Path) = "test.o".
I think the fix is to check if it's a thin archive, and if so, compare Name and
Path without the call to filename().
Will that work?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180813/cf58cd1c/attachment.html>
More information about the llvm-bugs
mailing list