diff --git a/.gitignore b/.gitignore index f71c7c7..707f265 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ /3.5.1.tar.gz /sleef-3.5.1.tar.gz /sleef-3.5.1-filtered.tar.xz +/sleef-3.5.1-filtered.tar.zst +/sleef-3.6-filtered.tar.zst +/sleef-3.6.1-filtered.tar.zst +/sleef-3.7-filtered.tar.zst +/sleef-3.8-filtered.tar.zst +/sleef-3.9.0-filtered.tar.zst diff --git a/471.patch b/471.patch deleted file mode 100644 index 4849399..0000000 --- a/471.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 1f27275c72c31451d8f458a4ddec01609830bc5f Mon Sep 17 00:00:00 2001 -From: "Benjamin A. Beasley" -Date: Wed, 4 Oct 2023 16:28:49 -0400 -Subject: [PATCH] Do not define our own mpfr_sinpi/mpfr_cospi for mpfr 4.2.0 - and later - -These two functions were added to the MPFR API. - -Fixes #458. ---- - src/libm-tester/testerutil.c | 2 ++ - src/libm-tester/testerutil.h | 2 ++ - 2 files changed, 4 insertions(+) - -diff --git a/src/libm-tester/testerutil.c b/src/libm-tester/testerutil.c -index 8e8b8936..688642ca 100644 ---- a/src/libm-tester/testerutil.c -+++ b/src/libm-tester/testerutil.c -@@ -289,6 +289,7 @@ double countULP2sp(float d, mpfr_t c0) { - - // - -+#if MPFR_VERSION < MPFR_VERSION_NUM(4, 2, 0) - void mpfr_sinpi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd) { - mpfr_t frpi, frd; - mpfr_inits(frpi, frd, NULL); -@@ -314,6 +315,7 @@ void mpfr_cospi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd) { - - mpfr_clears(frpi, frd, NULL); - } -+#endif - - void mpfr_lgamma_nosign(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd) { - int s; -diff --git a/src/libm-tester/testerutil.h b/src/libm-tester/testerutil.h -index 7f371414..313bf7b2 100644 ---- a/src/libm-tester/testerutil.h -+++ b/src/libm-tester/testerutil.h -@@ -90,7 +90,9 @@ int cmpDenormsp(float x, mpfr_t fry); - double countULPsp(float d, mpfr_t c); - double countULP2sp(float d, mpfr_t c); - -+#if MPFR_VERSION < MPFR_VERSION_NUM(4, 2, 0) - void mpfr_sinpi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd); - void mpfr_cospi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd); -+#endif - void mpfr_lgamma_nosign(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd); - #endif diff --git a/get_source.sh b/get_source.sh index d17508c..3745066 100755 --- a/get_source.sh +++ b/get_source.sh @@ -11,7 +11,7 @@ Usage: $1 VERSION Generate a source archive for sleef with src/gencoef/ removed, since the code therein is licensed CC-BY-4.0, but this license is not approved for code in -Fedora. The result will be named sleef-\${VERSION}-filtered.tar.xz and will be +Fedora. The result will be named sleef-\${VERSION}-filtered.tar.zst and will be written into the current working directory. EOF } @@ -31,22 +31,36 @@ VERSION="${1}" SOURCE0="${FORGEURL}/archive/${VERSION}/sleef-${VERSION}.tar.gz" TARNAME="$(basename "${SOURCE0}")" TARDIR="$(basename "${SOURCE0}" '.tar.gz')" -NEWTAR="${TARDIR}-filtered.tar.xz" +NEWTAR="${TARDIR}-filtered.tar.zst" SAVEDIR="${PWD}" XDIR="$(mktemp -d)" -trap "rm -rvf '${XDIR}'" INT TERM EXIT +trap "rm -rf '${XDIR}'" INT TERM EXIT cd "${XDIR}" curl -L -O "${SOURCE0}" -tar -xzvf "${TARNAME}" +tar -xzf "${TARNAME}" +MTIME="$(stat -c '%Y' "${TARDIR}")" rm -rvf "${TARDIR}/src/gencoef/" if grep -ErinI 'Attribution 4\.0' . then echo 'ERROR: did not properly remove problematic content' 1>&2 exit 1 fi -tar -cv "${TARDIR}/" | xz -9e > "${NEWTAR}" +# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html +# We reset all mtimes to that of the top-level extracted directory; since git +# archives don’t have meaningful per-file mtimes, nothing useful is lost. +TZ=UTC LC_ALL=C tar \ + --create \ + --sort=name \ + --format=posix \ + --numeric-owner --owner=0 --group=0 \ + --mode=go+u,go-w \ + --pax-option='delete=atime,delete=ctime' \ + --clamp-mtime --mtime="@${MTIME}" \ + "${TARDIR}/" | + zstdmt --ultra -22 > "${NEWTAR}" +touch -d @"${MTIME}" "${NEWTAR}" cd "${SAVEDIR}" mv -v "${XDIR}/${NEWTAR}" . diff --git a/sleef.rpmlintrc b/sleef.rpmlintrc index 0e0dc24..7a1f9b5 100644 --- a/sleef.rpmlintrc +++ b/sleef.rpmlintrc @@ -1,2 +1,12 @@ # These are not real spelling errors... -addFilter(r'spelling-error .*(\(en_US\)| en_US) ([Vv]ectorized) ') +addFilter(r"sleef-gnuabi\..*: spelling-error \('(lib(sleefgnuabi|mvec)|glibc)', ") +# All of the documentation is in the -doc subpackage. +addFilter(r" no-documentation") +# This Source cannot be a URL because we must filter out certain files. +addFilter(r" invalid-url Source[0-9]+: sleef-.*-filtered\.tar\.zst") +# Bogus; it is a perfectly fine zstandard file. +addFilter(r" inconsistent-file-extension sleef-.*-filtered\.tar\.zst") +# We are not sure why some files from docs/ are duplicated in docs/src/. The +# files are small compared to the documentation overall, so it does not seem +# worth too much investigation, and hardlinking them would be a little tedious. +addFilter(r" files-duplicate /.*/docs/src/") diff --git a/sleef.spec b/sleef.spec index 5a69c1d..ea7b1d4 100644 --- a/sleef.spec +++ b/sleef.spec @@ -1,23 +1,17 @@ -# We do not ship the DFT library since it has undiagnosed test failures on -# Fedora at -O2, and is not well-supported upstream. Additionally, it uses -# illegal instructions on ARM and s390x, at least on the Fedora build machines. -# See https://github.com/shibatch/sleef/issues/214. -%bcond dft 0 -# We would like to ship the quad-precision library, but since it is still -# considered experimental, it may have breaking ABI or API changes without an -# soversion bump, which is a no-no in Fedora. Rather than contorting ourselves -# to accommodate this, we disable it until it stabilizes or some dependent -# package appears. -%bcond quad 0 -# Similarly, Fedora packages should not ship static libraries unless absolutely -# required. Some software, like pytorch, really does rely on the inline headers -# and accompanying static support library for exceptional performance -# requirements, but no such software exists in Fedora at the moment. We will -# leave this feature disabled until someone asks for it. +%bcond dft 1 +%bcond quad 1 +# Fedora packages should not ship static libraries unless absolutely required. +# Some software may really rely on the inline headers and accompanying static +# support library for exceptional performance requirements, but we will leave +# this feature disabled until someone asks for it. %bcond static 0 +# Adds a BuildRequires on tlfloat and enables more tests +%bcond tlfloat 1 + Name: sleef -Version: 3.5.1 +Version: 3.9.0 +%global tag %{version} %global so_version 3 Release: %autorelease Summary: Vectorized math library @@ -35,34 +29,48 @@ Summary: Vectorized math library License: BSL-1.0 URL: https://sleef.org # This is a filtered version of: -# https://github.com/shibatch/sleef/archive/%%{version}/sleef-%%{version}.tar.gz +# https://github.com/shibatch/sleef/archive/%%{tag}/sleef-%%{tag}.tar.gz # See the comment above License for why this is necessary. The archive is # produced by using the script in Source1: # ./get_source.sh ${VERSION} -Source0: sleef-%{version}-filtered.tar.xz +Source0: sleef-%{tag}-filtered.tar.zst Source1: get_source.sh -# Do not define our own mpfr_sinpi/mpfr_cospi for mpfr 4.2.0 and later -# https://github.com/shibatch/sleef/pull/471 -# -# This is similar to: -# -# mpfr-4.2 add mpfr_cospi and mpfr_sinpi -# https://github.com/shibatch/sleef/pull/462 -# -# ...but maintains backwards-compatibility with mpfr version before 4.2.0. -# -# Fixes: -# -# Compilation fails (conflicting types) if mpfr-devel 4.2.0 is provided -# https://github.com/shibatch/sleef/issues/458 -Patch: https://github.com/shibatch/sleef/pull/471.patch - # https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval ExcludeArch: %{ix86} +# On aarch64, since 3.9.0, we cannot link at least bin/tester3svenofma when LTO +# is enabled, due to confusion about SVE. +# +# /builddir/build/BUILD/sleef-3.9.0-build/sleef-3.9.0/src/common/testerutil.c: +# In function ‘memrand.constprop’: +# /builddir/build/BUILD/sleef-3.9.0-build/sleef-3.9.0/src/common/testerutil.c:101:6: +# error: this operation requires the SVE ISA extension +# 101 | void memrand(void *p, int size) { +# | ^ +# /builddir/build/BUILD/sleef-3.9.0-build/sleef-3.9.0/src/common/testerutil.c:101:6: +# note: you can enable SVE using the command-line option ‘-march’, or by +# using the ‘target’ attribute or pragma +# /builddir/build/BUILD/sleef-3.9.0-build/sleef-3.9.0/src/common/testerutil.c:101: +# confused by earlier errors, bailing out +# +# This might be an upstream bug, but it is hard to understand. Upstream +# provides their own LTO option, SLEEF_ENABLE_LTO, but for does not support it +# in combination with shared libraries. +# +# - We could still build the library with LTO and not test it +# (-DSLEEF_BUILD_TESTS:BOOL=FALSE) on aarch64. +# - It’s not clear how we could disable LTO *only for the tests*. +# - We choose to disable LTO entirely on aarch64, because we really want to run +# the tests. We hope that the performance impact is not significant. It +# currently does not seem necessary to disable LTO on other architectures. +%ifarch %{arm64} +%global _lto_cflags %{nil} +%endif + BuildRequires: cmake >= 3.4.3 BuildRequires: gcc +BuildRequires: gcc-c++ BuildRequires: ninja-build # For tests only: BuildRequires: pkgconfig(mpfr) @@ -72,10 +80,13 @@ BuildRequires: pkgconfig(libcrypto) %if %{with dft} BuildRequires: pkgconfig(fftw3) %endif +%if %{with tlfloat} +BuildRequires: pkgconfig(tlfloat) +%endif # See https://sleef.org/additional.xhtml#gnuabi. The gnuabi version of the # library only applies to these architectures. -%global gnuabi_arches %{ix86} x86_64 aarch64 +%global gnuabi_arches %{ix86} %{x86_64} %{arm64} # See https://github.com/shibatch/sleef/pull/283. %if %{with static} %global inline_enabled 1 @@ -191,18 +202,16 @@ developing applications that use sleef-quad. %prep -%autosetup -p1 -# The gencoef tool sources are licensed CC-BY-4.0, which is allowed for content -# but not for code. Remove them to prove that they are not used in the build. -rm -vrf src/gencoef +%autosetup -n sleef-%{tag} -p1 +# Remove an unwanted hidden file from the docs +find docs/ -type f -name .nojekyll -print -delete -%build -# -GNinja: Upstream prominently states that parallel build is only supported -# with the Ninja generator for cmake, not with the make one. See -# https://sleef.org/compile.xhtml. +%conf +# -GNinja: This used to be required for parallel builds; it is still faster. # # -DENFORCE_TESTER3: The build should fail if we cannot build all tests. +# -DENFORCE_TESTER4: Likewise, except that tester4 requires tlfloat. # # -DBUILD_INLINE_HEADERS: Do not build the “inline” headers. This would provide # an arch-specific collection of sleefinline_*.h headers in _includedir, as @@ -211,13 +220,30 @@ rm -vrf src/gencoef # and would thus also be treated as a static library in the Fedora # guidelines) should be omitted unless something in Fedora absolutely # requires them. +# +# -DSLEEFDFT_ENABLE_STREAM: The author writes, “The recommended value for +# SLEEFDFT_ENABLE_STREAM depends on the architecture, and it is only +# recommended to be turned on on x86_64.” +# https://github.com/shibatch/sleef/discussions/654#discussioncomment-12860550 %cmake \ -GNinja \ - -DENFORCE_TESTER3:BOOL=TRUE \ - -DBUILD_INLINE_HEADERS:BOOL=%{?inline_enabled:TRUE}%{?!inline_enabled:FALSE} \ - -DBUILD_GNUABI_LIBS:BOOL=%{?gnuabi_enabled:TRUE}%{?!gnuabi_enabled:FALSE} \ - -DBUILD_DFT:BOOL=%{?with_dft:TRUE}%{?!with_dft:FALSE} \ - -DBUILD_QUAD:BOOL=%{?with_quad:TRUE}%{?!with_quad:FALSE} + -DSLEEF_BUILD_DFT:BOOL=%{?with_dft:TRUE}%{?!with_dft:FALSE} \ + -DSLEEF_ENFORCE_DFT:BOOL=%{?with_dft:TRUE}%{?!with_dft:FALSE} \ +%ifarch %{x86_64} + -DSLEEFDFT_ENABLE_STREAM:BOOL=TRUE \ +%else + -DSLEEFDFT_ENABLE_STREAM:BOOL=FALSE \ +%endif + -DSLEEF_BUILD_GNUABI_LIBS:BOOL=%{?gnuabi_enabled:TRUE}%{?!gnuabi_enabled:FALSE} \ + -DSLEEF_BUILD_INLINE_HEADERS:BOOL=%{?inline_enabled:TRUE}%{?!inline_enabled:FALSE} \ + -DSLEEF_BUILD_QUAD:BOOL=%{?with_quad:TRUE}%{?!with_quad:FALSE} \ + -DSLEEF_BUILD_SHARED_LIBS:BOOL=TRUE \ + -DSLEEF_ENFORCE_TESTER3:BOOL=TRUE \ + -DSLEEF_ENFORCE_TESTER4:BOOL=%{?with_tlfloat:TRUE}%{?!with_tlfloat:FALSE} \ + -DSLEEF_ENABLE_TLFLOAT:BOOL=%{?with_tlfloat:TRUE}%{?!with_tlfloat:FALSE} + + +%build %cmake_build @@ -226,27 +252,41 @@ rm -vrf src/gencoef %check +# Logging CPU features is helpful for debugging, especially in COPR builds +# where the builder hardware information is not necessarily logged separately. +echo '==== Build host CPU features ====' +cat /proc/cpuinfo + skips='^($.' -# https://github.com/shibatch/sleef/issues/439 -%ifarch x86_64 %{arm64} ppc64le s390x -skips="${skips}|iuty?purecfma_scalar" +%ifarch %{arm64} +# Some tests are specifically for SVE code. We can only run these tests on +# builder hardware that has the SVE extensions, which are not part of the +# aarch64 baseline. +if ! grep -E '[Ff](lags|eatures).*\bsve\b' /proc/cpuinfo >/dev/null +then + skips="${skips}|gnuabi_compatibility_SVE(_masked)?|qiutsve" +fi %endif -%ifarch %{arm64} ppc64le s390x -skips="${skips}|iuty?purec_scalar" -%endif -%ifarch s390x -skips="${skips}|iuty?zvector2(nofma)?" +%ifarch %{power64} +# Some tests are specifically for VSX3 code. We can only run these tests on +# builder hardware that has the VSX3 extensions (POWER 9 or later), which are +# not part of the ppc64le baseline (POWER 8). +if grep -E -i '\bPOWER8\b' /proc/cpuinfo >/dev/null +then + skips="${skips}|.*vsx3(nofma)?" +fi %endif -%if %{with dft} -# The DFT library has known test failures -# (https://github.com/shibatch/sleef/issues/214). -skips="${skips}|fftwtest2d[ds]p_(4_4|8_8|10_10|5_15)" -%ifarch aarch64 s390x -# Plus, it uses illegal instructions: -skips="${skips}|naivetest[ds]p_([2345]|10)" -skips="${skips}|fftwtest(1d[ds]p_1[26]|2d[ds]p_2_2)" +%ifarch %{x86_64} +%if %{undefined fc43} && %{undefined fc42} && %{undefined el10} +# At least one test within this executable fails since GCC 16 landed in Fedora +# 44. It’s not very easy to tell exactly what is going wrong, and upstream is +# not likely to be interested since (as determined by bisection) the failure +# was resolved upstream by the removal of no-FMA helpers in +# https://github.com/shibatch/sleef/pull/685. Let’s just skip this while we +# await the next upstream release. +skips="${skips}|tester4ypurec_scalar" %endif %endif @@ -264,6 +304,7 @@ skips="${skips})$" %{_includedir}/sleef.h %{_libdir}/libsleef.so %{_libdir}/pkgconfig/sleef.pc +%{_libdir}/cmake/sleef/ %if 0%{?inline_enabled} @@ -276,9 +317,8 @@ skips="${skips})$" %files doc %license LICENSE.txt %doc CHANGELOG.md -%doc CONTRIBUTORS.md -%doc README.md -%doc doc/html/ +%doc README.adoc +%doc docs/ %ifarch %{gnuabi_arches} diff --git a/sources b/sources index 7a04a36..a0b715a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (sleef-3.5.1-filtered.tar.xz) = a40e9292bc7164ad0b9a4a718fbe78cccb04a19a4b824d34d7991fd75656be9f9336a5f226b0004e88e01c1c8592b420e789e63a88ff3810a68cf08d6617c1bf +SHA512 (sleef-3.9.0-filtered.tar.zst) = 4c55c310795569debed8c771cf0251a126e8291515bf562e6ac4b611dafe6df5fd0024d129dbeaf2c6bce39112bb8a826acabd762beebdd17de86259394b5933