From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1681396-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 4B68D158042
	for <garchives@archives.gentoo.org>; Fri, 18 Oct 2024 14:44:09 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 8A877E0872;
	Fri, 18 Oct 2024 14:44:08 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 647EFE0872
	for <gentoo-commits@lists.gentoo.org>; Fri, 18 Oct 2024 14:44:08 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 7F39A33BE19
	for <gentoo-commits@lists.gentoo.org>; Fri, 18 Oct 2024 14:44:07 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 1CBFE1293
	for <gentoo-commits@lists.gentoo.org>; Fri, 18 Oct 2024 14:44:06 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1729262614.7c24a2c27204988e57f21ae6ce4f0c7c5b5e2871.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-scheme/guile/files/, dev-scheme/guile/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-scheme/guile/files/guile-3.0-fix-32bit-BE.patch dev-scheme/guile/files/guile-3.0.10-backport-issue72913.patch dev-scheme/guile/guile-3.0.10-r102.ebuild
X-VCS-Directories: dev-scheme/guile/files/ dev-scheme/guile/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 7c24a2c27204988e57f21ae6ce4f0c7c5b5e2871
X-VCS-Branch: master
Date: Fri, 18 Oct 2024 14:44:06 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 7e405305-55f0-443f-921e-de253e80461b
X-Archives-Hash: e9c00163b4972f154197f7e8b16abe44

commit:     7c24a2c27204988e57f21ae6ce4f0c7c5b5e2871
Author:     Matoro Mahri <matoro_gentoo <AT> matoro <DOT> tk>
AuthorDate: Tue Oct 15 21:33:56 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Oct 18 14:43:34 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7c24a2c2

dev-scheme/guile: backport patches to fix 32-bit BE build

[sam: Move eautoreconf, revbump as it affects the compiler on all
platforms, add comment.]

Closes: https://bugs.gentoo.org/940650
Signed-off-by: Matoro Mahri <matoro_gentoo <AT> matoro.tk>
Closes: https://github.com/gentoo/gentoo/pull/39007
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../guile/files/guile-3.0-fix-32bit-BE.patch       |  21 ++
 .../files/guile-3.0.10-backport-issue72913.patch   | 394 +++++++++++++++++++++
 dev-scheme/guile/guile-3.0.10-r102.ebuild          | 126 +++++++
 3 files changed, 541 insertions(+)

diff --git a/dev-scheme/guile/files/guile-3.0-fix-32bit-BE.patch b/dev-scheme/guile/files/guile-3.0-fix-32bit-BE.patch
new file mode 100644
index 000000000000..6417f639b5df
--- /dev/null
+++ b/dev-scheme/guile/files/guile-3.0-fix-32bit-BE.patch
@@ -0,0 +1,21 @@
+https://bugs.gentoo.org/940650#c4
+https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=977223;filename=guile-3.0-fix-32bit-BE.patch;msg=66
+
+diff --git a/stage0/Makefile.am b/stage0/Makefile.am
+index 12029fb45..b00611df0 100644
+--- a/stage0/Makefile.am
++++ b/stage0/Makefile.am
+@@ -22,7 +22,12 @@
+ 
+ 
+ GUILE_WARNINGS = -W0
+-GUILE_OPTIMIZATIONS = -O1
++$(ifeq($SCM_PREBUILT_BINARIES,"32-bit-little-endian") \
++	GUILE_OPTIMIZATIONS = -O1 -Oresolve-primitives -Ocps \
++else \
++	GUILE_OPTIMIZATIONS = -O1 \
++endif)
++
+ GUILE_BOOTSTRAP_STAGE = stage0
+ 
+ include $(top_srcdir)/am/bootstrap.am

diff --git a/dev-scheme/guile/files/guile-3.0.10-backport-issue72913.patch b/dev-scheme/guile/files/guile-3.0.10-backport-issue72913.patch
new file mode 100644
index 000000000000..0a4d84cfea31
--- /dev/null
+++ b/dev-scheme/guile/files/guile-3.0.10-backport-issue72913.patch
@@ -0,0 +1,394 @@
+https://bugs.gentoo.org/940650#c12
+https://issues.guix.gnu.org/72913
+https://git.savannah.gnu.org/cgit/guile.git/commit/?id=aff9ac968840e9c86719fb613bd2ed3c39b9905c
+
+From 605440d8021061a4ef8c18370783ef39f62c59b2 Mon Sep 17 00:00:00 2001
+From: Andy Wingo <wingo@pobox.com>
+Date: Wed, 25 Sep 2024 17:23:06 +0200
+Subject: [PATCH 1/4] 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 4ec88871c..12963cd71 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.47.0
+
+
+From 6953fcb8d9b7d9d36bf36e83e80e24153d37e2a4 Mon Sep 17 00:00:00 2001
+From: Andy Wingo <wingo@pobox.com>
+Date: Wed, 25 Sep 2024 17:24:51 +0200
+Subject: [PATCH 2/4] 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 12963cd71..e9761f0cb 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.47.0
+
+
+From b0559dbe88eb54e2bba4a82dd1f7e7c5b6de2f55 Mon Sep 17 00:00:00 2001
+From: Andy Wingo <wingo@pobox.com>
+Date: Mon, 23 Sep 2024 15:57:23 +0200
+Subject: [PATCH 3/4] 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 e9761f0cb..262dee484 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
+@@ -573,9 +573,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.47.0
+
+
+From 51db308ec2107f9fb32a06004e7a0a3da6418ff6 Mon Sep 17 00:00:00 2001
+From: Andy Wingo <wingo@pobox.com>
+Date: Thu, 26 Sep 2024 11:14:52 +0200
+Subject: [PATCH 4/4] 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 262dee484..ac63c8194 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 (? u64-operand? 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 a) (box-u64 result)))
+-- 
+2.47.0
+

