[PATCH] D76461: [llvm-ar] Use target triple to deduce archive kind for bitcode inputs

Pirama Arumuga Nainar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 18:41:42 PDT 2020


pirama marked an inline comment as done.
pirama added a comment.

In D76461#1932516 <https://reviews.llvm.org/D76461#1932516>, @MaskRay wrote:

> > https://llvm.org/doxygen/classllvm_1_1object_1_1Archive.html#ab288378fa8bfa0678dd25e36b5198a87. I think this regresses behavior for those other hosts.
>
> *BSD may need the `__.SYMDEF` format.
>
> Have you considered passing an explicit --format= via something like ARFLAGS?


The goal is to avoid requiring all users of the NDK on Darwin from having to set `--format=` when switching to LLVM binutils.  This format deduction only runs when no `--format` is provided and works for all cases except full LTO.  Also based on the deduction based on ObjectFile at the beginning of this function, it seems that all BSD environments require `--format=bsd` to be specified because it uses GNU archive kind for all ELF files.



================
Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:904
+               ? object::Archive::K_DARWIN
+               : object::Archive::K_GNU;
+    }
----------------
danalbert wrote:
> Looks like there are a few more options: https://llvm.org/doxygen/classllvm_1_1object_1_1Archive.html#ab288378fa8bfa0678dd25e36b5198a87. I think this regresses behavior for those other hosts.
Note that getDefaultForHost is also [[ https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-ar/llvm-ar.cpp#L857 | incorrect ]] on BSD (it returns K_GNU if the host triple is not Darwin).  So this doesn't exactly regress that behavior.  But it's good to handle this correctly for the narrow cases where we can.  I will fix getDefaultForHost in a follow up as it'd require a different test.

I also don't think llvm-ar is set up to pass through the other archive kinds (GNU64, DARWIN64, COFF).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76461





More information about the llvm-commits mailing list