From 65256f0fcb2e31e0fd74ac11f3c2de5d31ad26af Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Wed, 22 Mar 2023 13:15:42 +0200 Subject: [PATCH] Backport riscv64 fixes Fixes: https://git.savannah.gnu.org/cgit/gawk.git/commit/?id=ca4766401a1a81e548d05f9d113dc29f88b5d9e8 https://git.savannah.gnu.org/cgit/gawk.git/commit/?id=a3799ae3f5dd6648040d499224cc6dea61b355dd Signed-off-by: David Abdurachmanov --- 0001-Fix-riscv64-tests.patch | 273 +++++++++++++++++++++++++++++++++++ gawk.spec | 16 +- 2 files changed, 281 insertions(+), 8 deletions(-) create mode 100644 0001-Fix-riscv64-tests.patch diff --git a/0001-Fix-riscv64-tests.patch b/0001-Fix-riscv64-tests.patch new file mode 100644 index 0000000..fa8623f --- /dev/null +++ b/0001-Fix-riscv64-tests.patch @@ -0,0 +1,273 @@ +From 938b0810eb9e3be288a82ab54215abed76cc72f4 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Wed, 22 Mar 2023 11:13:00 +0000 +Subject: [PATCH] Fix riscv64 tests + + +diff --git a/eval.c b/eval.c +index 9e64452..37d0fa6 100644 +--- a/eval.c ++++ b/eval.c +@@ -41,6 +41,8 @@ static int num_exec_hook = 0; + static Func_pre_exec pre_execute[MAX_EXEC_HOOKS]; + static Func_post_exec post_execute = NULL; + ++static double fix_nan_sign(double left, double right, double result); ++ + extern void frame_popped(); + + int OFSlen; +@@ -1795,3 +1797,20 @@ init_interpret() + interpret = r_interpret; + } + ++/* fix_nan_sign --- fix NaN sign on RiscV */ ++ ++// See the thread starting at ++// https://lists.gnu.org/archive/html/bug-gawk/2022-09/msg00005.html ++// for why we need this function. ++ ++static double ++fix_nan_sign(double left, double right, double result) ++{ ++ if (isnan(left) && signbit(left)) ++ return copysign(result, -1.0); ++ else if (isnan(right) && signbit(right)) ++ return copysign(result, -1.0); ++ else ++ return result; ++} ++ +diff --git a/interpret.h b/interpret.h +index d52d537..0a7beff 100644 +--- a/interpret.h ++++ b/interpret.h +@@ -538,6 +538,7 @@ uninitialized_scalar: + plus: + t1 = TOP_NUMBER(); + r = make_number(t1->numbr + x2); ++ r->numbr = fix_nan_sign(t1->numbr, x2, r->numbr); + DEREF(t1); + REPLACE(r); + break; +@@ -552,6 +553,7 @@ plus: + minus: + t1 = TOP_NUMBER(); + r = make_number(t1->numbr - x2); ++ r->numbr = fix_nan_sign(t1->numbr, x2, r->numbr); + DEREF(t1); + REPLACE(r); + break; +diff --git a/pc/Makefile.tst b/pc/Makefile.tst +index 4c66285..f5abd62 100644 +--- a/pc/Makefile.tst ++++ b/pc/Makefile.tst +@@ -196,7 +196,7 @@ GAWK_EXT_TESTS = \ + gnuops2 gnuops3 gnureops gsubind icasefs icasers id igncdym igncfs \ + ignrcas2 ignrcas4 ignrcase incdupe incdupe2 incdupe3 incdupe4 \ + incdupe5 incdupe6 incdupe7 include include2 indirectbuiltin \ +- indirectcall indirectcall2 inf-nan-torture intarray iolint \ ++ indirectcall indirectcall2 intarray iolint \ + isarrayunset lint lintexp lintindex lintint lintlength lintplus \ + lintold lintset lintwarn manyfiles match1 match2 match3 mbstr1 \ + mbstr2 mixed1 mktime modifiers muldimposix nastyparm negtime \ +@@ -219,7 +219,7 @@ GAWK_EXT_TESTS = \ + ARRAYDEBUG_TESTS = arrdbg + EXTRA_TESTS = inftest regtest ignrcas3 + INET_TESTS = inetdayu inetdayt inetechu inetecht +-MACHINE_TESTS = double1 double2 intformat ++MACHINE_TESTS = double1 double2 inf-nan-torture intformat + LOCALE_CHARSET_TESTS = \ + asort asorti backbigs1 backsmalls1 backsmalls2 \ + fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \ +@@ -361,10 +361,10 @@ check: msg \ + basic-msg-start basic basic-msg-end \ + unix-msg-start unix-tests unix-msg-end \ + extend-msg-start gawk-extensions arraydebug-tests extend-msg-end \ +- machine-msg-start machine-tests machine-msg-end \ + charset-tests-all \ + shlib-msg-start shlib-tests shlib-msg-end \ +- mpfr-msg-start mpfr-tests mpfr-msg-end ++ mpfr-msg-start mpfr-tests mpfr-msg-end \ ++ machine-msg-start machine-tests machine-msg-end + @-$(MAKE) pass-fail || { $(MAKE) diffout; exit 1; } + + basic: $(BASIC_TESTS) +@@ -451,7 +451,9 @@ extend-msg-end: + @-echo "======== Done with gawk extension tests ========" + + machine-msg-start: +- @-echo "======== Starting machine-specific tests ========" ++ @echo "======== Starting machine-specific tests ========" ++ @-echo "If any of these tests fail, don't worry too much." ++ + + machine-msg-end: + @-echo "======== Done with machine-specific tests ========" +@@ -2899,12 +2901,6 @@ indirectcall2: + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +-inf-nan-torture: +- @echo $@ $(ZOS_FAIL) +- @echo Expect $@ to fail with MinGW. +- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +- + intarray: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --non-decimal-data >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +@@ -3400,6 +3396,12 @@ double2: + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(TESTOUTCMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ++inf-nan-torture: ++ @echo $@ $(ZOS_FAIL) ++ @echo Expect $@ to fail with MinGW. ++ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ++ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ++ + intformat: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +diff --git a/test/Makefile.am b/test/Makefile.am +index 547760b..3070cec 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -1445,7 +1445,7 @@ GAWK_EXT_TESTS = \ + gnuops2 gnuops3 gnureops gsubind icasefs icasers id igncdym igncfs \ + ignrcas2 ignrcas4 ignrcase incdupe incdupe2 incdupe3 incdupe4 \ + incdupe5 incdupe6 incdupe7 include include2 indirectbuiltin \ +- indirectcall indirectcall2 inf-nan-torture intarray iolint \ ++ indirectcall indirectcall2 intarray iolint \ + isarrayunset lint lintexp lintindex lintint lintlength lintplus \ + lintold lintset lintwarn manyfiles match1 match2 match3 mbstr1 \ + mbstr2 mixed1 mktime modifiers muldimposix nastyparm negtime \ +@@ -1471,7 +1471,7 @@ EXTRA_TESTS = inftest regtest ignrcas3 + + INET_TESTS = inetdayu inetdayt inetechu inetecht + +-MACHINE_TESTS = double1 double2 intformat ++MACHINE_TESTS = double1 double2 inf-nan-torture intformat + + LOCALE_CHARSET_TESTS = \ + asort asorti backbigs1 backsmalls1 backsmalls2 \ +@@ -1625,10 +1625,10 @@ check: msg \ + basic-msg-start basic basic-msg-end \ + unix-msg-start unix-tests unix-msg-end \ + extend-msg-start gawk-extensions arraydebug-tests extend-msg-end \ +- machine-msg-start machine-tests machine-msg-end \ + charset-tests-all \ + shlib-msg-start shlib-tests shlib-msg-end \ +- mpfr-msg-start mpfr-tests mpfr-msg-end ++ mpfr-msg-start mpfr-tests mpfr-msg-end \ ++ machine-msg-start machine-tests machine-msg-end + @$(MAKE) pass-fail || { $(MAKE) diffout; exit 1; } + + basic: $(BASIC_TESTS) +@@ -1716,6 +1716,7 @@ extend-msg-end: + + machine-msg-start: + @echo "======== Starting machine-specific tests ========" ++ @echo "If any of these tests fail, don't worry too much." + + machine-msg-end: + @echo "======== Done with machine-specific tests ========" +diff --git a/test/Makefile.in b/test/Makefile.in +index b265eab..accb0b3 100644 +--- a/test/Makefile.in ++++ b/test/Makefile.in +@@ -1711,7 +1711,7 @@ GAWK_EXT_TESTS = \ + gnuops2 gnuops3 gnureops gsubind icasefs icasers id igncdym igncfs \ + ignrcas2 ignrcas4 ignrcase incdupe incdupe2 incdupe3 incdupe4 \ + incdupe5 incdupe6 incdupe7 include include2 indirectbuiltin \ +- indirectcall indirectcall2 inf-nan-torture intarray iolint \ ++ indirectcall indirectcall2 intarray iolint \ + isarrayunset lint lintexp lintindex lintint lintlength lintplus \ + lintold lintset lintwarn manyfiles match1 match2 match3 mbstr1 \ + mbstr2 mixed1 mktime modifiers muldimposix nastyparm negtime \ +@@ -1734,7 +1734,7 @@ GAWK_EXT_TESTS = \ + ARRAYDEBUG_TESTS = arrdbg + EXTRA_TESTS = inftest regtest ignrcas3 + INET_TESTS = inetdayu inetdayt inetechu inetecht +-MACHINE_TESTS = double1 double2 intformat ++MACHINE_TESTS = double1 double2 inf-nan-torture intformat + LOCALE_CHARSET_TESTS = \ + asort asorti backbigs1 backsmalls1 backsmalls2 \ + fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \ +@@ -2080,10 +2080,10 @@ check: msg \ + basic-msg-start basic basic-msg-end \ + unix-msg-start unix-tests unix-msg-end \ + extend-msg-start gawk-extensions arraydebug-tests extend-msg-end \ +- machine-msg-start machine-tests machine-msg-end \ + charset-tests-all \ + shlib-msg-start shlib-tests shlib-msg-end \ +- mpfr-msg-start mpfr-tests mpfr-msg-end ++ mpfr-msg-start mpfr-tests mpfr-msg-end \ ++ machine-msg-start machine-tests machine-msg-end + @$(MAKE) pass-fail || { $(MAKE) diffout; exit 1; } + + basic: $(BASIC_TESTS) +@@ -2171,6 +2171,7 @@ extend-msg-end: + + machine-msg-start: + @echo "======== Starting machine-specific tests ========" ++ @echo "If any of these tests fail, don't worry too much." + + machine-msg-end: + @echo "======== Done with machine-specific tests ========" +@@ -4578,11 +4579,6 @@ indirectcall2: + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +-inf-nan-torture: +- @echo $@ $(ZOS_FAIL) +- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +- + intarray: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --non-decimal-data >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +@@ -5072,6 +5068,11 @@ double2: + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ++inf-nan-torture: ++ @echo $@ $(ZOS_FAIL) ++ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ++ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ++ + intformat: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +diff --git a/test/Maketests b/test/Maketests +index eb5e4bb..027b876 100644 +--- a/test/Maketests ++++ b/test/Maketests +@@ -1643,11 +1643,6 @@ indirectcall2: + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +-inf-nan-torture: +- @echo $@ $(ZOS_FAIL) +- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +- @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +- + intarray: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --non-decimal-data >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +@@ -2137,6 +2132,11 @@ double2: + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ++inf-nan-torture: ++ @echo $@ $(ZOS_FAIL) ++ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ++ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ++ + intformat: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +-- +2.40.0 + diff --git a/gawk.spec b/gawk.spec index cee6b64..2733251 100644 --- a/gawk.spec +++ b/gawk.spec @@ -47,7 +47,7 @@ Name: gawk Summary: The GNU version of the AWK text processing utility Version: 5.1.1 -Release: 5.0.riscv64%{?dist} +Release: 5.1.riscv64%{?dist} License: GPLv3+ and GPLv2+ and LGPLv2+ and BSD @@ -139,6 +139,10 @@ BuildRequires: make #Patch200: gawk-4.2.1-200-fix-build-for-f29.patch +# RISC-V backports (already in 5.2.1) +Patch300: 0001-Fix-riscv64-tests.patch + + %description The gawk package contains the GNU version of AWK text processing utility. AWK is a programming language designed for text processing and typically used as a data @@ -205,16 +209,12 @@ git commit --all --amend --no-edit > /dev/null # --------------- %build -%ifarch riscv64 -%define _pkg_extra_cflags -ffp-contract=off -%endif - # NOTE: The re-generating of ./configure (below) should be removed once the # direct dependency on 'aclocal-1.15' is fixed in upstream and backported. autoreconf --force --verbose %configure -%make_build CLAGS="%{optflags} -ffp-contract=off" +%make_build # Build the documentation in PDF, postscript and HTML versions: %make_build -C doc pdf @@ -296,8 +296,8 @@ install -m 0644 -p awklib/eg/data/* %{buildroot}%{_docdir}/%{name}/eg/data/ # ============================================================================= %changelog -* Wed Mar 01 2023 David Abdurachmanov - 5.1.1-5.0.riscv64 -- Build with -ffp-contract=off on riscv64 +* Tue Mar 22 2023 David Abdurachmanov - 5.1.1-5.1.riscv64 +- Backport riscv64 fixes from 5.2.1 * Thu Jan 19 2023 Fedora Release Engineering - 5.1.1-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild