[PATCH] D149377: [AIX][llvm-ar] Use the Correct Kind for Bitcode File Inputs
Qiongsi Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 27 13:24:39 PDT 2023
qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: daltenty, DiggerLin.
Herald added a subscriber: hiraditya.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
When the input files are LLVM bitcode, `llvm-ar` should set the archive kind to `K_AIXBIG` as well, instead of leaving it to the default `K_GNU`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149377
Files:
llvm/lib/Object/ArchiveWriter.cpp
llvm/test/tools/llvm-ar/Inputs/aix-foo.ll
llvm/test/tools/llvm-ar/aix-bitcode.test
Index: llvm/test/tools/llvm-ar/aix-bitcode.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ar/aix-bitcode.test
@@ -0,0 +1,7 @@
+# Check if llvm-as correctly archives bitcode files on AIX.
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: llvm-as %S/Inputs/aix-foo.ll -o %t/aix-foo.bc
+# RUN: llvm-ar qc %t/aix-foo.a %t/aix-foo.bc
+# RUN: FileCheck %s --input-file=%t/aix-foo.a
+
+# CHECK: bigaf
Index: llvm/test/tools/llvm-ar/Inputs/aix-foo.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ar/Inputs/aix-foo.ll
@@ -0,0 +1,8 @@
+target datalayout = "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+target triple = "powerpc64-ibm-aix7.2.0.0"
+
+define signext i32 @foo() #0 {
+entry:
+ ret i32 42
+}
+
Index: llvm/lib/Object/ArchiveWriter.cpp
===================================================================
--- llvm/lib/Object/ArchiveWriter.cpp
+++ llvm/lib/Object/ArchiveWriter.cpp
@@ -76,9 +76,11 @@
if (auto ObjOrErr = object::SymbolicFile::createSymbolicFile(
MemBufferRef, file_magic::bitcode, &Context)) {
auto &IRObject = cast<object::IRObjectFile>(**ObjOrErr);
- return Triple(IRObject.getTargetTriple()).isOSDarwin()
+ auto TargetTriple = Triple(IRObject.getTargetTriple());
+ return TargetTriple.isOSDarwin()
? object::Archive::K_DARWIN
- : object::Archive::K_GNU;
+ : (TargetTriple.isOSAIX() ? object::Archive::K_AIXBIG
+ : object::Archive::K_GNU);
} else {
// Squelch the error in case this was not a SymbolicFile.
consumeError(ObjOrErr.takeError());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149377.517689.patch
Type: text/x-patch
Size: 1744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230427/c43088de/attachment.bin>
More information about the llvm-commits
mailing list