add patch to strip out LLVM targets for EPEL support

This commit is contained in:
Jan200101 2026-01-04 15:26:23 +01:00
commit 61f511df21
No known key found for this signature in database
GPG key ID: 5B71B1D78B882E05
3 changed files with 267 additions and 5 deletions

View file

@ -1,7 +1,7 @@
From 776181c3f8b3d3e34758f376979eb11acd3317e6 Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Tue, 11 Jun 2024 13:35:37 +0200
Subject: [PATCH] remove native lib directories from rpath
Subject: [PATCH 1/2] remove native lib directories from rpath
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---
@ -29,5 +29,5 @@ index 036adbf852..8410c05576 100644
if (create_module.libc_paths_file) |paths_file| {
--
2.51.0
2.52.0

View file

@ -0,0 +1,254 @@
From ab92fe5f0be7a49fa2c97957bebf6278a1b69aaf Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Sun, 4 Jan 2026 12:41:39 +0100
Subject: [PATCH 2/2] Remove unsupported LLVM targets for RHEL
LLVM for RHEL is only build with a subset of targets
this blocks zig at the configuration stage.
This commit simply swaps them out with the one from
https://src.fedoraproject.org/rpms/llvm/blob/rawhide/f/llvm.spec
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---
cmake/Findllvm.cmake | 2 +-
src/codegen/llvm.zig | 97 ++++++++++----------------------------------
src/target.zig | 43 +++++++++++---------
3 files changed, 45 insertions(+), 97 deletions(-)
diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake
index 5ff5de869c..5430ef9d59 100644
--- a/cmake/Findllvm.cmake
+++ b/cmake/Findllvm.cmake
@@ -83,7 +83,7 @@ if(ZIG_USE_LLVM_CONFIG)
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
- set(ZIG_LLVM_REQUIRED_TARGETS "AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SystemZ;VE;WebAssembly;X86;XCore")
+ set(ZIG_LLVM_REQUIRED_TARGETS "X86;AMDGPU;PowerPC;NVPTX;SystemZ;AArch64;BPF;WebAssembly;RISCV")
set(ZIG_LLVM_REQUIRED_TARGETS_ENABLED TRUE)
foreach(TARGET_NAME IN LISTS ZIG_LLVM_REQUIRED_TARGETS)
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index bd2c7bd022..a98fbab47e 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -13016,20 +13016,6 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
llvm.LLVMInitializeAMDGPUAsmPrinter();
llvm.LLVMInitializeAMDGPUAsmParser();
},
- .thumb, .thumbeb, .arm, .armeb => {
- llvm.LLVMInitializeARMTarget();
- llvm.LLVMInitializeARMTargetInfo();
- llvm.LLVMInitializeARMTargetMC();
- llvm.LLVMInitializeARMAsmPrinter();
- llvm.LLVMInitializeARMAsmParser();
- },
- .avr => {
- llvm.LLVMInitializeAVRTarget();
- llvm.LLVMInitializeAVRTargetInfo();
- llvm.LLVMInitializeAVRTargetMC();
- llvm.LLVMInitializeAVRAsmPrinter();
- llvm.LLVMInitializeAVRAsmParser();
- },
.bpfel, .bpfeb => {
llvm.LLVMInitializeBPFTarget();
llvm.LLVMInitializeBPFTargetInfo();
@@ -13037,34 +13023,6 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
llvm.LLVMInitializeBPFAsmPrinter();
llvm.LLVMInitializeBPFAsmParser();
},
- .hexagon => {
- llvm.LLVMInitializeHexagonTarget();
- llvm.LLVMInitializeHexagonTargetInfo();
- llvm.LLVMInitializeHexagonTargetMC();
- llvm.LLVMInitializeHexagonAsmPrinter();
- llvm.LLVMInitializeHexagonAsmParser();
- },
- .lanai => {
- llvm.LLVMInitializeLanaiTarget();
- llvm.LLVMInitializeLanaiTargetInfo();
- llvm.LLVMInitializeLanaiTargetMC();
- llvm.LLVMInitializeLanaiAsmPrinter();
- llvm.LLVMInitializeLanaiAsmParser();
- },
- .mips, .mipsel, .mips64, .mips64el => {
- llvm.LLVMInitializeMipsTarget();
- llvm.LLVMInitializeMipsTargetInfo();
- llvm.LLVMInitializeMipsTargetMC();
- llvm.LLVMInitializeMipsAsmPrinter();
- llvm.LLVMInitializeMipsAsmParser();
- },
- .msp430 => {
- llvm.LLVMInitializeMSP430Target();
- llvm.LLVMInitializeMSP430TargetInfo();
- llvm.LLVMInitializeMSP430TargetMC();
- llvm.LLVMInitializeMSP430AsmPrinter();
- llvm.LLVMInitializeMSP430AsmParser();
- },
.nvptx, .nvptx64 => {
llvm.LLVMInitializeNVPTXTarget();
llvm.LLVMInitializeNVPTXTargetInfo();
@@ -13086,13 +13044,6 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
llvm.LLVMInitializeRISCVAsmPrinter();
llvm.LLVMInitializeRISCVAsmParser();
},
- .sparc, .sparc64 => {
- llvm.LLVMInitializeSparcTarget();
- llvm.LLVMInitializeSparcTargetInfo();
- llvm.LLVMInitializeSparcTargetMC();
- llvm.LLVMInitializeSparcAsmPrinter();
- llvm.LLVMInitializeSparcAsmParser();
- },
.s390x => {
llvm.LLVMInitializeSystemZTarget();
llvm.LLVMInitializeSystemZTargetInfo();
@@ -13123,13 +13074,6 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
llvm.LLVMInitializeXtensaAsmParser();
}
},
- .xcore => {
- llvm.LLVMInitializeXCoreTarget();
- llvm.LLVMInitializeXCoreTargetInfo();
- llvm.LLVMInitializeXCoreTargetMC();
- llvm.LLVMInitializeXCoreAsmPrinter();
- // There is no LLVMInitializeXCoreAsmParser function.
- },
.m68k => {
if (build_options.llvm_has_m68k) {
llvm.LLVMInitializeM68kTarget();
@@ -13148,13 +13092,6 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
llvm.LLVMInitializeCSKYAsmParser();
}
},
- .ve => {
- llvm.LLVMInitializeVETarget();
- llvm.LLVMInitializeVETargetInfo();
- llvm.LLVMInitializeVETargetMC();
- llvm.LLVMInitializeVEAsmPrinter();
- llvm.LLVMInitializeVEAsmParser();
- },
.arc => {
if (build_options.llvm_has_arc) {
llvm.LLVMInitializeARCTarget();
@@ -13164,21 +13101,29 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
// There is no LLVMInitializeARCAsmParser function.
}
},
- .loongarch32, .loongarch64 => {
- llvm.LLVMInitializeLoongArchTarget();
- llvm.LLVMInitializeLoongArchTargetInfo();
- llvm.LLVMInitializeLoongArchTargetMC();
- llvm.LLVMInitializeLoongArchAsmPrinter();
- llvm.LLVMInitializeLoongArchAsmParser();
- },
+
+ // Disabled LLVM targets
+ .thumb,
+ .thumbeb,
+ .arm,
+ .armeb,
+ .avr,
+ .hexagon,
+ .lanai,
+ .mips,
+ .mipsel,
+ .mips64,
+ .mips64el,
+ .msp430,
+ .sparc,
+ .sparc64,
+ .xcore,
+ .ve,
+ .loongarch32,
+ .loongarch64,
.spirv32,
.spirv64,
- => {
- llvm.LLVMInitializeSPIRVTarget();
- llvm.LLVMInitializeSPIRVTargetInfo();
- llvm.LLVMInitializeSPIRVTargetMC();
- llvm.LLVMInitializeSPIRVAsmPrinter();
- },
+ => unreachable,
// LLVM does does not have a backend for these.
.kalimba,
diff --git a/src/target.zig b/src/target.zig
index f8201d691b..8491912bd5 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -166,23 +166,12 @@ pub fn hasLlvmSupport(target: *const std.Target, ofmt: std.Target.ObjectFormat)
}
return switch (target.cpu.arch) {
- .arm,
- .armeb,
.aarch64,
.aarch64_be,
.arc,
- .avr,
.bpfel,
.bpfeb,
- .hexagon,
- .loongarch32,
- .loongarch64,
.m68k,
- .mips,
- .mipsel,
- .mips64,
- .mips64el,
- .msp430,
.powerpc,
.powerpcle,
.powerpc64,
@@ -190,24 +179,38 @@ pub fn hasLlvmSupport(target: *const std.Target, ofmt: std.Target.ObjectFormat)
.amdgcn,
.riscv32,
.riscv64,
- .sparc,
- .sparc64,
- .spirv32,
- .spirv64,
.s390x,
- .thumb,
- .thumbeb,
.x86,
.x86_64,
- .xcore,
.nvptx,
.nvptx64,
- .lanai,
.wasm32,
.wasm64,
- .ve,
=> true,
+ // Disabled LLVM targets
+ .thumb,
+ .thumbeb,
+ .arm,
+ .armeb,
+ .avr,
+ .hexagon,
+ .lanai,
+ .mips,
+ .mipsel,
+ .mips64,
+ .mips64el,
+ .msp430,
+ .sparc,
+ .sparc64,
+ .xcore,
+ .ve,
+ .loongarch32,
+ .loongarch64,
+ .spirv32,
+ .spirv64,
+ => false,
+
// LLVM backend exists but can produce neither assembly nor object files.
.csky,
.xtensa,
--
2.52.0

View file

@ -4,7 +4,7 @@
%global public_key RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U
# note here at which Fedora or EL release we need to use compat LLVM packages
%if 0%{?fedora} >= 43 || 0%{?rhel} >= 9
%if 0%{?fedora} >= 43 || 0%{?rhel} >= 11
%global llvm_compat 20
%endif
@ -57,7 +57,10 @@ Source2: macros.%{name}
# Remove native lib directories from rpath
# this is unlikely to be upstreamed in its current state because upstream
# wants to work around the shortcomings of NixOS
Patch: 0001-remove-native-lib-directories-from-rpath.patch
Patch0: 0001-remove-native-lib-directories-from-rpath.patch
# LLVM on RHEL/EPEL only provides fewer targets so we patch the required targets down
# Targets come from https://src.fedoraproject.org/rpms/llvm/blob/rawhide/f/llvm.spec
Patch1: 0002-Remove-unsupported-LLVM-targets-for-EPEL.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -140,7 +143,12 @@ This package contains common RPM macros for %{name}.
%prep
/usr/bin/minisign -V -m %{SOURCE0} -x %{SOURCE1} -P %{public_key} -Q | grep -F "file:%{archive_name}"
%autosetup -p1
%autosetup -N
%patch 0 -p1
%if 0%{?rhel}
%patch 1 -p1
%endif
%if %{without bootstrap}
# Ensure that the pre-build stage1 binary is not used
rm -f stage1/zig1.wasm