diff --git a/llvm/PKGBUILD b/llvm/PKGBUILD index 83fb964523..af11462ef1 100644 --- a/llvm/PKGBUILD +++ b/llvm/PKGBUILD @@ -4,7 +4,7 @@ pkgname=('llvm' 'llvm-libs') pkgver=18.1.8 -pkgrel=4.1 +pkgrel=5 arch=(x86_64 powerpc64le powerpc64 powerpc riscv64) url="https://llvm.org/" license=('Apache-2.0 WITH LLVM-exception') @@ -17,7 +17,10 @@ source=($_source_base/llvm-$pkgver.src.tar.xz{,.sig} $_source_base/cmake-$pkgver.src.tar.xz{,.sig} $_source_base/third-party-$pkgver.src.tar.xz{,.sig} $pkgname-SelectionDAG.patch - llvm-ppc64-elfv2.patch) + llvm-ppc64-elfv2.patch + dyld-elf-ppc32.patch + ppc-gcc-bug.patch + macho32.patch) sha256sums=('f68cf90f369bc7d0158ba70d860b0cb34dbc163d6ff0ebc6cfa5e515b9b2e28d' 'SKIP' '59badef592dd34893cd319d42b323aaa990b452d05c7180ff20f23ab1b41e837' @@ -25,7 +28,10 @@ sha256sums=('f68cf90f369bc7d0158ba70d860b0cb34dbc163d6ff0ebc6cfa5e515b9b2e28d' 'b76b810f3d3dc5d08e83c4236cb6e395aa9bd5e3ea861e8c319b216d093db074' 'SKIP' '9b53e584f8b8a44648a2a066da1860155b61118c8cdebed3632161db0b680462' - '8c4e8db0b80b1a86f8cff9aa678b70458503bc8926ecc41e0df953ea14ab3559') + '8c4e8db0b80b1a86f8cff9aa678b70458503bc8926ecc41e0df953ea14ab3559' + 'fe0277358d7a9bdfda236f9e6d74c43d458384a0c9d5db75bf2874b9a1d761f6' + '18d3c415474e937fc73ad4173506250495385025af168a0c270d3c202aedbab5' + 'a2ba322576fdea8d0c317d0ad372d224009b2d090b86ed9d0f566efb1d238827') validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid @@ -69,6 +75,11 @@ prepare() { # we use elfv2 on powerpc64 patch -Np2 -i ${srcdir}/llvm-ppc64-elfv2.patch + # Adelie fixes, they're awesome too! + patch -Np1 -i ${srcdir}/dyld-elf-ppc32.patch + patch -Np1 -i ${srcdir}/ppc-gcc-bug.patch + patch -Np1 -i ${srcdir}/macho32.patch + mkdir build # https://github.com/llvm/llvm-project/issues/82431 diff --git a/llvm/dyld-elf-ppc32.patch b/llvm/dyld-elf-ppc32.patch new file mode 100644 index 0000000000..7fb744169b --- /dev/null +++ b/llvm/dyld-elf-ppc32.patch @@ -0,0 +1,24 @@ +Author: A. Wilcox +Upstream-Status: Pending + +This implements the R_PPC_REL32 relocation type, which is needed for the +OrcJIT to work properly on 32-bit PowerPC. + +Needs more tests before submitting upstream, but seems to DTRT. + +--- llvm-14.0.6.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp.old 2022-06-22 16:46:24.000000000 +0000 ++++ llvm-14.0.6.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp 2022-11-28 06:33:12.239921624 +0000 +@@ -830,6 +830,13 @@ + case ELF::R_PPC_ADDR16_HA: + writeInt16BE(LocalAddress, applyPPCha(Value + Addend)); + break; ++ case ELF::R_PPC_REL32: ++ uint32_t FinalAddress = Section.getLoadAddressWithOffset(Offset); ++ int64_t delta = static_cast(Value - FinalAddress + Addend); ++ if (SignExtend64<32>(delta) != delta) ++ llvm_unreachable("Relocation R_PPC_REL32 overflow"); ++ writeInt32BE(LocalAddress, delta); ++ break; + } + } + diff --git a/llvm/macho32.patch b/llvm/macho32.patch new file mode 100644 index 0000000000..e180983725 --- /dev/null +++ b/llvm/macho32.patch @@ -0,0 +1,17 @@ +Use integer offset math instead of pointer math to determine load +command bounds. + +Upstream-URL: https://github.com/llvm/llvm-project/issues/56746 + +--- llvm-14.0.6.src/lib/Object/MachOObjectFile.cpp.old 2022-06-22 16:46:24.000000000 +0000 ++++ llvm-14.0.6.src/lib/Object/MachOObjectFile.cpp 2022-11-28 04:21:02.730211841 +0000 +@@ -192,7 +192,8 @@ + getLoadCommandInfo(const MachOObjectFile &Obj, const char *Ptr, + uint32_t LoadCommandIndex) { + if (auto CmdOrErr = getStructOrErr(Obj, Ptr)) { +- if (CmdOrErr->cmdsize + Ptr > Obj.getData().end()) ++ uint64_t Offset = Ptr - Obj.getData().begin(); ++ if (CmdOrErr->cmdsize + Offset > Obj.getData().size()) + return malformedError("load command " + Twine(LoadCommandIndex) + + " extends past end of file"); + if (CmdOrErr->cmdsize < 8) diff --git a/llvm/ppc-gcc-bug.patch b/llvm/ppc-gcc-bug.patch new file mode 100644 index 0000000000..3c1371dc40 --- /dev/null +++ b/llvm/ppc-gcc-bug.patch @@ -0,0 +1,22 @@ +Upstream: https://github.com/llvm/llvm-project/issues/95594 +Ref: #1204 + +--- llvm/include/llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h.old 2024-06-15 12:21:32.000000000 -0500 ++++ llvm/include/llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h 2024-06-25 21:42:07.495284340 -0500 +@@ -390,6 +390,8 @@ + return Size; + } + ++#pragma GCC push_options ++#pragma GCC optimize("no-tree-ch") + static bool serialize(SPSOutputBuffer &OB, const SequenceT &S) { + if (!SPSArgList::serialize(OB, static_cast(S.size()))) + return false; +@@ -398,6 +400,7 @@ + return false; + return true; + } ++#pragma GCC pop_options + + static bool deserialize(SPSInputBuffer &IB, SequenceT &S) { + using TBSD = TrivialSPSSequenceDeserialization;