0.pre8.108:
authorWilliam Harold Newman <william.newman@airmail.net>
Sat, 26 Apr 2003 14:19:52 +0000 (14:19 +0000)
committerWilliam Harold Newman <william.newman@airmail.net>
Sat, 26 Apr 2003 14:19:52 +0000 (14:19 +0000)
Check *FEATURES* compatibility in fasl load.

base-target-features.lisp-expr
src/code/early-fasl.lisp
src/code/load.lisp
src/compiler/dump.lisp
version.lisp-expr

index c6e3c90..207a04f 100644 (file)
  ;; As of SBCL 0.8,  this is only supposed to work in x86 Linux, on which
  ;; system it's implemented using clone(2) and the %fs segment register.
  ;; Note that no consistent effort to audit the SBCL library code for
- ;; thread safety has been performed, so caveat executor
+ ;; thread safety has been performed, so caveat executor.
  ; :sb-thread
  
  ;; This affects the definition of a lot of things in bignum.lisp. It
  ;; in the *FEATURES* list
  ;;
 
+ ;; Any target feature which affects binary compatibility of fasl files
+ ;; needs to be recorded in *FEATURES-POTENTIALLY-AFFECTING-FASL-FORMAT*
+ ;; (elsewhere).
+
  ;; notes on the :NIL and :IGNORE features:
  ;;
  ;; #+NIL is used to comment out forms. Occasionally #+IGNORE is used
index 06c77da..30bcfd0 100644 (file)
 ;;;   against.
 (defparameter *fasl-header-string-start-string* "# FASL")
 
