Skip to content

Commit bc61060

Browse files
committed
Fix alternatives handling
This implements multiple fixes to the handling of llvm-config alternatives: * Increase alternative priority for new versions. Otherwise we'll give all versions the same priority. The new one will be something like 2064 for the 64-bit LLVM 20 llvm-config binary. * Remove old llvm-config-64/llvm-config-32 alternative. This is only needed once, so suppress the error. * Do not remove no longer used llvm-config-64/32 in postun scriptlet. Instead remove the llvm-config in install_bindir. However, now that the path will be the same for compat and non-compat LLVM, only do this on uninstall, not on upgrade. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2361779
1 parent 97e4be2 commit bc61060

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

llvm.spec

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
#region main package
317317
Name: %{pkg_name_llvm}
318318
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
319-
Release: 9%{?dist}
319+
Release: 10%{?dist}
320320
Summary: The Low Level Virtual Machine
321321

322322
License: Apache-2.0 WITH LLVM-exception OR NCSA
@@ -2599,7 +2599,13 @@ cp %{_vpath_builddir}/.ninja_log %{buildroot}%{_datadir}
25992599
%post -n %{pkg_name_llvm}-devel
26002600
update-alternatives --install %{_bindir}/llvm-config-%{maj_ver} llvm-config-%{maj_ver} %{install_bindir}/llvm-config %{__isa_bits}
26012601
%if %{without compat_build}
2602-
update-alternatives --install %{_bindir}/llvm-config llvm-config %{install_bindir}/llvm-config %{__isa_bits}
2602+
# Prioritize newer LLVM versions over older and 64-bit over 32-bit.
2603+
update-alternatives --install %{_bindir}/llvm-config llvm-config %{install_bindir}/llvm-config $((%{maj_ver}*100+%{__isa_bits}))
2604+
2605+
# Remove old llvm-config-%{__isa_bits} alternative. This will only do something during the
2606+
# first upgrade from a version that used it. In all other cases it will error, so suppress the
2607+
# expected error message.
2608+
update-alternatives --remove llvm-config %{_bindir}/llvm-config-%{__isa_bits} 2>/dev/null ||:
26032609

26042610
# During the upgrade from LLVM 16 (F38) to LLVM 17 (F39), we found out the
26052611
# main llvm-devel package was leaving entries in the alternatives system.
@@ -2617,14 +2623,14 @@ if [ $1 -eq 0 ]; then
26172623
update-alternatives --remove llvm-config%{exec_suffix} %{install_bindir}/llvm-config
26182624
fi
26192625
%if %{without compat_build}
2620-
# When upgrading between minor versions (i.e. from x.y.1 to x.y.2), we must
2621-
# not remove the alternative.
2622-
# However, during a major version upgrade (i.e. from 16.x.y to 17.z.w), the
2623-
# alternative must be removed in order to give priority to a newly installed
2624-
# compat package.
2625-
if [[ $1 -eq 0
2626-
|| "x$(%{_bindir}/llvm-config%{exec_suffix} --version | awk -F . '{ print $1 }')" != "x%{maj_ver}" ]]; then
2627-
update-alternatives --remove llvm-config-%{maj_ver} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits}
2626+
# There are a number of different cases here:
2627+
# Uninstall: Remove alternatives.
2628+
# Patch version upgrade: Keep alternatives.
2629+
# Major version upgrade with installation of compat package: Keep alternatives for compat package.
2630+
# Major version upgrade without installation of compat package: Remove alternatives. However, we
2631+
# can't distinguish it from the previous case, so we conservatively leave it behind.
2632+
if [ $1 -eq 0 ]; then
2633+
update-alternatives --remove llvm-config-%{maj_ver} %{install_bindir}/llvm-config
26282634
fi
26292635
%endif
26302636

@@ -3427,6 +3433,9 @@ fi
34273433

34283434
#region changelog
34293435
%changelog
3436+
* Tue Jun 17 2025 Nikita Popov <[email protected]> - 20.1.6-10
3437+
- Fix llvm-config alternatives handling (rhbz#2361779)
3438+
34303439
* Mon Jun 16 2025 Nikita Popov <[email protected]> - 20.1.6-9
34313440
- Use libdir suffix in versioned prefix
34323441

0 commit comments

Comments
 (0)