[llvm] [lipo] Support creating Universal 64 bit Mach-O files. (PR #67737)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 14:07:58 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff da28593d71a8581bdcf6b99346e1cd625076aaff 7430302bbb408a36f151e4dad2796b1abff3a4cf -- llvm/include/llvm/Object/MachOUniversalWriter.h llvm/lib/Object/MachOUniversalWriter.cpp llvm/tools/llvm-lipo/llvm-lipo.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/Object/MachOUniversalWriter.h b/llvm/include/llvm/Object/MachOUniversalWriter.h
index 73527a023cb0..3270bc12960b 100644
--- a/llvm/include/llvm/Object/MachOUniversalWriter.h
+++ b/llvm/include/llvm/Object/MachOUniversalWriter.h
@@ -97,9 +97,11 @@ public:
}
};
-Error writeUniversalBinary(ArrayRef<Slice> Slices, StringRef OutputFileName, bool UseFat64 = false);
+Error writeUniversalBinary(ArrayRef<Slice> Slices, StringRef OutputFileName,
+ bool UseFat64 = false);
-Error writeUniversalBinaryToStream(ArrayRef<Slice> Slices, raw_ostream &Out, bool UseFat64 = false);
+Error writeUniversalBinaryToStream(ArrayRef<Slice> Slices, raw_ostream &Out,
+ bool UseFat64 = false);
} // end namespace object
diff --git a/llvm/lib/Object/MachOUniversalWriter.cpp b/llvm/lib/Object/MachOUniversalWriter.cpp
index 54ffd0bf475c..b37c1963cbcc 100644
--- a/llvm/lib/Object/MachOUniversalWriter.cpp
+++ b/llvm/lib/Object/MachOUniversalWriter.cpp
@@ -240,8 +240,7 @@ Expected<Slice> Slice::create(const IRObjectFile &IRO, uint32_t Align) {
return Slice{IRO, CPUType, CPUSubType, std::move(ArchName), Align};
}
-template <typename FatArchTy>
-struct FatArchTraits {
+template <typename FatArchTy> struct FatArchTraits {
static const uint64_t OffsetLimit;
static const std::string StructName;
static const uint8_t BitCount;
@@ -274,9 +273,12 @@ buildFatArchList(ArrayRef<Slice> Slices) {
return createStringError(
std::errc::invalid_argument,
("fat file too large to be created because the offset field in "
- "the struct " + Twine(FatArchTraits<FatArchTy>::StructName) +
- " is only " + Twine(FatArchTraits<FatArchTy>::BitCount) + "-bits and the"
- " offset " + Twine(Offset) + " for " + S.getBinary()->getFileName() +
+ "the struct " +
+ Twine(FatArchTraits<FatArchTy>::StructName) + " is only " +
+ Twine(FatArchTraits<FatArchTy>::BitCount) +
+ "-bits and the"
+ " offset " +
+ Twine(Offset) + " for " + S.getBinary()->getFileName() +
" for architecture " + S.getArchString() + "exceeds that.")
.str()
.c_str());
@@ -294,10 +296,9 @@ buildFatArchList(ArrayRef<Slice> Slices) {
}
template <typename FatArchTy>
-static Error
-writeUniversalArchsToStream(MachO::fat_header FatHeader,
- ArrayRef<Slice> Slices,
- raw_ostream &Out) {
+static Error writeUniversalArchsToStream(MachO::fat_header FatHeader,
+ ArrayRef<Slice> Slices,
+ raw_ostream &Out) {
Expected<SmallVector<FatArchTy, 2>> FatArchListOrErr =
buildFatArchList<FatArchTy>(Slices);
if (!FatArchListOrErr)
@@ -334,22 +335,21 @@ writeUniversalArchsToStream(MachO::fat_header FatHeader,
}
Error object::writeUniversalBinaryToStream(ArrayRef<Slice> Slices,
- raw_ostream &Out,
- bool UseFat64) {
+ raw_ostream &Out, bool UseFat64) {
MachO::fat_header FatHeader;
FatHeader.magic = UseFat64 ? MachO::FAT_MAGIC_64 : MachO::FAT_MAGIC;
FatHeader.nfat_arch = Slices.size();
if (UseFat64) {
- return writeUniversalArchsToStream<MachO::fat_arch_64>(FatHeader, Slices, Out);
+ return writeUniversalArchsToStream<MachO::fat_arch_64>(FatHeader, Slices,
+ Out);
} else {
return writeUniversalArchsToStream<MachO::fat_arch>(FatHeader, Slices, Out);
}
}
Error object::writeUniversalBinary(ArrayRef<Slice> Slices,
- StringRef OutputFileName,
- bool UseFat64) {
+ StringRef OutputFileName, bool UseFat64) {
const bool IsExecutable = any_of(Slices, [](Slice S) {
return sys::fs::can_execute(S.getBinary()->getFileName());
});
diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index b5d38027ccb9..88d77faa035f 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -599,9 +599,11 @@ buildSlices(LLVMContext &LLVMCtx, ArrayRef<OwningBinary<Binary>> InputBinaries,
return Slices;
}
-[[noreturn]] static void createUniversalBinary(
- LLVMContext &LLVMCtx, ArrayRef<OwningBinary<Binary>> InputBinaries,
- const StringMap<const uint32_t> &Alignments, StringRef OutputFileName, bool UseFat64) {
+[[noreturn]] static void
+createUniversalBinary(LLVMContext &LLVMCtx,
+ ArrayRef<OwningBinary<Binary>> InputBinaries,
+ const StringMap<const uint32_t> &Alignments,
+ StringRef OutputFileName, bool UseFat64) {
assert(InputBinaries.size() >= 1 && "Incorrect number of input binaries");
assert(!OutputFileName.empty() && "Create expects a single output file");
``````````
</details>
https://github.com/llvm/llvm-project/pull/67737
More information about the llvm-commits
mailing list