Create BSD archives by default on OS X.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 9 Jul 2015 20:12:50 +0000 (20:12 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 9 Jul 2015 20:12:50 +0000 (20:12 +0000)
They should probably be created on anything that is not windows or linux, but I will
test on freebsd before changing that.

With this it is possible to bootstrap with llvm-ar instead of ar+ranlib on OS X.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241849 91177308-0d34-0410-b5e6-96231b3b80d8

test/Object/archive-format.test
tools/llvm-ar/llvm-ar.cpp

index 951177256b6dbfce8deb7bae585cdfa7a099155a..51fa72a1f7b9d31de3c37a576f4e9d5357a604fe 100644 (file)
@@ -8,7 +8,7 @@ RUN: echo -n bar. > 0123456789abcde
 RUN: echo -n zed. > 0123456789abcdef
 
 RUN: rm -f test.a
-RUN: llvm-ar rc test.a 0123456789abcde 0123456789abcdef
+RUN: llvm-ar --format=gnu rc test.a 0123456789abcde 0123456789abcdef
 RUN: cat test.a | FileCheck -strict-whitespace %s
 
 CHECK:      !<arch>
index 6fbfc15380824507ccea0f4e72840374232bbb84..66daba30a4acdf28194dc0730281a3c679a366df 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/LibDriver/LibDriver.h"
@@ -552,9 +553,14 @@ performWriteOperation(ArchiveOperation Operation, object::Archive *OldArchive,
                       std::vector<NewArchiveIterator> *NewMembersP) {
   object::Archive::Kind Kind;
   switch (FormatOpt) {
-  case Default:
-    // FIXME: change as the support for other formats improve.
-    Kind = object::Archive::K_GNU;
+  case Default: {
+    Triple T(sys::getProcessTriple());
+    if (T.isOSDarwin())
+      Kind = object::Archive::K_BSD;
+    else
+      Kind = object::Archive::K_GNU;
+    break;
+  }
   case GNU:
     Kind = object::Archive::K_GNU;
     break;