1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Add a workaround for pre-3.0.10 incorrect inlinable exports

* module/language/tree-il/peval.scm (peval)
(inlinable-kwargs-bug-fixup): Before 3.0.10, the inlinable exports pass
was incorrectly serializing functions with keyword arguments.  This was
fixed in 2c645571b3, but that meant that
3.0.10 compiling against 3.0.9 binaries could raise an exception at
compile-time; whoops.  Add a workaround so that 3.0.9 binaries still
work.

Fixes https://issues.guix.gnu.org/72936.
This commit is contained in:
Andy Wingo 2024-09-23 14:07:53 +02:00
parent a970ed5bd5
commit 90e1205018

View file

@ -395,6 +395,21 @@ referenced multiple times."
;; FIXME: add more cases? ;; FIXME: add more cases?
(else #f))) (else #f)))
(define (inlinable-kwargs-bug-fixup exp)
;; Versions of Guile before 3.0.10 had a bug where they mis-serialized
;; functions with keyword arguments; work around that. See
;; https://issues.guix.gnu.org/72936.
(post-order
(match-lambda
(($ <lambda-case> src req opt rest (aok? (kw name #f) ...) inits syms body
alt)
(let ((kw-syms (reverse (list-head (reverse syms) (length kw)))))
(make-lambda-case src req opt rest
(cons aok? (map list kw name kw-syms))
inits syms body alt)))
(exp exp))
exp))
(define* (peval exp #:optional (cenv (current-module)) (env vlist-null) (define* (peval exp #:optional (cenv (current-module)) (env vlist-null)
#:key #:key
(operator-size-limit 40) (operator-size-limit 40)
@ -1110,8 +1125,9 @@ top-level bindings from ENV and return the resulting expression."
(lambda (module) (lambda (module)
(and=> (module-public-interface module) (and=> (module-public-interface module)
(lambda (iface) (lambda (iface)
(and=> (module-inlinable-exports iface) (and=> (and=> (module-inlinable-exports iface)
(lambda (proc) (proc name)))))))) (lambda (proc) (proc name)))
inlinable-kwargs-bug-fixup))))))
=> (lambda (inlined) => (lambda (inlined)
;; Similar logic to lexical-ref, but we can't enumerate ;; Similar logic to lexical-ref, but we can't enumerate
;; uses, and don't know about aliases. ;; uses, and don't know about aliases.