From e831a2c8da62d19d5fd379ef0f0f94ec2002f984 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Sun, 11 May 2025 21:07:56 +0800 Subject: [PATCH] add upstream patches to fix build under i686 --- 0001-Add-missing-include-in-syscalls.h.patch | 28 +++ ...cess-precision-standard-for-i-3456-8.patch | 54 +++++ ...e-with-GCC-14-and-musl-on-32-bit-sys.patch | 41 ++++ 0001-Fix-compilation-with-C23.patch | 42 ++++ ...-of-logand-immediate-if-no-bits-used.patch | 40 ++++ ...-d579848cb5d65440af5afd9c89686286655.patch | 35 +++ ...ded-bits-computation-in-specialize-n.patch | 73 ++++++ ...ng-of-non-fixnum-negative-u64-values.patch | 56 +++++ ...range-inference-for-scm-u64-truncate.patch | 34 +++ ...point-based-on-use-def-graph-not-cfg.patch | 217 ++++++++++++++++++ guile.spec | 16 +- guile.yaml | 4 +- 12 files changed, 637 insertions(+), 3 deletions(-) create mode 100644 0001-Add-missing-include-in-syscalls.h.patch create mode 100644 0001-Compile-with-fexcess-precision-standard-for-i-3456-8.patch create mode 100644 0001-Fix-build-failure-with-GCC-14-and-musl-on-32-bit-sys.patch create mode 100644 0001-Fix-compilation-with-C23.patch create mode 100644 0001-Narrow-parameter-of-logand-immediate-if-no-bits-used.patch create mode 100644 0002-Partially-revert-d579848cb5d65440af5afd9c89686286655.patch create mode 100644 0003-Fix-fixpoint-needed-bits-computation-in-specialize-n.patch create mode 100644 0004-Fix-boxing-of-non-fixnum-negative-u64-values.patch create mode 100644 0005-Tighten-up-range-inference-for-scm-u64-truncate.patch create mode 100644 0006-Run-sigbits-fixpoint-based-on-use-def-graph-not-cfg.patch diff --git a/0001-Add-missing-include-in-syscalls.h.patch b/0001-Add-missing-include-in-syscalls.h.patch new file mode 100644 index 0000000..abeb15a --- /dev/null +++ b/0001-Add-missing-include-in-syscalls.h.patch @@ -0,0 +1,28 @@ +From 0f2125e66f3ad9df386e7887c87abea1b5e880e9 Mon Sep 17 00:00:00 2001 +From: Michael Gran +Date: Tue, 20 Jun 2023 15:22:21 -0700 +Subject: [PATCH] Add missing #include in syscalls.h + +SCM_SYSCALL uses scm_async_tick. + +* libguile/syscalls.h: include async.h +--- + libguile/syscalls.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libguile/syscalls.h b/libguile/syscalls.h +index e10cc4870..3f2e69344 100644 +--- a/libguile/syscalls.h ++++ b/libguile/syscalls.h +@@ -24,6 +24,8 @@ + + /* ASYNC_TICK after finding EINTR in order to handle pending signals, if + any. See comment in scm_syserror. */ ++#include "async.h" ++ + #define SCM_SYSCALL(line) \ + do \ + { \ +-- +2.49.0 + diff --git a/0001-Compile-with-fexcess-precision-standard-for-i-3456-8.patch b/0001-Compile-with-fexcess-precision-standard-for-i-3456-8.patch new file mode 100644 index 0000000..56b45d6 --- /dev/null +++ b/0001-Compile-with-fexcess-precision-standard-for-i-3456-8.patch @@ -0,0 +1,54 @@ +From 9b1effb58579821ffa9357df808d5264e45fb30c Mon Sep 17 00:00:00 2001 +From: Rob Browning +Date: Sat, 5 Oct 2024 17:18:06 -0500 +Subject: [PATCH] Compile with -fexcess-precision=standard for i[3456]86 when + we can + +* configure.ac: when -fexcess-precision=standard is available and we're +building for i[3456]86, use it. This fixes floating point precision +problems caused by x87 (80-bit) floating point, and detected by +numbers.test. + +Closes: 43262 +--- + configure.ac | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 262b171f1..ce3ae0226 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -62,6 +62,30 @@ AC_PROG_INSTALL + AC_PROG_CC + gl_EARLY + ++AC_MSG_CHECKING([whether the compiler supports -fexcess-precision=standard]) ++old_CFLAGS="$CFLAGS" ++CFLAGS="$CFLAGS -fexcess-precision=standard" ++fexcess_precision='' ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo;], [])], [fexcess_precision=1]]) ++CFLAGS="$old_CFLAGS" ++if test -n "$fexcess_precision"; then ++ AC_MSG_RESULT([yes]) ++else ++ AC_MSG_RESULT([no]) ++fi ++AC_MSG_CHECKING([whether we want -fexcess-precision=standard for $target_cpu]) ++case "$target_cpu" in ++ i[[3456]]86) ++ AC_MSG_RESULT([yes]) ++ if test -n "$fexcess_precision"; then ++ CFLAGS="$CFLAGS -fexcess-precision=standard" ++ else ++ AC_MSG_WARN([floating-point precision may exceed C99 rules]) ++ fi ++ ;; ++ *) AC_MSG_RESULT([no]) ;; ++esac ++ + AC_MSG_CHECKING([whether the compiler supports -flto]) + old_CFLAGS="$CFLAGS" + LTO_CFLAGS="-flto" +-- +2.49.0 + diff --git a/0001-Fix-build-failure-with-GCC-14-and-musl-on-32-bit-sys.patch b/0001-Fix-build-failure-with-GCC-14-and-musl-on-32-bit-sys.patch new file mode 100644 index 0000000..e442f19 --- /dev/null +++ b/0001-Fix-build-failure-with-GCC-14-and-musl-on-32-bit-sys.patch @@ -0,0 +1,41 @@ +From bb7154fb800eb410fb7cc4c353975787353f2246 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Wed, 16 Oct 2024 10:02:01 +0200 +Subject: [PATCH] Fix build failure with GCC 14 and musl on 32-bit systems. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes . + +This fixes this error when compiling with GCC 14 and musl libc on 32-bit +Alpine Linux: + + filesys.c: In function 'scm_sendfile': + filesys.c:1405:16: error: assignment to 'off_t *' {aka 'long long int *'} from incompatible pointer type 'scm_t_off *' {aka 'long int *'} [-Wincompatible-pointer-types] + 1405 | offset_ptr = SCM_UNBNDP (offset) ? NULL : &c_offset; + | ^ + +* libguile/filesys.c (scm_sendfile): Change type of ‘c_offset’. + +Signed-off-by: Ludovic Courtès +--- + libguile/filesys.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libguile/filesys.c b/libguile/filesys.c +index 6896e00ea..b70fbb1ce 100644 +--- a/libguile/filesys.c ++++ b/libguile/filesys.c +@@ -1397,7 +1397,7 @@ SCM_DEFINE (scm_sendfile, "sendfile", 3, 1, 0, + + ssize_t result SCM_UNUSED; + size_t c_count, total = 0; +- scm_t_off c_offset; ++ off_t c_offset; + int in_fd, out_fd; + + VALIDATE_FD_OR_PORT (out_fd, out, 1); +-- +2.49.0 + diff --git a/0001-Fix-compilation-with-C23.patch b/0001-Fix-compilation-with-C23.patch new file mode 100644 index 0000000..d3a83d9 --- /dev/null +++ b/0001-Fix-compilation-with-C23.patch @@ -0,0 +1,42 @@ +From c2e7d834c26dca39e0a2dc6784fc47814969817a Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Tue, 25 Jun 2024 09:30:21 +0200 +Subject: [PATCH] Fix compilation with C23 + +* libguile/jit.c (is_unreachable): Rename from "unreachable", which is +apparently a new reserved word in C23. +--- + libguile/jit.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libguile/jit.c b/libguile/jit.c +index 6f3a650b8..a20a8e7f7 100644 +--- a/libguile/jit.c ++++ b/libguile/jit.c +@@ -1,4 +1,4 @@ +-/* Copyright 2018-2021, 2023 ++/* Copyright 2018-2021, 2023-2024 + Free Software Foundation, Inc. + + This file is part of Guile. +@@ -370,7 +370,7 @@ set_register_state (scm_jit_state *j, uint32_t state) + } + + static uint32_t +-unreachable (scm_jit_state *j) ++is_unreachable (scm_jit_state *j) + { + return j->register_state & UNREACHABLE; + } +@@ -382,7 +382,7 @@ has_register_state (scm_jit_state *j, uint32_t state) + } + + #define ASSERT_HAS_REGISTER_STATE(state) \ +- ASSERT (unreachable (j) || has_register_state (j, state)); ++ ASSERT (is_unreachable (j) || has_register_state (j, state)); + + static void + record_gpr_clobber (scm_jit_state *j, jit_gpr_t r) +-- +2.49.0 + diff --git a/0001-Narrow-parameter-of-logand-immediate-if-no-bits-used.patch b/0001-Narrow-parameter-of-logand-immediate-if-no-bits-used.patch new file mode 100644 index 0000000..305dff6 --- /dev/null +++ b/0001-Narrow-parameter-of-logand-immediate-if-no-bits-used.patch @@ -0,0 +1,40 @@ +From 5e6288c9304b60f1875a44808ee3858e3d6efc83 Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Mon, 23 Sep 2024 15:57:23 +0200 +Subject: [PATCH] Narrow parameter of logand/immediate if no bits used + +* module/language/cps/specialize-numbers.scm (specialize-operations): +Narrow ulogand/immediate param according to used bits. +--- + module/language/cps/specialize-numbers.scm | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/module/language/cps/specialize-numbers.scm b/module/language/cps/specialize-numbers.scm +index 4ec88871c..f93250756 100644 +--- a/module/language/cps/specialize-numbers.scm ++++ b/module/language/cps/specialize-numbers.scm +@@ -1,6 +1,6 @@ + ;;; Continuation-passing style (CPS) intermediate language (IL) + +-;; Copyright (C) 2015-2021, 2023 Free Software Foundation, Inc. ++;; Copyright (C) 2015-2021,2023-2024 Free Software Foundation, Inc. + + ;;;; This library is free software; you can redistribute it and/or + ;;;; modify it under the terms of the GNU Lesser General Public +@@ -561,9 +561,11 @@ BITS indicating the significant bits needed for a variable. BITS may be + (specialize-unop cps k src op param a + (unbox-u64 a) (box-u64 result)))) + +- (('logand/immediate (? u64-result? ) param (? u64-operand? a)) ++ (('logand/immediate (? u64-result?) param (? u64-operand? a)) + (specialize-unop cps k src 'ulogand/immediate +- (logand param (1- (ash 1 64))) ++ (logand param ++ (or (intmap-ref sigbits result) -1) ++ (1- (ash 1 64))) + a + (unbox-u64 a) (box-u64 result))) + +-- +2.49.0 + diff --git a/0002-Partially-revert-d579848cb5d65440af5afd9c89686286655.patch b/0002-Partially-revert-d579848cb5d65440af5afd9c89686286655.patch new file mode 100644 index 0000000..464d882 --- /dev/null +++ b/0002-Partially-revert-d579848cb5d65440af5afd9c89686286655.patch @@ -0,0 +1,35 @@ +From b04071cc579e7b9d38d0c999e731bdd94b7f7a78 Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Tue, 24 Sep 2024 09:24:15 +0200 +Subject: [PATCH] Partially revert d579848cb5d65440af5afd9c8968628665554c22 + +* module/language/cps/specialize-numbers.scm (specialize-operations): +Accept any operand to logand/immediate, provided the result is a u64 in +the right range. +--- + module/language/cps/specialize-numbers.scm | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/module/language/cps/specialize-numbers.scm b/module/language/cps/specialize-numbers.scm +index f93250756..cd884533c 100644 +--- a/module/language/cps/specialize-numbers.scm ++++ b/module/language/cps/specialize-numbers.scm +@@ -561,13 +561,13 @@ BITS indicating the significant bits needed for a variable. BITS may be + (specialize-unop cps k src op param a + (unbox-u64 a) (box-u64 result)))) + +- (('logand/immediate (? u64-result?) param (? u64-operand? a)) ++ (('logand/immediate (? u64-result?) param a) + (specialize-unop cps k src 'ulogand/immediate + (logand param + (or (intmap-ref sigbits result) -1) + (1- (ash 1 64))) + a +- (unbox-u64 a) (box-u64 result))) ++ (unbox-u64/truncate a) (box-u64 result))) + + (((or 'add/immediate 'sub/immediate 'mul/immediate) + (? s64-result?) (? s64-parameter?) (? s64-operand? a)) +-- +2.49.0 + diff --git a/0003-Fix-fixpoint-needed-bits-computation-in-specialize-n.patch b/0003-Fix-fixpoint-needed-bits-computation-in-specialize-n.patch new file mode 100644 index 0000000..8d08c4c --- /dev/null +++ b/0003-Fix-fixpoint-needed-bits-computation-in-specialize-n.patch @@ -0,0 +1,73 @@ +From 0dab58fc2a6ac6a8354439749d598f8c24f57ddd Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Wed, 25 Sep 2024 17:23:06 +0200 +Subject: [PATCH] Fix fixpoint needed-bits computation in specialize-numbers + +* module/language/cps/specialize-numbers.scm (next-power-of-two): Use +integer-length. No change. +(compute-significant-bits): Fix the fixpoint computation, which was +failing to complete in some cases with loops. +--- + module/language/cps/specialize-numbers.scm | 27 ++++++++-------------- + 1 file changed, 10 insertions(+), 17 deletions(-) + +diff --git a/module/language/cps/specialize-numbers.scm b/module/language/cps/specialize-numbers.scm +index cd884533c..f70c28e08 100644 +--- a/module/language/cps/specialize-numbers.scm ++++ b/module/language/cps/specialize-numbers.scm +@@ -265,10 +265,7 @@ + (sigbits-intersect a (sigbits-intersect b c))) + + (define (next-power-of-two n) +- (let lp ((out 1)) +- (if (< n out) +- out +- (lp (ash out 1))))) ++ (ash 1 (integer-length n))) + + (define (range->sigbits min max) + (cond +@@ -310,18 +307,16 @@ + BITS indicating the significant bits needed for a variable. BITS may be + #f to indicate all bits, or a non-negative integer indicating a bitmask." + (let ((preds (invert-graph (compute-successors cps kfun)))) +- (let lp ((worklist (intmap-keys preds)) (visited empty-intset) +- (out empty-intmap)) ++ (let lp ((worklist (intmap-keys preds)) (out empty-intmap)) + (match (intset-prev worklist) + (#f out) + (label +- (let ((worklist (intset-remove worklist label)) +- (visited* (intset-add visited label))) ++ (let ((worklist (intset-remove worklist label))) + (define (continue out*) +- (if (and (eq? out out*) (eq? visited visited*)) +- (lp worklist visited out) ++ (if (eq? out out*) ++ (lp worklist out) + (lp (intset-union worklist (intmap-ref preds label)) +- visited* out*))) ++ out*))) + (define (add-def out var) + (intmap-add out var 0 sigbits-union)) + (define (add-defs out vars) +@@ -352,12 +347,10 @@ BITS indicating the significant bits needed for a variable. BITS may be + (($ $values args) + (match (intmap-ref cps k) + (($ $kargs _ vars) +- (if (intset-ref visited k) +- (fold (lambda (arg var out) +- (intmap-add out arg (intmap-ref out var) +- sigbits-union)) +- out args vars) +- out)) ++ (fold (lambda (arg var out) ++ (intmap-add out arg (intmap-ref out var (lambda (_) 0)) ++ sigbits-union)) ++ out args vars)) + (($ $ktail) + (add-unknown-uses out args)))) + (($ $call proc args) +-- +2.49.0 + diff --git a/0004-Fix-boxing-of-non-fixnum-negative-u64-values.patch b/0004-Fix-boxing-of-non-fixnum-negative-u64-values.patch new file mode 100644 index 0000000..c6caa7b --- /dev/null +++ b/0004-Fix-boxing-of-non-fixnum-negative-u64-values.patch @@ -0,0 +1,56 @@ +From e45b70dcded37eb77e71ec30445b12040b6bb1b7 Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Wed, 25 Sep 2024 17:24:51 +0200 +Subject: [PATCH] Fix boxing of non-fixnum negative u64 values + +* module/language/cps/specialize-numbers.scm (u64->fixnum/truncate): New +helper. +(specialize-operations): Fix specialized boxing of u64 values to +truncate possibly-negative values, to avoid confusing CSE. Fixes +https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71891. +--- + module/language/cps/specialize-numbers.scm | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/module/language/cps/specialize-numbers.scm b/module/language/cps/specialize-numbers.scm +index f70c28e08..b46919a40 100644 +--- a/module/language/cps/specialize-numbers.scm ++++ b/module/language/cps/specialize-numbers.scm +@@ -115,6 +115,13 @@ + (letk ks64 ($kargs ('s64) (s64) ,tag-body)) + (build-term + ($continue ks64 src ($primcall 'u64->s64 #f (u64)))))) ++(define (u64->fixnum/truncate cps k src u64 bits) ++ (with-cps cps ++ (letv truncated) ++ (let$ tag-body (u64->fixnum k src truncated)) ++ (letk ku64 ($kargs ('truncated) (truncated) ,tag-body)) ++ (build-term ++ ($continue ku64 src ($primcall 'ulogand/immediate bits (u64)))))) + (define-simple-primcall scm->u64) + (define-simple-primcall scm->u64/truncate) + (define-simple-primcall u64->scm) +@@ -473,7 +480,19 @@ BITS indicating the significant bits needed for a variable. BITS may be + (define (box-s64 result) + (if (fixnum-result? result) tag-fixnum s64->scm)) + (define (box-u64 result) +- (if (fixnum-result? result) u64->fixnum u64->scm)) ++ (call-with-values ++ (lambda () ++ (lookup-post-type types label result 0)) ++ (lambda (type min max) ++ (cond ++ ((and (type<=? type &exact-integer) ++ (<= 0 min max (target-most-positive-fixnum))) ++ u64->fixnum) ++ ((only-fixnum-bits-used? result) ++ (lambda (cps k src u64) ++ (u64->fixnum/truncate cps k src u64 (intmap-ref sigbits result)))) ++ (else ++ u64->scm))))) + (define (box-f64 result) + f64->scm) + +-- +2.49.0 + diff --git a/0005-Tighten-up-range-inference-for-scm-u64-truncate.patch b/0005-Tighten-up-range-inference-for-scm-u64-truncate.patch new file mode 100644 index 0000000..d90fa74 --- /dev/null +++ b/0005-Tighten-up-range-inference-for-scm-u64-truncate.patch @@ -0,0 +1,34 @@ +From 30c3849092b17a56b9b74dd23da121afc5076e08 Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Wed, 25 Sep 2024 17:27:17 +0200 +Subject: [PATCH] Tighten up range inference for scm->u64/truncate + +* module/language/cps/types.scm (scm->u64/truncate): Better range +analysis. +--- + module/language/cps/types.scm | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm +index 512be4bb2..db4a8c7c8 100644 +--- a/module/language/cps/types.scm ++++ b/module/language/cps/types.scm +@@ -1008,10 +1008,12 @@ minimum, and maximum." + (define! result &u64 param param)) + + (define-type-checker (scm->u64/truncate scm) +- (check-type scm &exact-integer &range-min &range-max)) ++ (check-type scm &exact-integer -inf.0 +inf.0)) + (define-type-inferrer (scm->u64/truncate scm result) +- (restrict! scm &exact-integer &range-min &range-max) +- (define! result &u64 0 &u64-max)) ++ (restrict! scm &exact-integer -inf.0 +inf.0) ++ (if (<= 0 (&min scm) (&max scm) &u64-max) ++ (define! result &u64 (&min scm) (&max scm)) ++ (define! result &u64 0 &u64-max))) + + (define-type-checker (u64->scm u64) + #t) +-- +2.49.0 + diff --git a/0006-Run-sigbits-fixpoint-based-on-use-def-graph-not-cfg.patch b/0006-Run-sigbits-fixpoint-based-on-use-def-graph-not-cfg.patch new file mode 100644 index 0000000..fbf629b --- /dev/null +++ b/0006-Run-sigbits-fixpoint-based-on-use-def-graph-not-cfg.patch @@ -0,0 +1,217 @@ +From aff9ac968840e9c86719fb613bd2ed3c39b9905c Mon Sep 17 00:00:00 2001 +From: Andy Wingo +Date: Thu, 26 Sep 2024 11:14:52 +0200 +Subject: [PATCH] Run sigbits fixpoint based on use/def graph, not cfg + +* module/language/cps/specialize-numbers.scm (sigbits-ref): New helper. +(invert-graph*): New helper. +(compute-significant-bits): When visiting a term changes computed +needed-bits for one of its definitions, we need to revisit the variables +that contributed to its result (the uses), because they might need more +bits as well. Previously we were doing this by enqueueing predecessors +to the term, which worked if the uses were defined in predecessors, or +if all defining terms were already in the worklist, which is the case +without loops. But with loops, when revisiting a term, you could see +that it causes sigbits to change, enqueue its predecessors, but then the +predecessors don't change anything and the fixpoint stops before +reaching the definitions of the variables we need. So instead we +compute the use-def graph and enqueue defs directly. +--- + module/language/cps/specialize-numbers.scm | 120 ++++++++++----------- + 1 file changed, 54 insertions(+), 66 deletions(-) + +diff --git a/module/language/cps/specialize-numbers.scm b/module/language/cps/specialize-numbers.scm +index b46919a40..4983326f6 100644 +--- a/module/language/cps/specialize-numbers.scm ++++ b/module/language/cps/specialize-numbers.scm +@@ -286,6 +286,9 @@ + (and (type<=? type (logior &exact-integer &u64 &s64)) + (range->sigbits min max))))) + ++(define (sigbits-ref sigbits var) ++ (intmap-ref sigbits var (lambda (_) 0))) ++ + (define significant-bits-handlers (make-hash-table)) + (define-syntax-rule (define-significant-bits-handler + ((primop label types out def ...) param arg ...) +@@ -297,24 +300,42 @@ + (define-significant-bits-handler ((logand label types out res) param a b) + (let ((sigbits (sigbits-intersect3 (inferred-sigbits types label a) + (inferred-sigbits types label b) +- (intmap-ref out res (lambda (_) 0))))) ++ (sigbits-ref out res)))) + (intmap-add (intmap-add out a sigbits sigbits-union) + b sigbits sigbits-union))) + (define-significant-bits-handler ((logand/immediate label types out res) param a) + (let ((sigbits (sigbits-intersect3 (inferred-sigbits types label a) + param +- (intmap-ref out res (lambda (_) 0))))) ++ (sigbits-ref out res)))) + (intmap-add out a sigbits sigbits-union))) + + (define (significant-bits-handler primop) + (hashq-ref significant-bits-handlers primop)) + ++(define (invert-graph* defs) ++ "Given a graph LABEL->VAR..., return a graph VAR->LABEL.... Like the one ++in (language cps graphs), but different because it doesn't assume that ++the domain will be the same before and after." ++ (persistent-intmap ++ (intmap-fold (lambda (label vars out) ++ (intset-fold ++ (lambda (var out) ++ (intmap-add! out var (intset label) intset-union)) ++ vars ++ out)) ++ defs ++ empty-intmap))) ++ + (define (compute-significant-bits cps types kfun) + "Given the locally inferred types @var{types}, compute a map of VAR -> + BITS indicating the significant bits needed for a variable. BITS may be + #f to indicate all bits, or a non-negative integer indicating a bitmask." +- (let ((preds (invert-graph (compute-successors cps kfun)))) +- (let lp ((worklist (intmap-keys preds)) (out empty-intmap)) ++ (let ((cps (intmap-select cps (compute-function-body cps kfun)))) ++ ;; Label -> Var... ++ (define-values (defs uses) (compute-defs-and-uses cps)) ++ ;; Var -> Label... ++ (define defs-by-var (invert-graph* defs)) ++ (let lp ((worklist (intmap-keys cps)) (out empty-intmap)) + (match (intset-prev worklist) + (#f out) + (label +@@ -322,69 +343,36 @@ BITS indicating the significant bits needed for a variable. BITS may be + (define (continue out*) + (if (eq? out out*) + (lp worklist out) +- (lp (intset-union worklist (intmap-ref preds label)) ++ (lp (intset-fold ++ (lambda (use worklist) ++ (intset-union worklist (intmap-ref defs-by-var use))) ++ (intmap-ref uses label) ++ worklist) + out*))) +- (define (add-def out var) +- (intmap-add out var 0 sigbits-union)) +- (define (add-defs out vars) +- (match vars +- (() out) +- ((var . vars) (add-defs (add-def out var) vars)))) +- (define (add-unknown-use out var) ++ (define (add-unknown-use var out) + (intmap-add out var (inferred-sigbits types label var) + sigbits-union)) +- (define (add-unknown-uses out vars) +- (match vars +- (() out) +- ((var . vars) +- (add-unknown-uses (add-unknown-use out var) vars)))) ++ (define (default) ++ (intset-fold add-unknown-use (intmap-ref uses label) out)) + (continue + (match (intmap-ref cps label) +- (($ $kfun src meta self) +- (if self (add-def out self) out)) +- (($ $kargs names vars term) +- (let ((out (add-defs out vars))) +- (match term +- (($ $continue k src exp) +- (match exp +- ((or ($ $const) ($ $prim) ($ $fun) ($ $const-fun) +- ($ $code) ($ $rec)) +- ;; No uses, so no info added to sigbits. +- out) +- (($ $values args) +- (match (intmap-ref cps k) +- (($ $kargs _ vars) +- (fold (lambda (arg var out) +- (intmap-add out arg (intmap-ref out var (lambda (_) 0)) +- sigbits-union)) +- out args vars)) +- (($ $ktail) +- (add-unknown-uses out args)))) +- (($ $call proc args) +- (add-unknown-use (add-unknown-uses out args) proc)) +- (($ $callk label proc args) +- (let ((out (add-unknown-uses out args))) +- (if proc +- (add-unknown-use out proc) +- out))) +- (($ $calli args callee) +- (add-unknown-uses (add-unknown-use out callee) args)) +- (($ $primcall name param args) +- (let ((h (significant-bits-handler name))) +- (if h +- (match (intmap-ref cps k) +- (($ $kargs _ defs) +- (h label types out param args defs))) +- (add-unknown-uses out args)))))) +- (($ $branch kf kt src op param args) +- (add-unknown-uses out args)) +- (($ $switch kf kt src arg) +- (add-unknown-use out arg)) +- (($ $prompt k kh src escape? tag) +- (add-unknown-use out tag)) +- (($ $throw src op param args) +- (add-unknown-uses out args))))) +- (_ out))))))))) ++ (($ $kargs _ _ ($ $continue k _ ($ $primcall op param args))) ++ (match (significant-bits-handler op) ++ (#f (default)) ++ (h ++ (match (intmap-ref cps k) ++ (($ $kargs _ defs) ++ (h label types out param args defs)))))) ++ (($ $kargs _ _ ($ $continue k _ ($ $values args))) ++ (match (intmap-ref cps k) ++ (($ $kargs _ vars) ++ (fold (lambda (arg var out) ++ (intmap-add out arg (sigbits-ref out var) ++ sigbits-union)) ++ out args vars)) ++ (($ $ktail) ++ (default)))) ++ (_ (default)))))))))) + + (define (specialize-operations cps) + (define (u6-parameter? param) +@@ -416,7 +404,7 @@ BITS indicating the significant bits needed for a variable. BITS may be + (define (all-u64-bits-set? var) + (operand-in-range? var &exact-integer (1- (ash 1 64)) (1- (ash 1 64)))) + (define (only-fixnum-bits-used? var) +- (let ((bits (intmap-ref sigbits var))) ++ (let ((bits (sigbits-ref sigbits var))) + (and bits (= bits (logand bits (target-most-positive-fixnum)))))) + (define (fixnum-result? result) + (or (only-fixnum-bits-used? result) +@@ -429,7 +417,7 @@ BITS indicating the significant bits needed for a variable. BITS may be + min max + (target-most-positive-fixnum))))))) + (define (only-u64-bits-used? var) +- (let ((bits (intmap-ref sigbits var))) ++ (let ((bits (sigbits-ref sigbits var))) + (and bits (= bits (logand bits (1- (ash 1 64))))))) + (define (u64-result? result) + (or (only-u64-bits-used? result) +@@ -490,7 +478,7 @@ BITS indicating the significant bits needed for a variable. BITS may be + u64->fixnum) + ((only-fixnum-bits-used? result) + (lambda (cps k src u64) +- (u64->fixnum/truncate cps k src u64 (intmap-ref sigbits result)))) ++ (u64->fixnum/truncate cps k src u64 (sigbits-ref sigbits result)))) + (else + u64->scm))))) + (define (box-f64 result) +@@ -576,7 +564,7 @@ BITS indicating the significant bits needed for a variable. BITS may be + (('logand/immediate (? u64-result?) param a) + (specialize-unop cps k src 'ulogand/immediate + (logand param +- (or (intmap-ref sigbits result) -1) ++ (or (sigbits-ref sigbits a) -1) + (1- (ash 1 64))) + a + (unbox-u64/truncate a) (box-u64 result))) +-- +2.49.0 + diff --git a/guile.spec b/guile.spec index 8dfe397..43bf4b6 100644 --- a/guile.spec +++ b/guile.spec @@ -7,7 +7,7 @@ Name: guile Version: 3.0.10 %global mver 3.0 -Release: 2 +Release: 3 Epoch: 5 Summary: GNU's Ubiquitous Intelligent Language for Extension License: LGPL-3.0-or-later and MIT and Public Domain and GPL-3.0-or-later @@ -21,6 +21,16 @@ Patch1: guile-3.0.7-disable-oom-test.patch Patch2: guile-3.0.7-chroot.patch Patch3: guile-3.0.7-disable-stackoverflow-test.patch Patch4: guile-3.0-gc_pkgconfig_private.patch +Patch6001: 0001-Fix-compilation-with-C23.patch +Patch6002: 0001-Compile-with-fexcess-precision-standard-for-i-3456-8.patch +Patch6003: 0001-Fix-build-failure-with-GCC-14-and-musl-on-32-bit-sys.patch +Patch6004: 0001-Add-missing-include-in-syscalls.h.patch +Patch6005: 0001-Narrow-parameter-of-logand-immediate-if-no-bits-used.patch +Patch6006: 0002-Partially-revert-d579848cb5d65440af5afd9c89686286655.patch +Patch6007: 0003-Fix-fixpoint-needed-bits-computation-in-specialize-n.patch +Patch6008: 0004-Fix-boxing-of-non-fixnum-negative-u64-values.patch +Patch6009: 0005-Tighten-up-range-inference-for-scm-u64-truncate.patch +Patch6010: 0006-Run-sigbits-fixpoint-based-on-use-def-graph-not-cfg.patch BuildRequires: gcc make BuildRequires: autoconf automake libtool gettext-devel BuildRequires: pkgconfig(bdw-gc) >= 7.2 @@ -56,6 +66,7 @@ tar xf %{S:1} %endif %build +export CFLAGS="%{build_cflags} -std=gnu17" autoreconf -fiv %configure --disable-static --disable-error-on-warning %make_build @@ -166,6 +177,9 @@ fi %{_infodir}/* %changelog +* Sun May 11 2025 Funda Wang - 5:3.0.10-3 +- add upstream patches to fix build under i686 + * Fri May 09 2025 Funda Wang - 5:3.0.10-2 - disable compat build diff --git a/guile.yaml b/guile.yaml index 36e5683..e379b09 100644 --- a/guile.yaml +++ b/guile.yaml @@ -1,4 +1,4 @@ version_control: git src_repo: https://git.savannah.gnu.org/git/guile.git -tag_prefix: ^guile- -seperator: "." +tag_prefix: ^v +separator: "." -- Gitee