diff --git a/dev-scheme/guile/guile-3.0.10-r102.ebuild b/dev-scheme/guile/guile-3.0.10-r102.ebuild
new file mode 100644
index 000000000000..1b276a4f9906
--- /dev/null
+++ b/dev-scheme/guile/guile-3.0.10-r102.ebuild
@@ -0,0 +1,126 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools
+
+DESCRIPTION="GNU Ubiquitous Intelligent Language for Extensions"
+HOMEPAGE="https://www.gnu.org/software/guile/"
+SRC_URI="mirror://gnu/guile/${P}.tar.xz"
+
+LICENSE="LGPL-3+"
+SLOT="$(ver_cut 1-2)"  # See (guile)Parallel Installations.
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos"
+
+IUSE="debug debug-malloc +deprecated +jit +networking +nls +regex +threads" # upstream recommended +networking +nls
+REQUIRED_USE="regex" # workaround for bug #596322
+RESTRICT="strip"
+
+RDEPEND="
+	>=dev-libs/boehm-gc-7.0[threads?]
+	dev-libs/gmp:=
+	dev-libs/libffi:=
+	dev-libs/libatomic_ops
+	dev-libs/libunistring:=
+	sys-libs/ncurses:=
+	sys-libs/readline:=
+	virtual/libcrypt:=
+	!dev-scheme/guile:12
+"
+DEPEND="${RDEPEND}"
+BDEPEND="
+	virtual/pkgconfig
+	dev-build/libtool
+	sys-devel/gettext
+"
+
+# guile generates ELF files without use of C or machine code
+# It's false positive. bug #677600
+QA_PREBUILT='*[.]go'
+
+DOCS=( ABOUT-NLS AUTHORS ChangeLog GUILE-VERSION HACKING NEWS README THANKS )
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-2.2.3-gentoo-sandbox.patch
+	"${FILESDIR}/${PN}-3.0-fix-32bit-BE.patch"
+	"${FILESDIR}/${PN}-3.0.10-backport-issue72913.patch"
+)
+
+# Where to install data files.
+GUILE_DATA="${EPREFIX}/usr/share/guile-data/${SLOT}"
+GUILE_PCDIR="${EPREFIX}/usr/share/guile-data/${SLOT}/pkgconfig"
+GUILE_INFODIR="${GUILE_DATA}"/info
+
+src_prepare() {
+	default
+
+	# Needed for fix-32bit-BE.patch
+	eautoreconf
+}
+
+src_configure() {
+	# See bug #676468 (may be able to drop this if we adapt fix-32bit-BE.patch)?
+	mv prebuilt/32-bit-big-endian{,.broken} || die
+
+	local -a myconf=(
+		--program-suffix="-${SLOT}"
+		--infodir="${GUILE_INFODIR}"
+		--with-pkgconfigdir="${GUILE_PCDIR}"
+
+		--disable-error-on-warning
+		--disable-rpath
+		--disable-lto
+		--enable-posix
+		--without-libgmp-prefix
+		--without-libiconv-prefix
+		--without-libintl-prefix
+		--without-libreadline-prefix
+		--without-libunistring-prefix
+		$(use_enable debug guile-debug)
+		$(use_enable debug-malloc)
+		$(use_enable deprecated)
+		$(use_enable jit)
+		$(use_enable networking)
+		$(use_enable nls)
+		$(use_enable regex)
+		$(use_with threads)
+	)
+
+	econf "${myconf[@]}"
+}
+
+# Akin to (and taken from) toolchain-autoconfs eclass
+guile_slot_info() {
+	rm -f dir || die
+
+	pushd "${D}/${GUILE_INFODIR}" >/dev/null || die
+	for f in *.info*; do
+		# Install convenience aliases for versioned Guile pages.
+		ln -s "$f" "${f/./-${SLOT}.}" || die
+	done
+	popd >/dev/null || die
+
+	docompress "${GUILE_INFODIR}"
+}
+
+src_install() {
+	default
+
+	# From Novell https://bugzilla.novell.com/show_bug.cgi?id=874028#c0
+	dodir /usr/share/gdb/auto-load/$(get_libdir)
+	mv "${ED}"/usr/$(get_libdir)/libguile-*-gdb.scm "${ED}"/usr/share/gdb/auto-load/$(get_libdir) || die
+
+	mv "${ED}"/usr/share/aclocal/guile{,-"${SLOT}"}.m4 || die
+	find "${ED}" -name '*.la' -delete || die
+
+	guile_slot_info
+
+	local major="$(ver_cut 1 "${SLOT}")"
+	local minor="$(ver_cut 2 "${SLOT}")"
+	local idx="$((99999-(major*1000+minor)))"
+	newenvd - "50guile${idx}" <<-EOF
+	PKG_CONFIG_PATH="${GUILE_PCDIR}"
+	INFOPATH="${GUILE_INFODIR}"
+	EOF
+}