[llvm] [llvm-ar] Use COFF archive format for COFF targets. (PR #82642)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 09:24:46 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;
----------------
gbreynoo wrote:

Thanks @jh7370, I checked and this will change our downstream ar's output in the cases @cjacek highlights above. However, due to @cjacek's points I cannot argue against it's submission.

The current behavior that default output format is defined by host does not seem good for the cross-compile use case in general. It may be preferable for the default to be based on a CMAKE option or something similar to gnu binutils and the GNUTARGET environment variable. Both are likely out of the scope of this PR though.

https://github.com/llvm/llvm-project/pull/82642


More information about the llvm-commits mailing list