Add update-alternative for ld

rhbz#1739973
This commit is contained in:
Tom Stellard 2019-02-15 22:11:28 +00:00
parent 9d776282c7
commit fbb8d64fa7
3 changed files with 61 additions and 1 deletions

View File

@ -3,7 +3,7 @@
Name: lld
Version: 8.0.0
Release: 1%{?rc_ver:.rc%{rc_ver}}%{?dist}.1
Release: 2%{?rc_ver:.rc%{rc_ver}}%{?dist}
Summary: The LLVM Linker
License: NCSA
@ -27,6 +27,9 @@ BuildRequires: python3-rpm-macros
BuildRequires: python3-lit
BuildRequires: llvm-googletest = %{version}
Requires(post): %{_sbindir}/alternatives
Requires(preun): %{_sbindir}/alternatives
%description
The LLVM project linker.
@ -76,6 +79,13 @@ cd %{_target_platform}
chrpath --delete %{buildroot}%{_bindir}/*
chrpath --delete %{buildroot}%{_libdir}/*.so*
%post
%{_sbindir}/update-alternatives --install %{_bindir}/ld ld %{_bindir}/ld.lld 1
%postun
if [ $1 -eq 0 ] ; then
%{_sbindir}/update-alternatives --remove ld %{_bindir}/ld.lld
fi
%check
@ -87,6 +97,7 @@ make -C %{_target_platform} %{?_smp_mflags} check-lld
%ldconfig_scriptlets libs
%files
%ghost %{_bindir}/ld
%{_bindir}/lld*
%{_bindir}/ld.lld
%{_bindir}/ld64.lld
@ -100,6 +111,9 @@ make -C %{_target_platform} %{?_smp_mflags} check-lld
%{_libdir}/liblld*.so.*
%changelog
* Tue Aug 13 2019 Tom Stellard <tstellar@redhat.com> - 8.0.0-2
- Add update-alternative for ld
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 8.0.0-1.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

32
tests/ld-alternative/runtest.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# This test assumes lld is already installed.
set -ex
function verify_ld_bfd {
# Verify that /usr/bin/ld points to ld.bfd.
ls -l /etc/alternatives/ld | grep ld.bfd
# Run ld and verify it invokes ld.bfd
/usr/bin/ld --version | grep 'GNU ld'
}
# Verify ld.bfd is still the system linker when lld is installed
verify_ld_bfd
# Set lld as the system linker
update-alternatives --set ld /usr/bin/ld.lld
# Verify that /usr/bin/ld points to lld
ls -l /etc/alternatives/ld | grep ld.lld
# Run ld and verify it invokes lld
/usr/bin/ld --version | grep 'LLD'
# Uninstall lld and make sure the /usr/bin/ld is reset to ld.bfd
dnf -y remove lld
verify_ld_bfd

View File

@ -0,0 +1,14 @@
# The ld-alternative test uninstalls lld, so it needs to be run by
# itself in a separate .yml file so it doesn't modify the test
# environment for other tests.
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
required_packages:
- binutils
- lld
tests:
- ld-alternative