diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..449436c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/hans-gpg-key.asc +SOURCES/lld-10.0.0.src.tar.xz diff --git a/.lld.metadata b/.lld.metadata new file mode 100644 index 0000000..f189117 --- /dev/null +++ b/.lld.metadata @@ -0,0 +1,2 @@ +32fa4b0193960f05064f2ab31b5a89c7cf48a0b9 SOURCES/hans-gpg-key.asc +ed8dc4f73847e084b65f4ad5d2f6670f6f38a8eb SOURCES/lld-10.0.0.src.tar.xz diff --git a/SOURCES/0001-CMake-Check-for-gtest-headers-even-if-lit.py-is-not-.patch b/SOURCES/0001-CMake-Check-for-gtest-headers-even-if-lit.py-is-not-.patch new file mode 100644 index 0000000..c4af14d --- /dev/null +++ b/SOURCES/0001-CMake-Check-for-gtest-headers-even-if-lit.py-is-not-.patch @@ -0,0 +1,47 @@ +From e5bdf4580677da063abe8d3880fbab9eaa7a7efe Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 30 Aug 2018 08:53:56 -0700 +Subject: [PATCH] CMake: Check for gtest headers even if lit.py is not present + +This makes it possible to build the unittests even withotu a full +checkout of the llvm source tree. +--- + CMakeLists.txt | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e2fbdbf..c9b2927 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -75,6 +75,15 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") + set(LLVM_UTILS_PROVIDED ON) + endif() + ++ # Check for gtest ++ set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) ++ if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h ++ AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} ++ AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) ++ add_subdirectory(${UNITTEST_DIR} utils/unittest) ++ endif() ++ ++ # Check for lit + if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) + # Note: path not really used, except for checking if lit was found + set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) +@@ -84,12 +93,6 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") + set(LLVM_UTILS_PROVIDED ON) + set(LLD_TEST_DEPS FileCheck not) + endif() +- set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) +- if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h +- AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} +- AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) +- add_subdirectory(${UNITTEST_DIR} utils/unittest) +- endif() + else() + # Seek installed Lit. + find_program(LLVM_LIT +-- +1.8.3.1 + diff --git a/SOURCES/lit.lld-test.cfg.py b/SOURCES/lit.lld-test.cfg.py new file mode 100644 index 0000000..10d165b --- /dev/null +++ b/SOURCES/lit.lld-test.cfg.py @@ -0,0 +1,12 @@ +#Clear lld_tools_dir so we don't accidently pick up tools from somewhere else +config.lld_tools_dir = "" + +if hasattr(config, 'have_zlib'): + # Regression tests write output to this directory, so we need to be able to specify + # a temp directory when invoking lit. e.g. lit -Dlld_obj_root=/tmp/lit + config.lld_obj_root = "%(lld_obj_root)s" % lit_config.params + lit_config.load_config(config, '%(lld_test_root)s/lit.cfg.py' % lit_config.params) +else: + # For unit tests, llvm_obj_root is used to find the unit test binaries. + config.lld_obj_root = '%(lld_unittest_bindir)s' % lit_config.params + lit_config.load_config(config, '%(lld_test_root)s/Unit/lit.cfg.py' % lit_config.params) diff --git a/SOURCES/lld-10.0.0.src.tar.xz.sig b/SOURCES/lld-10.0.0.src.tar.xz.sig new file mode 100644 index 0000000..e30a6d4 Binary files /dev/null and b/SOURCES/lld-10.0.0.src.tar.xz.sig differ diff --git a/SOURCES/run-lit-tests b/SOURCES/run-lit-tests new file mode 100755 index 0000000..7b92d2e --- /dev/null +++ b/SOURCES/run-lit-tests @@ -0,0 +1,66 @@ +#!/bin/bash + +usage() { + cat << EOF +usage: `basename $0` [OPTIONS] + --threads NUM The number of threads to use for running tests. + --multilib-arch ARCH Use this option to test 32-bit libs/binaries on + 64-bit hosts. +EOF +} + +threads_arg='' + +while [ $# -gt 0 ]; do + case $1 in + --threads) + shift + threads_arg="--threads $1" + ;; + --multilib-arch) + shift + ARCH=$1 + ;; + * ) + echo "unknown option: $1" + echo "" + usage + exit 1 + ;; + esac + shift +done + +if [ `whoami` = "root" ]; then + echo "error: lld tests do not support running as root." + exit 1 +fi + +set -xe + +if [ -z "$ARCH" ]; then + ARCH=`rpm --eval '%_arch'` +fi + +case $ARCH in + arm) + ;& + i686) + LIB_DIR="/usr/lib/" + ;; + *) + LIB_DIR="/usr/lib64/" + ;; +esac + +cd $(mktemp -d) +ln -s /usr/include include +tar -xzf /usr/share/lld/src/test.tar.gz +ln -s $ARCH.site.cfg.py test/lit.site.cfg.py +ln -s $ARCH.site.cfg.py test/Unit/lit.site.cfg.py + +LD_LIBRARY_PATH=$LIB_DIR/lld:$LD_LIBRARY_PATH \ +lit -v -s $threads_arg test \ + -Dlld_obj_root=`pwd` \ + -Dlld_test_root=`pwd`/test \ + -Dlld_unittest_bindir=$LIB_DIR/lld diff --git a/SPECS/lld.spec b/SPECS/lld.spec new file mode 100644 index 0000000..540ad74 --- /dev/null +++ b/SPECS/lld.spec @@ -0,0 +1,294 @@ +#%%global rc_ver 6 +%global baserelease 1 +%global lld_srcdir lld-%{version}%{?rc_ver:rc%{rc_ver}}.src +%global maj_ver 10 +%global min_ver 0 +%global patch_ver 0 + +# Don't include unittests in automatic generation of provides or requires. +%global __provides_exclude_from ^%{_libdir}/lld/.*$ +%global __requires_exclude ^libgtest.*$ + +%bcond_with ld_alternative + +Name: lld +Version: %{maj_ver}.%{min_ver}.%{patch_ver} +Release: %{baserelease}%{?rc_ver:.rc%{rc_ver}}%{?dist} +Summary: The LLVM Linker + +License: NCSA +URL: http://llvm.org +%if 0%{?rc_ver:1} +Source0: https://prereleases.llvm.org/%{version}/rc%{rc_ver}/%{lld_srcdir}.tar.xz +Source3: https://prereleases.llvm.org/%{version}/rc%{rc_ver}/%{lld_srcdir}.tar.xz.sig +%else +Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{lld_srcdir}.tar.xz +Source3: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{lld_srcdir}.tar.xz.sig +%endif +Source1: run-lit-tests +Source2: lit.lld-test.cfg.py +Source4: https://prereleases.llvm.org/%{version}/hans-gpg-key.asc + +Patch0: 0001-CMake-Check-for-gtest-headers-even-if-lit.py-is-not-.patch + +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: cmake +BuildRequires: llvm-devel = %{version} +BuildRequires: llvm-test = %{version} +BuildRequires: ncurses-devel +BuildRequires: zlib-devel +BuildRequires: chrpath + +# For make check: +BuildRequires: python3-rpm-macros +BuildRequires: python3-lit +BuildRequires: llvm-googletest = %{version} + +%if %{with ld_alternative} +Requires(post): %{_sbindir}/alternatives +Requires(preun): %{_sbindir}/alternatives +%endif + +Requires: lld-libs = %{version}-%{release} + +%description +The LLVM project linker. + +%package devel +Summary: Libraries and header files for LLD +Requires: lld-libs = %{version}-%{release} + +%description devel +This package contains library and header files needed to develop new native +programs that use the LLD infrastructure. + +%package libs +Summary: LLD shared libraries + +%description libs +Shared libraries for LLD. + +%package test +Summary: LLD regression tests +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: python3-lit +Requires: llvm-test(major) = %{maj_ver} +Requires: lld-libs = %{version}-%{release} + +%description test +LLVM regression tests. + +%prep +%autosetup -n %{lld_srcdir} -p1 + +%build + +mkdir %{_target_platform} +cd %{_target_platform} + +%cmake .. \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ + -DLLVM_DYLIB_COMPONENTS="all" \ + -DPYTHON_EXECUTABLE=%{__python3} \ + -DLLVM_INCLUDE_TESTS=ON \ + -DLLVM_MAIN_SRC_DIR=%{_datadir}/llvm/src \ + -DLLVM_EXTERNAL_LIT=%{_bindir}/lit \ + -DLLVM_LIT_ARGS="-sv \ + --path %{_libdir}/llvm" \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 +%else + -DLLVM_LIBDIR_SUFFIX= +%endif + +%make_build + +# Build the unittests so we can install them. +%make_build lld-test-depends + +%install + +%global lit_cfg test/%{_arch}.site.cfg.py +%global lit_unit_cfg test/Unit/%{_arch}.site.cfg.py +%global lit_lld_test_cfg_install_path %{_datadir}/lld/lit.lld-test.cfg.py + +# Generate lit config files. Strip off the last line that initiates the +# test run, so we can customize the configuration. +head -n -1 %{_target_platform}/test/lit.site.cfg.py >> %{lit_cfg} +head -n -1 %{_target_platform}/test/Unit/lit.site.cfg.py >> %{lit_unit_cfg} + +# Patch lit config files to load custom config: +for f in %{lit_cfg} %{lit_unit_cfg}; do + echo "lit_config.load_config(config, '%{lit_lld_test_cfg_install_path}')" >> $f +done + +# Install test files +install -d %{buildroot}%{_datadir}/lld/src +cp %{SOURCE2} %{buildroot}%{_datadir}/lld/ + +tar -czf %{buildroot}%{_datadir}/lld/src/test.tar.gz test/ +install -d %{buildroot}%{_libexecdir}/tests/lld +cp %{SOURCE1} %{buildroot}%{_libexecdir}/tests/lld + +# Install unit test binaries +install -d %{buildroot}%{_libdir}/lld/ +cp -R %{_target_platform}/unittests %{buildroot}%{_libdir}/lld/ +rm -rf `find %{buildroot}%{_libdir}/lld/ -iname '*make*'` + +# Install gtest libraries +cp %{_target_platform}/%{_lib}/libgtest*so* %{buildroot}%{_libdir}/lld/ + +# Install libraries and binaries +cd %{_target_platform} +%make_install + +# Remove rpath +chrpath --delete %{buildroot}%{_bindir}/* +chrpath --delete %{buildroot}%{_libdir}/*.so* +chrpath --delete `find %{buildroot}%{_libdir}/lld/ -type f` + +%if %{with ld_alternative} +# Required when using update-alternatives: +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Alternatives/ +touch %{buildroot}%{_bindir}/ld + +%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 +%endif + +%check + +# armv7lhl tests disabled because of arm issue, see https://koji.fedoraproject.org/koji/taskinfo?taskID=33660162 +%ifnarch %{arm} +make -C %{_target_platform} %{?_smp_mflags} check-lld +%endif + +%ldconfig_scriptlets libs + +%files +%if %{with ld_alternative} +%ghost %{_bindir}/ld +%endif +%{_bindir}/lld* +%{_bindir}/ld.lld +%{_bindir}/ld64.lld +%{_bindir}/wasm-ld + +%files devel +%{_includedir}/lld +%{_libdir}/liblld*.so + +%files libs +%{_libdir}/liblld*.so.* + +%files test +%{_libexecdir}/tests/lld/ +%{_libdir}/lld/ +%{_datadir}/lld/src/test.tar.gz +%{_datadir}/lld/lit.lld-test.cfg.py + +%changelog +* Thu Apr 9 2020 sguelton@redhat.com - 10.0.0-1 +- 10.0.0 final + +* Thu Dec 19 2019 Tom Stellard -9.0.1-1 +- 9.0.1 Release + +* Fri Dec 13 2019 Tom Stellard - 9.0.0-5 +- Fix some rpmdiff errors + +* Fri Dec 13 2019 Tom Stellard - 9.0.0-4 +- Remove build artifacts installed with unittests + +* Thu Dec 05 2019 Tom Stellard - 9.0.0-3 +- Add lld-test package + +* Thu Nov 14 2019 Tom Stellard - 9.0.0-2 +- Add explicit lld-libs requires to fix rpmdiff errors + +* Thu Sep 26 2019 Tom Stellard - 9.0.0-1 +- 9.0.0 Release + +* Thu Aug 1 2019 sguelton@redhat.com - 8.0.1-1 +- 8.0.1 release + +* Mon Jun 17 2019 sguelton@redhat.com - 8.0.1-0.2.rc2 +- Remove unnecessary threading patch + +* Thu Jun 13 2019 sguelton@redhat.com - 8.0.1-0.1.rc2 +- 8.0.1rc2 Release + +* Tue Apr 16 2019 sguelton@redhat.com - 8.0.0-1 +- 8.0.0 Release + +* Mon Jan 14 2019 sguelton@redhat.com - 7.0.1-3 +- Fix lld + annobin integration & Setup basic CI tests + +* Sat Dec 15 2018 Tom Stellard - 7.0.1-2 +- Bump required python3-lit version + +* Fri Dec 14 2018 Tom Stellard - 7.0.1-1 +- 7.0.1-1 Release + +* Mon Dec 10 2018 Tom Stellard - 7.0.1-0.2.rc3 +- 7.0.1-rc3 Release + +* Tue Nov 27 2018 Tom Stellard - 7.0.0-1 +- 7.0.0 Release + +* Mon Oct 01 2018 Tom Stellard - 6.0.1-2 +- Drop scl macros + +* Wed Jun 27 2018 Tom Stellard - 6.0.1-1 +- 6.0.1 Release + +* Fri May 11 2018 Tom Stellard - 6.0.1-0.1.rc1 +- 6.0.1-rc1 Release + +* Thu Mar 08 2018 Tom Stellard - 6.0.0-1 +- 6.0.0 Release + +* Tue Feb 13 2018 Tom Stellard - 6.0.0-0.3.rc2 +- 6.0.0-rc2 Release + +* Thu Feb 08 2018 Fedora Release Engineering - 6.0.0-0.2.rc1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jan 25 2018 Tom Stellard - 6.0.0-0.1.rc1 +- 6.0.0-rc1 Release + +* Thu Dec 21 2017 Tom Stellard - 5.0.1-1 +- 5.0.1 Release + +* Mon Sep 11 2017 Tom Stellard - 5.0.0-1 +- 5.0.0 Release + +* Thu Aug 03 2017 Fedora Release Engineering - 4.0.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 4.0.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Thu Jul 06 2017 Tom Stellard - 4.0.1-2 +- Backport r307092 + +* Tue Jul 04 2017 Tom Stellard - 4.0.1-1 +- 4.0.1 Release + +* Tue Jul 04 2017 Tom Stellard - 4.0.0-4 +- Fix build without llvm-static + +* Wed May 31 2017 Tom Stellard - 4.0.0-3 +- Remove llvm-static dependency + +* Mon May 15 2017 Fedora Release Engineering - 4.0.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_27_Mass_Rebuild + +* Tue Mar 14 2017 Tom Stellard - 4.0.0-1 +- lld 4.0.0 Final Release