From 1bdc85ab9dfbd9f2fafda57e51aafcedbf71c005 Mon Sep 17 00:00:00 2001 From: Charles Zhang Date: Tue, 31 May 2022 17:50:24 -0700 Subject: [PATCH] Work around remaining RENAME-PACKAGE issue for tll smashing. Simply force compilation of queued lambdas when a DEFPACKAGE/MAKE-PACKAGE is seen at compile time, thereby avoiding issues with RENAME-PACKAGE. Set TOP-LEVEL-LAMBDA-MAX back to 20. This is for the case which I think is not conforming code, but nevertheless causes behavioral change. It's not worth trying to solve this to save a few bytes off of fasls in the case where we have random package hackery going on, something which doesn't apply to the majority of code. --- NEWS | 4 ++++ make-target-2.sh | 4 ---- src/code/target-package.lisp | 8 ++++++++ tests/block-compile.impure.lisp | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 65423f3b2..3cd79b300 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ ;;;; -*- coding: utf-8; fill-column: 78 -*- +changes relative to sbcl-2.2.5: + * optimization: fasl files are now usually smaller (up to 10% on default + policy) and may load faster, especially on high debug. + changes in sbcl-2.2.5 relative to sbcl-2.2.4: * minor incompatible change: SB-EXT:*DERIVE-FUNCTION-TYPES* being NIL now means that function calls will strictly only use type information from diff --git a/make-target-2.sh b/make-target-2.sh index d5e833dae..b37d85d0e 100755 --- a/make-target-2.sh +++ b/make-target-2.sh @@ -67,10 +67,6 @@ echo //doing warm init - load and dump phase (setf sb-c::*merge-pathnames* t) ;;; and for storing pathname namestrings in fasls too. (setq sb-c::*name-context-file-path-selector* 'truename) -;;; FIXME: Workaround for possible incorrect RENAME-PACKAGE behavior -;;; with top-level-lambda merging. Remove this when the tests -;;; :block-defpackage-rename-package etc works. -(setq sb-c::top-level-lambda-max 0) (let ((sb-ext:*invoke-debugger-hook* (prog1 sb-ext:*invoke-debugger-hook* (sb-ext:enable-debugger)))) (sb-ext:save-lisp-and-die "output/sbcl.core")) EOF diff --git a/src/code/target-package.lisp b/src/code/target-package.lisp index ddc05299e..c865f5e7a 100644 --- a/src/code/target-package.lisp +++ b/src/code/target-package.lisp @@ -1046,6 +1046,14 @@ implementation it is ~S." *!default-package-use-list*) "Clobber existing package." "A package named ~S already exists" name) (setf clobber t)) + ;; Force pending top-level lambdas at compile time, to prevent a + ;; potentially observable behavioral change with + ;; RENAME-PACKAGE. See test + ;; :BLOCK-DEFPACKAGE-RENAME-PACKAGE-REDEFPACKAGE which shows the + ;; failing scenario. Forcing top-level lambdas like this does not + ;; apply to block compilation. + (when (boundp 'sb-c::*compilation*) + (sb-c::compile-toplevel-lambdas '() t)) (with-package-graph () ;; Check for race, signal the error outside the lock. (when (and (not clobber) (find-package name)) diff --git a/tests/block-compile.impure.lisp b/tests/block-compile.impure.lisp index aea210ca1..d4b0819f6 100644 --- a/tests/block-compile.impure.lisp +++ b/tests/block-compile.impure.lisp @@ -82,7 +82,10 @@ (assert (eq (nth-value 1 (find-symbol "F" "BLOCK-DEFPACKAGE3")) :external))) -;;; Similar to the above test case, but with RENAME-PACKAGE. +;;; Similar to the above test case, but with RENAME-PACKAGE. This is +;;; probably, strictly speaking, non-conforming code according to ANSI +;;; 3.2.4.4 under item 1 for symbol, taking package "same"ness to mean +;;; EQness. We don't expect this to work under block compilation. (with-test (:name :block-defpackage-rename-package-redefpackage :fails-on :sbcl) (ctu:file-compile