;;; Guile Emacs Lisp
-;; Copyright (C) 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011, 2013, 2018 Free Software Foundation, Inc.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
#:use-module (language tree-il)
#:use-module (system base pmatch)
#:use-module (system base compile)
+ #:use-module (system base target)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-8)
#:use-module (srfi srfi-11)
(map compile-expr args))))
(defspecial eval-when-compile (loc args)
- (make-const loc (compile `(progn ,@args) #:from 'elisp #:to 'value)))
+ (make-const loc (with-native-target
+ (lambda ()
+ (compile `(progn ,@args) #:from 'elisp #:to 'value)))))
(defspecial if (loc args)
(pmatch args
args
body))))
(make-const loc name))))
- (compile tree-il #:from 'tree-il #:to 'value)
+ (with-native-target
+ (lambda ()
+ (compile tree-il #:from 'tree-il #:to 'value)))
tree-il)))))
(defspecial defun (loc args)
;;; Guile Emac Lisp
-;; Copyright (C) 2001, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2009, 2010, 2018 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
#:use-module (language elisp parser)
#:use-module (system base language)
#:use-module (system base compile)
+ #:use-module (system base target)
#:export (elisp))
(define-language elisp
#:printer write
#:compilers `((tree-il . ,compile-tree-il)))
-(compile-and-load (%search-load-path "language/elisp/boot.el")
- #:from 'elisp)
+;; Compile and load the Elisp boot code for the native host
+;; architecture. We must specifically ask for native compilation here,
+;; because this module might be loaded in a dynamic environment where
+;; cross-compilation has been requested using 'with-target'. For
+;; example, this happens when cross-compiling Guile itself.
+(with-native-target
+ (lambda ()
+ (compile-and-load (%search-load-path "language/elisp/boot.el")
+ #:from 'elisp)))
;;; Compilation targets
-;; Copyright (C) 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2014, 2018 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
(define-module (system base target)
#:use-module (rnrs bytevectors)
#:use-module (ice-9 regex)
- #:export (target-type with-target
+ #:export (target-type with-target with-native-target
target-cpu target-vendor target-os
(%target-word-size (triplet-pointer-size target)))
(thunk))))
+(define (with-native-target thunk)
+ (with-fluids ((%target-type %host-type)
+ (%target-endianness (native-endianness))
+ (%target-word-size %native-word-size))
+ (thunk)))
+
(define (cpu-endianness cpu)
"Return the endianness for CPU."
(if (string=? cpu (triplet-cpu %host-type))