Homo wrote on 22 Jan 06:42 +0100
(address . guix-patches@gnu.org)(name . Homo)(address . gay@disroot.org)
This is required to bootstrap MicroHs.
* gnu/packages/patches/hugs-ignore-integer-overflow.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/hugs.scm (hugs)[source]: Use it.
Change-Id: Ie13085d356f98d4dbb0fd1108b7179ad5226720f
---
It's a strong requirement from Lennart to not remove usage of pattern guards in MicroHs's code, so need help from someone experienced with YACC to add pattern guards support to Hugs, a nice to have, but not required, cherry on top of that: adding bang patterns and "instance forall" support in Hugs.
gnu/local.mk | 1 +
gnu/packages/hugs.scm | 2 +-
.../hugs-ignore-integer-overflow.patch | 55 +++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/hugs-ignore-integer-overflow.patch
Toggle diff (88 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index f118fe4442..ecea6ae9c7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1569,6 +1569,7 @@ dist_patch_DATA = \
%D%/packages/patches/hubbub-sort-entities.patch \
%D%/packages/patches/hueplusplus-mbedtls.patch \
%D%/packages/patches/hugs-fix-build.patch \
+ %D%/packages/patches/hugs-ignore-integer-overflow.patch \
%D%/packages/patches/hurd-64bit.patch \
%D%/packages/patches/hurd-refcounts-assert.patch \
%D%/packages/patches/hurd-rumpdisk-no-hd.patch \
diff --git a/gnu/packages/hugs.scm b/gnu/packages/hugs.scm
index b6a97ea78c..ae7acbd511 100644
--- a/gnu/packages/hugs.scm
+++ b/gnu/packages/hugs.scm
@@ -37,7 +37,7 @@ (define-public hugs
(sha256
(base32
"1mdy4aq4campgmnpc2qwq7bsbfhaxfsqdghbyyz2wms4lnfcmyma"))
- (patches (search-patches "hugs-fix-build.patch"))))
+ (patches (search-patches "hugs-fix-build.patch" "hugs-ignore-integer-overflow.patch"))))
(build-system gnu-build-system)
(arguments
`(#:phases
diff --git a/gnu/packages/patches/hugs-ignore-integer-overflow.patch b/gnu/packages/patches/hugs-ignore-integer-overflow.patch
new file mode 100644
index 0000000000..ef0b7de824
--- /dev/null
+++ b/gnu/packages/patches/hugs-ignore-integer-overflow.patch
@@ -0,0 +1,55 @@
+From a87d3a15194e4d7724627e43a94ac1d12ab78f9c Mon Sep 17 00:00:00 2001
+From: Lennart Augustsson <lennart@augustsson.net>
+Date: Tue, 21 Jan 2025 12:26:15 -0700
+Subject: [PATCH] Ignore overflow in conversion from Integer to Int.
+
+---
+ src/bignums.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/src/bignums.c b/src/bignums.c
+index 32ce528..38ec43f 100644
+--- a/src/bignums.c
++++ b/src/bignums.c
+@@ -196,10 +196,18 @@ Bignum n; {
+ while (nonNull(ds=tl(ds))) {
+ Int d = digitOf(hd(ds));
+ if (b > (Int)(MAXHUGSWORD/BIGBASE))
+- return NIL;
++#if 0
++ return NIL;
++#else
++ fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ b *= BIGBASE;
+ if (d > (Int)((MAXHUGSWORD - m)/b))
+- return NIL;
++#if 0
++ return NIL;
++#else
++ fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ m += b*d;
+ }
+ } else { /* fst(n)==NEGNUM */
+@@ -207,10 +215,18 @@ Bignum n; {
+ while (nonNull(ds=tl(ds))) {
+ Int d = - digitOf(hd(ds));
+ if (b > (MAXPOSINT/BIGBASE))
+- return NIL;
++#if 0
++ return NIL;
++#else
++ fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ b *= BIGBASE;
+ if (d < (MINNEGINT - m)/b)
+- return NIL;
++#if 0
++ return NIL;
++#else
++ fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ m += b*d;
+ }
+ }
--
2.47.1