From 2dfe932d0a86eea307e1b51a9401e95d70b41736 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Mon, 16 May 2022 11:23:35 +0100 Subject: [PATCH] Make explicit which generated sources are build-dependent (For example because of different build-time options) --- make-genesis-2.lisp | 4 ++-- src/code/target-thread.lisp | 2 +- src/cold/compile-cold-sbcl.lisp | 2 +- src/cold/shared.lisp | 17 +++++++++++------ src/cold/slam.lisp | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/make-genesis-2.lisp b/make-genesis-2.lisp index 75b9f5202..2b68e997a 100644 --- a/make-genesis-2.lisp +++ b/make-genesis-2.lisp @@ -14,8 +14,8 @@ (push (stem-object-path stem flags :target-compile) list))) (nreverse list)) - :defstruct-descriptions (find-bootstrap-file "output/defstructs.lisp-expr") - :tls-init (read-from-file "output/tls-init.lisp-expr") + :defstruct-descriptions (find-bootstrap-file "output/defstructs.lisp-expr" t) + :tls-init (read-from-file "output/tls-init.lisp-expr" :build-dependent t) :c-header-dir-name "output/genesis-2" :symbol-table-file-name "src/runtime/sbcl.nm" :core-file-name "output/cold-sbcl.core" diff --git a/src/code/target-thread.lisp b/src/code/target-thread.lisp index bb1c8ac88..ef861bedf 100644 --- a/src/code/target-thread.lisp +++ b/src/code/target-thread.lisp @@ -2571,7 +2571,7 @@ mechanism for inter-thread communication." (eval-when (:compile-toplevel) ;; Inform genesis of the index <-> symbol mapping made by DEFINE-THREAD-LOCAL - (with-open-file (output (sb-cold:find-bootstrap-file "output/tls-init.lisp-expr") + (with-open-file (output (sb-cold:find-bootstrap-file "output/tls-init.lisp-expr" t) :direction :output :if-exists :supersede) (let ((list (mapcar (lambda (x &aux (symbol (car x))) (cons (info :variable :wired-tls symbol) symbol)) diff --git a/src/cold/compile-cold-sbcl.lisp b/src/cold/compile-cold-sbcl.lisp index 8f2345504..7ff723b49 100644 --- a/src/cold/compile-cold-sbcl.lisp +++ b/src/cold/compile-cold-sbcl.lisp @@ -224,4 +224,4 @@ (format t "~&~50t ~f~%" total-time)) (sb-c::dump/restore-interesting-types 'write))) (sb-kernel::write-structure-definitions-as-text - (sb-cold:find-bootstrap-file "output/defstructs.lisp-expr"))))) + (sb-cold:find-bootstrap-file "output/defstructs.lisp-expr" t))))) diff --git a/src/cold/shared.lisp b/src/cold/shared.lisp index 2866bd21b..4c1f919d4 100644 --- a/src/cold/shared.lisp +++ b/src/cold/shared.lisp @@ -169,13 +169,15 @@ (compile 'rename-file-a-la-unix) (export '(*target-sbcl-version* *generated-sources-root* + *build-dependent-generated-sources-root* stem-source-path find-bootstrap-file read-from-file)) (defvar *sources-root* "") (defvar *generated-sources-root* "") +(defvar *build-dependent-generated-sources-root* "") (defvar *src-cold-shared-pathname* *load-pathname*) ;;; See remark in COMPILE-STEM about strings vs. The Common Lisp Way -(defun find-bootstrap-file (namestring) +(defun find-bootstrap-file (namestring &optional build-dependent) (cond ((char= (char namestring 0) #\^) ;; If it starts with a "^" then it means "src/cold/..." (let ((this *src-cold-shared-pathname*) @@ -190,7 +192,9 @@ ;; in the tree as checked in, or generated by a prior build step. (concatenate 'string (if (eql (mismatch "output/" namestring) 7) ; a generated source - *generated-sources-root* + (if build-dependent + *build-dependent-generated-sources-root* + *generated-sources-root*) *sources-root*) namestring)) (t @@ -201,9 +205,10 @@ ;;; Return an expression read from the file named NAMESTRING. ;;; For user-supplied inputs, protect against more than one expression -;;; appearing in the file. For in-tree inputs we needn't bother. -(defun read-from-file (namestring &optional (enforce-single-expr t)) - (with-open-file (s (find-bootstrap-file namestring)) +;;; appearing in the file. (Our ^build-order.lisp-expr file has more than +;;; one expression in it, so we need to be able to not enforce.) +(defun read-from-file (namestring &key (enforce-single-expr t) build-dependent) + (with-open-file (s (find-bootstrap-file namestring build-dependent)) (let* ((result (read s)) (eof-result (cons nil nil))) (unless enforce-single-expr @@ -505,7 +510,7 @@ ;; to produce warnings as a bug workaround. (let ((cl:*features* (cons feature cl:*features*)) (*readtable* *xc-readtable*)) - (read-from-file "^build-order.lisp-expr" nil)))) + (read-from-file "^build-order.lisp-expr" :enforce-single-expr nil)))) (setf *stems-and-flags* (cons build-phase list))) ;; Now check for duplicate stems and bogus flags. (let ((stems (make-hash-table :test 'equal))) diff --git a/src/cold/slam.lisp b/src/cold/slam.lisp index d2df9e99f..c954d915f 100644 --- a/src/cold/slam.lisp +++ b/src/cold/slam.lisp @@ -46,7 +46,7 @@ ;;; :trace-file as a flag. (setf *stems-and-flags* (let ((*readtable* *xc-readtable*)) - (read-from-file "^build-order.lisp-expr" nil))) + (read-from-file "^build-order.lisp-expr" :enforce-single-expr nil))) ;;; Don't care about deftransforms that get redefined. ;;; The target condition is defined in 'condition' which is a :not-host file.