First load runtime/host-adapter when building a cross-compiler.
authorMatt Birkholz <matt@birchwood-abbey.net>
Fri, 3 Mar 2017 00:49:37 +0000 (17:49 -0700)
committerMatt Birkholz <matt@birchwood-abbey.net>
Fri, 3 Mar 2017 00:49:37 +0000 (17:49 -0700)
src/Makefile.tools.in
src/compiler/base/utils.scm
src/cref/make.scm
src/runtime/host-adapter.scm [new file with mode: 0644]

index 8e4a3a93a3b0a21024e6aa5fb71962db360dd9a3..565df737293016e487437681f446a117a9e31841 100644 (file)
@@ -124,6 +124,8 @@ tools/compiler.com: cross-cref
 tools/compiler.com: cross-sf
 tools/compiler.com: kludgerous-star-parser
        (echo '(begin' && \
+        echo '  (with-working-directory-pathname "runtime"' && \
+        echo '    (lambda () (load "host-adapter")))' && \
         echo '  (with-working-directory-pathname "cref"' && \
         echo '    (lambda () (load "make")))' && \
         echo '  (with-working-directory-pathname "sf"' && \
@@ -139,6 +141,8 @@ tools/syntaxer.com: cross-cref
 tools/syntaxer.com: cross-sf
 tools/syntaxer.com: kludgerous-star-parser
        (echo '(begin' && \
+        echo '  (with-working-directory-pathname "runtime"' && \
+        echo '    (lambda () (load "host-adapter")))' && \
         echo '  (with-working-directory-pathname "cref"' && \
         echo '    (lambda () (load "make")))' && \
         echo '  (with-working-directory-pathname "sf"' && \
index 1f0813b61d575ad5f02f2f1be6032b8c0b09e2e3..f5e0a36cdaa6cb769d2dbd053d0532fd9b32575c 100644 (file)
@@ -31,13 +31,6 @@ USA.
 \f
 ;;;; Miscellaneous
 
-;; Temporary definition, for 9.2 hosts.
-(define (random-bytevector n #!optional state)
-  (let ((env (->environment '(runtime random-number))))
-    ((if (environment-bound? env 'random-byte-vector)
-        (access random-byte-vector env)
-        (access random-bytevector env)) n state)))
-
 (define (three-way-sort = set set* receiver)
   (let ((member? (member-procedure =)))
     (define (loop set set* receiver)
index e4ff7566520f07630c172b8044b4bc380d84b221..797c64e88f2eecf58d8273d134d99e621f914563 100644 (file)
@@ -32,54 +32,4 @@ USA.
   (lambda ()
     (load-package-set "cref")))
 
-;;; Patch the package loader in 9.2 host runtimes.
-(if (string-prefix? "9.2" (get-subsystem-version-string "Release"))
-    (eval
-     '(begin
-       (define (link-description? object)
-         (and (vector? object)
-              (cond ((fix:= (vector-length object) 2)
-                     (and (symbol? (vector-ref object 0))
-                          (package-name? (vector-ref object 1))))
-                    ((fix:= (vector-length object) 3)
-                     (and (symbol? (vector-ref object 0))
-                          (package-name? (vector-ref object 1))
-                          (symbol? (vector-ref object 2))))
-                    ((fix:= (vector-length object) 4)
-                     (and (symbol? (vector-ref object 0))
-                          (package-name? (vector-ref object 1))
-                          (symbol? (vector-ref object 2))
-                          (or (eq? #f (vector-ref object 3))
-                              (eq? 'deprecated (vector-ref object 3)))))
-                    (else #f))))
-       (define (create-links-from-description description)
-         (let ((environment
-                (find-package-environment (package-description/name description))))
-           (let ((bindings (package-description/exports description)))
-             (let ((n (vector-length bindings)))
-               (do ((i 0 (fix:+ i 1)))
-                   ((fix:= i n))
-                 (let ((binding (vector-ref bindings i)))
-                   (link-variables (find-package-environment (vector-ref binding 1))
-                                   (if (fix:= (vector-length binding) 3)
-                                       (vector-ref binding 2)
-                                       (vector-ref binding 0))
-                                   environment
-                                   (vector-ref binding 0))))))
-           (let ((bindings (package-description/imports description)))
-             (let ((n (vector-length bindings)))
-               (do ((i 0 (fix:+ i 1)))
-                   ((fix:= i n))
-                 (let ((binding (vector-ref bindings i)))
-                   (let ((source-environment
-                          (find-package-environment (vector-ref binding 1)))
-                         (source-name
-                          (if (fix:>= (vector-length binding) 3)
-                              (vector-ref binding 2)
-                              (vector-ref binding 0))))
-                     (guarantee-binding source-environment source-name)
-                     (link-variables environment (vector-ref binding 0)
-                                     source-environment source-name)))))))))
-     (->environment '(package))))
-
 (add-subsystem-identification! "CREF" '(2 4))
\ No newline at end of file
diff --git a/src/runtime/host-adapter.scm b/src/runtime/host-adapter.scm
new file mode 100644 (file)
index 0000000..c2f4d56
--- /dev/null
@@ -0,0 +1,100 @@
+#| -*-Scheme-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+    2017 Massachusetts Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+|#
+
+;;;; Adapt host system.
+;;; package: ()
+
+(declare (usual-integrations))
+\f
+;;; This is loaded by the cross-syntaxer and cross-compiler to hack
+;;; the host runtime.
+
+(let ((env (->environment '())))
+
+  (if (not (environment-bound? env 'random-bytevector))
+      (eval '
+(define random-bytevector random-byte-vector)
+       env))
+
+  (if (not (environment-bound? env 'guarantee))
+      (eval '
+(define (guarantee predicate object #!optional caller)
+  (if (not (predicate object))
+      (error "Not a:" predicate object)))
+       env)))
+
+(let ((env (->environment '(package))))
+
+  (if (not ((access link-description? env) #(???)))
+      (begin
+       (eval '
+(define (link-description? object)
+  (and (vector? object)
+       (cond ((fix:= (vector-length object) 2)
+             (and (symbol? (vector-ref object 0))
+                  (package-name? (vector-ref object 1))))
+            ((fix:= (vector-length object) 3)
+             (and (symbol? (vector-ref object 0))
+                  (package-name? (vector-ref object 1))
+                  (symbol? (vector-ref object 2))))
+            ((fix:= (vector-length object) 4)
+             (and (symbol? (vector-ref object 0))
+                  (package-name? (vector-ref object 1))
+                  (symbol? (vector-ref object 2))
+                  (or (eq? #f (vector-ref object 3))
+                      (eq? 'deprecated (vector-ref object 3)))))
+            (else #f))))
+        env)
+       (eval '
+(define (create-links-from-description description)
+  (let ((environment
+        (find-package-environment (package-description/name description))))
+    (let ((bindings (package-description/exports description)))
+      (let ((n (vector-length bindings)))
+       (do ((i 0 (fix:+ i 1)))
+           ((fix:= i n))
+         (let ((binding (vector-ref bindings i)))
+           (link-variables (find-package-environment (vector-ref binding 1))
+                           (if (fix:= (vector-length binding) 3)
+                               (vector-ref binding 2)
+                               (vector-ref binding 0))
+                           environment
+                           (vector-ref binding 0))))))
+    (let ((bindings (package-description/imports description)))
+      (let ((n (vector-length bindings)))
+       (do ((i 0 (fix:+ i 1)))
+           ((fix:= i n))
+         (let ((binding (vector-ref bindings i)))
+           (let ((source-environment
+                  (find-package-environment (vector-ref binding 1)))
+                 (source-name
+                  (if (fix:>= (vector-length binding) 3)
+                      (vector-ref binding 2)
+                      (vector-ref binding 0))))
+             (guarantee-binding source-environment source-name)
+             (link-variables environment (vector-ref binding 0)
+                             source-environment source-name))))))))
+        env))))
\ No newline at end of file