[llvm] r241849 - Create BSD archives by default on OS X.

Rafael Espindola rafael.espindola at gmail.com
Thu Jul 9 13:12:50 PDT 2015


Author: rafael
Date: Thu Jul  9 15:12:50 2015
New Revision: 241849

URL: http://llvm.org/viewvc/llvm-project?rev=241849&view=rev
Log:
Create BSD archives by default on OS X.

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.

Modified:
    llvm/trunk/test/Object/archive-format.test
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/test/Object/archive-format.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/archive-format.test?rev=241849&r1=241848&r2=241849&view=diff
==============================================================================
--- llvm/trunk/test/Object/archive-format.test (original)
+++ llvm/trunk/test/Object/archive-format.test Thu Jul  9 15:12:50 2015
@@ -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>

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=241849&r1=241848&r2=241849&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Jul  9 15:12:50 2015
@@ -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 O
                       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;





More information about the llvm-commits mailing list