From e483ed0e729742ec8eb83eb81d0f7007ad95708e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Mon, 22 Nov 2021 19:24:50 -0300 Subject: [PATCH] sympow: do not mess with fpu control word It turns out doing that on musl results in wrong output for doubles. Moreover any cpu with sse2 should not be using fp registers anyway. For i686 without sse, the configure will figure out that floats are 80 bits and add -ffloat-store to CFLAGS to force them to be 64 bits. A simple way to test it is to run $ sympow -curve '[0,0,0,0,1]' -analrank ... Analytic Rank is 0 : L-value 7.01091e-01 When broken this prints "7.01092e-01" instead. The actual value computed to 128 bits with pari is: $ echo 'elllseries(ellinit([0,0,0,0,1]),1)' | gp -q 0.70109105266272713058750953952514706773 so the glibc output is the correct one. What is broken is not computing but printing, as fmt_fp in musl uses long double, which means messing with fpu control word breaks it. This is important since sagemath parses sympow output. This affects sagemath doctests as in $ sage -t src/sage/lfunctions/sympow.py ... (3 failures) After this commit, the doctest in question passes. --- .../patches/dont-change-fpu-control-word.patch | 16 ++++++++++++++++ srcpkgs/sympow/template | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/sympow/patches/dont-change-fpu-control-word.patch diff --git a/srcpkgs/sympow/patches/dont-change-fpu-control-word.patch b/srcpkgs/sympow/patches/dont-change-fpu-control-word.patch new file mode 100644 index 000000000000..2a1155111268 --- /dev/null +++ b/srcpkgs/sympow/patches/dont-change-fpu-control-word.patch @@ -0,0 +1,16 @@ +--- a/Configure 2021-11-22 22:20:42.512565997 -0300 ++++ b/Configure 2021-11-22 23:10:09.986457874 -0300 +@@ -154,9 +154,10 @@ + done + + # Select the most appropriate FPU control scheme +-for FLAG in '-DISOC99_FENV' '-DFPUCONTROLH' '-Dx86'; do +- try_add_CFLAG $FLAG && break +-done ++## disable messing with fpu control word -- not worth it ++# for FLAG in '-DISOC99_FENV' '-DFPUCONTROLH' '-Dx86'; do ++# try_add_CFLAG $FLAG && break ++# done + + # Some flags to try as last resort. These hurt performance, so only add + # them if needed. diff --git a/srcpkgs/sympow/template b/srcpkgs/sympow/template index d484cf847f57..48e2399b72e3 100644 --- a/srcpkgs/sympow/template +++ b/srcpkgs/sympow/template @@ -1,7 +1,7 @@ # Template file for 'sympow' pkgname=sympow version=2.023.6 -revision=2 +revision=3 wrksrc=${pkgname}-v${version} build_style=configure make_build_target=all