Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm-lib] Don't rewrite paths for members in non-thin archives #123416

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

mstorsjo
Copy link
Member

This matches what MS lib.exe does (and llvm-ar too); when adding files to an archive, MS lib.exe stores the file name as it was given on the command line, whereas llvm-lib rewrote it into a relative path name, relative to the archive location. Such a rewrite makes sense for thin archives, but not for regular archives. (MS lib.exe doesn't support producing thin archives; that's an LLVM extension - see the thin-relative.test testcase.)

The behaviour to rewrite these paths was added in 451c2ef; it is unclear why it was chosen to do the rewriting for non-thin archives as well. This quirk is even pointed out in a code comment - but neither the code review at https://reviews.llvm.org/D57842 nor the linked bug report at https://crbug.com/41440160 mentions why this is done for all archives, not only thin ones.

Therefore, assume that this only was done out of convenience, and change llvm-lib to not adjust the paths for non-thin archives.

Normally, the actual member names doesn't matter for non-thin archives; however for short import libraries, where each member is named e.g. "foo.dll", the names do matter. If using llvm-lib to merge two import libraries (as a non-thin library), preserve the original names rather than making the member names relative.

This matches what MS lib.exe does (and llvm-ar too); MS lib.exe
doesn't produce relative paths when producing regular static
archives. (lib.exe doesn't support producing thin archives; that's
an LLVM extension; see the thin-relative.test testcase.)

It is unclear why 451c2ef chose
to extend this behaviour to non-thin archives in the case of llvm-lib
(and even mentioning it in a comment), while not doing that for
llvm-ar; the code review at https://reviews.llvm.org/D57842 or the
linked bug report at https://crbug.com/41440160 doesn't touch upon
that.

Therefore, assume that this only was done out of convenience, and
change llvm-lib to not adjust the paths for non-thin archives.

Normally, the actual member names doesn't matter for non-thin
archives; however for short import libraries, where each member
is named e.g. "foo.dll", the names do matter. If using llvm-lib
to merge two import libraries (as a non-thin library), preserve
the original names rather than making the member names relative.
Copy link
Contributor

@cjacek cjacek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and thanks for the comprehensive explanation.

@mstorsjo mstorsjo merged commit c912e98 into llvm:main Jan 21, 2025
9 checks passed
@mstorsjo mstorsjo deleted the llvm-lib-relative-path branch January 21, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants