[PATCH] D143540: [llvm-lib] Add support for writing COFF archives.

Jacek Caban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 15:09:00 PST 2023


jacek added a comment.

In D143540#4113923 <https://reviews.llvm.org/D143540#4113923>, @mstorsjo wrote:

> So - I'm not very familiar with the internals of static archives, can you elaborate a bit more on what `K_COFF` vs `K_GNU` means here. Is this a format flag which is written to the static archives themselves (I believe not?), or just different conventions for what details are written and found in the archives?

It's about how details are written to the archives, the meaning in this patch it analogical to how reader uses them, see Archive class constructor. Essentially, if the second member is another symbol table, then the archive treated as `K_COFF`. The other subtle difference is that strings in string table are null-terminated, see `ArchiveMemberHeader::getName`. This patch makes it possible to write archives that will be recognized as `K_COFF`.

> Currently, when reading such archives, are they identified as `K_GNU` or `K_COFF`?  And currently, before this patch, which mode is used?

Libraries generated by current llvm-lib are identified as `K_GNU`. Libraries generated by llvm-lib with this patch are identified as `K_COFF`.

> If I read the patch correctly (I just eyed it quickly) - `llvm-ar` will continue to write things like it used to, while `llvm-lib` will pick `K_COFF` (unless it's a thin library)?

Yes, nothing changes for llvm-ar yet. I guess it would make sense to add new llvm-ar --format argument for that, but we probably shouldn't change the default. If we changed the default for Windows host, it would require explicit --format when cross compiling from Windows, which is currently not required.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143540/new/

https://reviews.llvm.org/D143540



More information about the llvm-commits mailing list