[llvm] [llvm-ar] Use COFF archive format for COFF targets. (PR #82642)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 06:40:35 PST 2024
================
@@ -969,12 +969,19 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
Err = Error::success();
}
+object::Archive::Kind Archive::getDefaultKindForTriple(Triple &T) {
+ if (T.isOSDarwin())
+ return object::Archive::K_DARWIN;
+ if (T.isOSAIX())
+ return object::Archive::K_AIXBIG;
+ if (T.isOSWindows())
+ return object::Archive::K_COFF;
----------------
cjacek wrote:
Please note the host matters only when `llvm-ar` can't infer the format from any other source. In practice, it means that it matters only when creating empty archives and archives who's first member is a non-symbolic files. In typical use case, when you pass object files, this PR shouldn't change anything unless you use COFF files.
I could limit impact of this PR by not changing the effect of `getDefaultKindForHost`, but it feels right to be consistent. If we consider those cases to be a problem, then it's also problematic for existing `isOSDarwin()` and `isOSAIX()` checks (which have even more significant format differences). If user cares about the format and uses `llvm-ar ` on non-symbolic files, then an explicit `--format` argument is the only reliable way I can see to handle all cross compilation variants.
https://github.com/llvm/llvm-project/pull/82642
More information about the llvm-commits
mailing list