[PATCH] D81109: llvm-link: Add support for archive files as inputs.

Jon Chesterfield via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 09:12:50 PDT 2020


JonChesterfield added a comment.

I really like this. I've wanted to pass archives of bitcode to llvm-link before and assume others have experienced the same disappointment.

The patch is straightforward, conservatively aborts if the archive has a mix of files in it, uses the existing parsing machinery.  Understanding .ll files as well would be a nice future extension.

llvm-link raises reasonable error messages usually, I think this should hit the same handling. Maybe add a test case where the two bitcode files have different triples and check we see the usual error reported?



================
Comment at: llvm/tools/llvm-link/llvm-link.cpp:14
 
+#include "llvm//Object/Archive.h"
 #include "llvm/ADT/STLExtras.h"
----------------
Double //, should be llvm/Object


================
Comment at: llvm/tools/llvm-link/llvm-link.cpp:162
+      WithColor::error()
+          << " could not get member name of archive library failed'"
+          << ArchiveName << "'\n";
----------------
double negative - perhaps " failed to read name of archive member"?


================
Comment at: llvm/tools/llvm-link/llvm-link.cpp:353
+    std::unique_ptr<Module> M =
+      (llvm::sys::path::extension(File) == ".a")
+          ? loadArFile(argv0, File, Context, L, Flags, ApplicableFlags)
----------------
May be better to read the first few bytes, looking for '!<arch>', instead of going by extension. Don't have strong preferences though.


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

https://reviews.llvm.org/D81109





More information about the llvm-commits mailing list