-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
Summary: When adding one thin archive to another, we currently chop off the relative path to the flattened members. For instance, when adding `foo/child.a` (which contains `x.txt`) to `parent.a`, when flattening it we should add it as `foo/x.txt` (which exists) instead of `x.txt` (which does not exist). As a note, this also undoes the `IsNew` parameter of handling relative paths in r288280. The unit test there still passes. This was reported as part of testing the kernel build with llvm-ar: https://patchwork.kernel.org/patch/10767545/ (see the second point). Reviewers: mstorsjo, pcc, ruiu, davide, david2050, inglorion Reviewed By: ruiu Subscribers: void, jdoerfert, tpimh, mgorny, hans, nickdesaulniers, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57842 llvm-svn: 353995
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,13 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) { | |
|
||
// Create an archive file. | ||
std::string OutputPath = getOutputPath(&Args, Members[0]); | ||
// llvm-lib uses relative paths for both regular and thin archives, unlike | ||
// standard GNU ar, which only uses relative paths for thin archives and | ||
// basenames for regular archives. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mstorsjo
Member
|
||
for (NewArchiveMember &Member : Members) | ||
Member.MemberName = | ||
Saver.save(computeArchiveRelativePath(OutputPath, Member.MemberName)); | ||
|
||
if (Error E = | ||
writeArchive(OutputPath, Members, | ||
/*WriteSymtab=*/true, object::Archive::K_GNU, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This test creates a thin archive in a directory and adds it to a thin archive | ||
# in the parent directory. The relative path should be included when flattening | ||
# the archive. | ||
|
||
RUN: mkdir -p %t/foo | ||
RUN: touch %t/foo/a.txt | ||
RUN: rm -f %t/archive.a %t/foo/archive.a | ||
|
||
# These tests must be run in the same directory as %t/archive.a. cd %t is | ||
# included on each line to make debugging this test case easier. | ||
RUN: cd %t && llvm-ar rcST foo/archive.a foo/a.txt | ||
RUN: cd %t && llvm-ar rcST archive.a foo/archive.a | ||
RUN: cd %t && llvm-ar t archive.a | FileCheck %s --match-full-lines | ||
|
||
CHECK: foo/a.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
RUN: rm -rf %t | ||
RUN: mkdir -p %t/foo | ||
RUN: cd %t | ||
|
||
RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o foo/obj.o %S/Inputs/a.s | ||
|
||
RUN: llvm-lib -out:archive.a -llvmlibthin foo/obj.o | ||
RUN: llvm-ar t archive.a | FileCheck %s --check-prefix=PARENT-DIR --match-full-lines | ||
PARENT-DIR: foo/obj.o | ||
|
||
RUN: llvm-lib -out:foo/archive.a -llvmlibthin foo/obj.o | ||
RUN: llvm-ar t foo/archive.a | FileCheck %s --check-prefix=SAME-DIR --match-full-lines | ||
SAME-DIR: foo/obj.o |
This is a bit of code archeology here, but, does anyone (@rupprecht, @zmodem) happen to know why it was chosen to use different logic here (to always use paths relative to the archive) for llvm-lib, while it says that this only is done for thin archives, when using llvm-ar? I tried to read the code review at https://reviews.llvm.org/D57842 but I don't see it mentioned why it was decided to go this way.
I'm running into cases where the always-relative path logic is problematic.