boot10.lisp 2.57 KB
Newer Older
pw's avatar
pw committed
1 2 3 4 5 6 7 8 9 10 11
;; bootstrap changes in the way FASL-FILE-VERSION is checked
;;
;; Given that FASL files are incompatible between releases, the
;; FASL-FILE-NUMBER was set to #x18d on all platforms, so that users
;; loading old compiled lisp files into their core will see a useful
;; error message, rather than unexplained lossage.
;;
;; This check is made when loading a FASL file into core, in the
;; function FOP-CODE-FORMAT. We work around the check so that it is
;; possible to build from 18c, without requiring a cross-compile.
;;
12 13 14 15
;; Additionally, the FASL file format was changed slightly: We use the new
;; FOP-LONG-CODE-FORMAT with code 157, because the version number is now
;; an uint32 instead of a single octet.  The old FOP-CODE-FORMAT with code
;; 57 is retained, in order to correctly read/detect old version numbers.
pw's avatar
pw committed
16 17 18

(in-package :cl)

19 20 21
;; Declare new variable defined in code/load.lisp, so that new-genesis
;; can reference it, before code/load is loaded.
(defvar *skip-fasl-file-version-check* nil)
pw's avatar
pw committed
22

23 24
;; Define nop FOP for the new FOP code of FOP-CODE-FORMAT
(define-fop (fop-long-code-format 157 :nope)
pw's avatar
pw committed
25 26 27
  (let ((implementation (read-arg 1))
	(version (read-arg 4)))
    (declare (ignore implementation version))
28
    (warn "FOP-LONG-CODE-FORMAT ignoring FASL file versions during rebuild")))
pw's avatar
pw committed
29 30 31

(in-package :c)

32
;; this is a DEFCONSTANT, so can't use SETQ
pw's avatar
pw committed
33 34
(setf (symbol-value 'byte-fasl-file-version) #x18d)

35 36 37 38
(setf (backend-fasl-file-version *target-backend*) #x18d)

;; Use the new format for newly created FASLs

pw's avatar
pw committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
(defun open-fasl-file (name where &optional byte-p)
  (declare (type pathname name))
  (let* ((stream (open name :direction :output
		       :if-exists :new-version
		       :element-type '(unsigned-byte 8)))
	 (res (make-fasl-file :stream stream)))
    (multiple-value-bind
	(version f-vers f-imp)
	(if byte-p
	    (values "Byte code"
		    byte-fasl-file-version
		    (backend-byte-fasl-file-implementation *backend*))
	    (values (backend-version *backend*)
		    (backend-fasl-file-version *backend*)
		    (backend-fasl-file-implementation *backend*)))
      (format stream
	      "FASL FILE output from ~A.~@
	       Compiled ~A on ~A~@
	       Compiler ~A, Lisp ~A~@
58
	       Targeted for ~A, FASL version ~X~%"
pw's avatar
pw committed
59 60 61 62 63 64 65 66 67
	      where
	      (ext:format-universal-time nil (get-universal-time))
	      (machine-instance) compiler-version
	      (lisp-implementation-version)
	      version f-vers)
      ;;
      ;; Terminate header.
      (dump-byte 255 res)
      ;;
68 69
      ;; Specify code format.
      (dump-fop 'lisp::fop-long-code-format res)
pw's avatar
pw committed
70 71 72
      (dump-byte f-imp res)
      (dump-unsigned-32 f-vers res))
    res))