This is an archive of the discontinued LLVM Phabricator instance.

[objcopy][NFC] Rename files to avoid clashing of archive members.
ClosedPublic

Authored by avl on Feb 22 2022, 12:11 PM.

Details

Summary

libtool uses file names to name members of an static library.
Files, located in different directories and having matching name,
would have the same name inside an archive. This is not a problem
for ld, but may be a problem for ar. This patch renames files
from ObjCopy library to avoid names clashing.

See https://reviews.llvm.org/D88827#3335814

Diff Detail

Event Timeline

avl created this revision.Feb 22 2022, 12:11 PM
avl requested review of this revision.Feb 22 2022, 12:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2022, 12:11 PM
MaskRay accepted this revision.EditedFeb 22 2022, 12:29 PM

I think the main benefit is that if you open two files of the same basename in an editor, it may look better.

libtool uses file names to name members of an static library.

This is also a problem for regular (non-thin) archives in all(?) other formats, including GNU.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ar.html says

All file operands can be pathnames. However, files within archives shall be named by a filename, which is the last component of the pathname used when the file was entered into the archive. The comparison of file operands to the names of files in archives shall be performed by comparing the last component of the operand to the name of the file in the archive.

Having / is therefore not compliant.

This revision is now accepted and ready to land.Feb 22 2022, 12:29 PM
jhenderson accepted this revision.Feb 23 2022, 12:32 AM

LGTM too!

This revision was landed with ongoing or failed builds.Feb 23 2022, 2:07 AM
This revision was automatically updated to reflect the committed changes.