records: Make 'report-duplicate-field-specifier' available at expansion-time.

Fixes a regression in 'guix pack -R' introduced with commit
c2dcff41c2.  The imported modules of
'c-compiler' would be compiled in this order: first (guix records),
then (guix search-paths).  Consequently,
'report-duplicate-field-specifier' would be reported as unbound while
compiling (guix search-paths), leading to a build failure.

* guix/records.scm (report-invalid-field-specifier)
(report-duplicate-field-specifier): Move within 'eval-expand'.
This commit is contained in:
Ludovic Courtès 2019-01-24 20:48:14 +01:00
parent 2c5ee9bba4
commit bbb2bd50dc
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 27 additions and 27 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -44,6 +44,30 @@
(format #f fmt args ...) (format #f fmt args ...)
form)))) form))))
(eval-when (expand load eval)
;; The procedures below are needed both at run time and at expansion time.
(define (current-abi-identifier type)
"Return an identifier unhygienically derived from TYPE for use as its
\"current ABI\" variable."
(let ((type-name (syntax->datum type)))
(datum->syntax
type
(string->symbol
(string-append "% " (symbol->string type-name)
" abi-cookie")))))
(define (abi-check type cookie)
"Return syntax that checks that the current \"application binary
interface\" (ABI) for TYPE is equal to COOKIE."
(with-syntax ((current-abi (current-abi-identifier type)))
#`(unless (eq? current-abi #,cookie)
;; The source file where this exception is thrown must be
;; recompiled.
(throw 'record-abi-mismatch-error 'abi-check
"~a: record ABI mismatch; recompilation needed"
(list #,type) '()))))
(define (report-invalid-field-specifier name bindings) (define (report-invalid-field-specifier name bindings)
"Report the first invalid binding among BINDINGS." "Report the first invalid binding among BINDINGS."
(let loop ((bindings bindings)) (let loop ((bindings bindings))
@ -67,31 +91,7 @@
(syntax-violation name "duplicate field initializer" (syntax-violation name "duplicate field initializer"
#'duplicate)) #'duplicate))
(() (()
#t)))))) #t)))))))
(eval-when (expand load eval)
;; The procedures below are needed both at run time and at expansion time.
(define (current-abi-identifier type)
"Return an identifier unhygienically derived from TYPE for use as its
\"current ABI\" variable."
(let ((type-name (syntax->datum type)))
(datum->syntax
type
(string->symbol
(string-append "% " (symbol->string type-name)
" abi-cookie")))))
(define (abi-check type cookie)
"Return syntax that checks that the current \"application binary
interface\" (ABI) for TYPE is equal to COOKIE."
(with-syntax ((current-abi (current-abi-identifier type)))
#`(unless (eq? current-abi #,cookie)
;; The source file where this exception is thrown must be
;; recompiled.
(throw 'record-abi-mismatch-error 'abi-check
"~a: record ABI mismatch; recompilation needed"
(list #,type) '())))))
(define-syntax make-syntactic-constructor (define-syntax make-syntactic-constructor
(syntax-rules () (syntax-rules ()