+(macrolet ((define-fasl-format-features ()
+             (let (;; master value for *F-P-A-F-F*
+                  (fpaff '(:sb-thread)))
+              `(progn
+                 ;; a list of *(SHEBANG-)FEATURES* flags which affect
+                 ;; binary compatibility, i.e. which must be the same
+                 ;; between the SBCL which compiles the code and the
+                 ;; SBCL which executes the code
+                 ;;
+                 ;; This is a property of SBCL executables in the
+                 ;; abstract, not of this particular SBCL executable, 
+                 ;; so any flag in this list may or may not be present
+                 ;; in the *FEATURES* list of this particular build.
+                 (defparameter *features-potentially-affecting-fasl-format*
+                   ',fpaff)
+                 ;; a string representing flags of *F-P-A-F-F* which
+                 ;; are in this particular build
+                 ;;
+                 ;; (A list is the natural logical representation for
+                 ;; this, but we represent it as a string because
+                 ;; that's physically convenient for writing to and
+                 ;; reading from fasl files, and because we don't
+                 ;; need to do anything sophisticated with its
+                 ;; logical structure, just test it for equality.)
+                 (defparameter *features-affecting-fasl-format*
+                   ,(let ((*print-pretty* nil))
+                      (prin1-to-string
+                       (sort
+                        (copy-seq
+                         (intersection sb-cold:*shebang-features* fpaff))
+                        #'string<
+                        :key #'symbol-name))))))))
+  (define-fasl-format-features))
+          
 ;;; the code for a character which terminates a fasl file header
 (def!constant +fasl-header-string-stop-char-code+ 255)
 
 ;;; This value should be incremented when the system changes in such a
 ;;; way that it will no longer work reliably with old fasl files. In
-;;; practice, I (WHN) fairly often forget to increment it for CVS
+;;; practice, I (WHN) have often forgotten to increment it for CVS
 ;;; versions which break binary compatibility. But it certainly should
 ;;; be incremented for release versions which break binary
 ;;; compatibility.
-(def!constant +fasl-file-version+ 40)
-;;; (record of versions before 0.7.0 deleted in 0.7.1.41)
-;;; 23 = sbcl-0.7.0.1 deleted no-longer-used EVAL-STACK stuff,
-;;;      causing changes in *STATIC-SYMBOLS*.
-;;; 24 = sbcl-0.7.1.19 changed PCL service routines which might be
-;;;      called from macroexpanded code
-;;; 25 = sbcl-0.7.1.41 (and immediately preceding versions, actually)
-;;;      introduced new functions to check for control stack exhaustion
-;;; 26 = sbcl-0.7.2.4 or so added :VARIABLE :MACRO-EXPANSION to INFO codes
-;;; 27: (2002-04-08) added MIGHT-CONTAIN-OTHER-TYPES? slot to CTYPE
-;;; 28: (2002-05-08) new convention for foreign symbols to support
-;;;     dynamic loading in OpenBSD
-;;; 29: (2002-06-24) removed *!INITIAL-FDEFN-OBJECTS* from static symbols
-;;; 30: (2002-07-26) deleted all references to %DETECT-STACK-EXHAUSTION, 
-;;;     which was introduced in version 25, since now control stack
-;;;     is checked using mmap() page protection
-;;; 31: (2002-08-14) changed encoding of PCL internal MAKE-INSTANCE
-;;;     function names so they're insensitive to whether the class name
-;;;     is currently external to its package
-;;; 32: (2002-09-21) changes in implementation of sequence functions,
-;;;     causing old utility functions like COERCE-TO-SIMPLE-VECTOR to go away
-;;; 33: (2002-10-02) (again) changes in implementation of sequence functions,
-;;;     causing old utility functions like COERCE-TO-SIMPLE-VECTOR to go away
-;;; 34: (2002-10-05) changed implementation of DEFMACRO, so %%DEFMACRO
-;;;      was deleted
-;;; 35: (2002-11-27) (incremented version before 0.7.10 release,
-;;;     reflecting changes from a week or more ago) changed layout of
-;;;     CLOS objects to support SXHASH returning values other than 42
-;;;     for STANDARD-OBJECT
-;;; 36: (2002-12-04) DEFSTRUCT-DESCRIPTION layout changed to accommodate
-;;;     correct behaviour of colliding accessors
-;;; 37: (2002-12-09) changed implementation of DEFINE-COMPILER-MACRO,
-;;;     deleting %%DEFINE-COMPILER-MACRO
+(def!constant +fasl-file-version+ 41)
+;;; (record of versions before 2003 deleted in 2003-04-26/0.pre8.107 or so)
 ;;; 38: (2003-01-05) changed names of internal SORT machinery
 ;;; 39: (2003-02-20) in 0.7.12.1 a slot was added to
 ;;;     DEFSTRUCT-SLOT-DESCRIPTION
 ;;; 40: (2003-03-11) changed value of (SXHASH NIL)
+;;; 41: (2003-04-26) enforced binary incompatibility between +SB-THREAD
+;;;     and -SB-THREAD builds
 
 ;;; the conventional file extension for our fasl files
 (declaim (type simple-string *fasl-file-type*))
index f7f7ca9..48c3ccb 100644 (file)
                       stream
                       implementation
                       +backend-fasl-file-implementation+))))
-       ;; TO DO: Check for *FEATURES* which affect binary compatibility.
-       ;; (And don't forget to return T.:-)
-       ))))
+       ;; Read and validate *FEATURES* which affect binary compatibility.
+       (let ((faff-in-this-file (string-from-stream)))
+         (unless (string= faff-in-this-file *features-affecting-fasl-format*)
+           (error
+            "~@<incompatible ~S in fasl file ~S: ~2I~_~
+              Of features affecting binary compatibility, ~4I~_~S~2I~_~
+              this runtime has ~4I~_~A,~2I~_~
+              while the fasl expects ~4I~_~A.~:>"
+            '*features* 
+            stream
+            *features-potentially-affecting-fasl-format*
+            *features-affecting-fasl-format*
+            faff-in-this-file)))
+       ;; success
+       t))))
 
 ;; Setting this variable gives you a trace of fops as they are loaded and
 ;; executed.
index 4ca7e8f..7c4619f 100644 (file)
      stream)
     (dump-byte +fasl-header-string-stop-char-code+ res)
 
-    ;; Finish the header by outputting fasl file implementation and
-    ;; version in machine-readable form.
-    (let ((implementation +backend-fasl-file-implementation+))
-      (dump-unsigned-32 (length (symbol-name implementation)) res)
-      (dotimes (i (length (symbol-name implementation)))
-       (dump-byte (char-code (aref (symbol-name implementation) i)) res)))
-    (dump-unsigned-32 +fasl-file-version+ res)
+    ;; Finish the header by outputting fasl file implementation,
+    ;; version, and key *FEATURES*.
+    (flet ((dump-counted-string (string)
+            (dump-unsigned-32 (length string) res)
+            (dotimes (i (length string))
+              (dump-byte (char-code (aref string i)) res))))
+      (dump-counted-string (symbol-name +backend-fasl-file-implementation+))
+      (dump-unsigned-32 +fasl-file-version+ res)      
+      (dump-counted-string *features-affecting-fasl-format*))
 
     res))
 
index ac7cf1a..83b252a 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.pre8.107"
+"0.pre8.108"