This is an archive of the discontinued LLVM Phabricator instance.

[Object] Deduplicate long archive member names
ClosedPublic

Authored by Lekensteyn on Dec 18 2018, 3:29 PM.

Details

Summary

Import libraries as created by llvm-dlltool always use the same archive
member name for every object file (namely, the DLL library name). Ensure
that long names are not repeatedly stored in the string table.

Diff Detail

Repository
rL LLVM

Event Timeline

Lekensteyn created this revision.Dec 18 2018, 3:29 PM

I'm not intimately familiar with the structure of ar files, but the change looks like it makes sense to me at least. Does MSVC link.exe produce import libraries with deduplicated member names as well?

I think the change is possible to apply as such, but it'd be better if the diff was made with more context included (diff -U9999).

I'm not intimately familiar with the structure of ar files, but the change looks like it makes sense to me at least. Does MSVC link.exe produce import libraries with deduplicated member names as well?

Yes it does deduplicate and use /0 for every archive member File ID.

Additional differences with MSVC which does not appear to have a noticable functional impact:

  • LLVM produces string table entries terminated with /\n while MSVC uses \0. The PE Format documentation says: "The strings are null-terminated. Each string begins immediately after the null byte in the previous string."
  • MSVC creates an additional Second Linker Member which is omitted by LLVM.

To view the contents you could look at a hexdump or use Wireshark with https://git.lekensteyn.nl/peter/wireshark-notes/tree/lua/file-ar.lua

wireshark -Xlua_script:path/to/file-ar.lua -r your.lib

I think the change is possible to apply as such, but it'd be better if the diff was made with more context included (diff -U9999).

I've used git diff -W to include function context, but if that's not sufficient I'll include the full diff next time :)

ruiu accepted this revision.Dec 19 2018, 7:57 AM

LGTM

lib/Object/ArchiveWriter.cpp
276–277 ↗(On Diff #178801)

nit: if previous if is enclosed with {}, so should be else.

449 ↗(On Diff #178801)

I'd think "important" is a bit too strong. Maybe I'd say something like doing this saves space especially for COFF import libraries where all members have the same filename.

This revision is now accepted and ready to land.Dec 19 2018, 7:57 AM

Added braces and updated comment. Thanks for the feedback!

This revision was automatically updated to reflect the committed changes.