changeset 651: |
af486e0a40c9 |
parent: |
7ce855f76e1d
|
child: |
295ea43ceb2d |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sat, 14 Sep 2024 22:13:06 -0400 |
permissions: |
-rw-r--r-- |
description: |
multi-binaries, working on removing x.lisp |
1 ;;; std/sys.lisp --- Lisp System Utilities 9 ;; (reexport-from :sb-introspect 10 ;; :include '(:function-lambda-list :lambda-list-keywords :lambda-parameters-limit 11 ;; :method-combination-lambda-list :deftype-lambda-list 12 ;; :primitive-object-size :allocation-information 14 ;; :who-specializes-directly :who-specializes-generally 15 ;; :find-function-callees :find-function-callers)) 18 ;; sb-sys:*linkage-info* *machine-version* *runtime-dlhandle* *periodic-polling-function* 19 ;; *periodic-polling-period* io-timeout nlx-protect serve-event os-deinit os-exit with-deadline dlopen-or-lose deallocate-system-memory 21 (defun current-lisp-implementation () 22 "Return the current lisp implemenation as a list: (TYPE VERSION FEATURES)" 24 (lisp-implementation-type) 25 (lisp-implementation-version) 28 (defun current-machine () 29 "Return the current machine spec as a list: (HOST TYPE VERSION)" 35 (defun list-package-symbols (&optional (pkg *package*)) 36 (loop for s being the external-symbol of pkg 39 (defun package-symbols (&optional (package *package*) test) 41 (do-external-symbols (symbol package) 43 (when (funcall test symbol) 44 (push symbol symbols)) 45 (push symbol symbols))) 48 (defun package-symbol-names (&optional (package *package*) test) 49 (sort (mapcar (lambda (x) (string-downcase (symbol-name x))) 50 (package-symbols package test)) 53 (defun standard-symbol-names (test) 54 (package-symbol-names :common-lisp test)) 56 (defun append-logical-hosts (&rest hosts) 57 "Reinitialize SB-IMPL::*LOGICAL-HOSTS* with a freshly allocated vector 58 consisting of the old contents appended to the new." 60 (concatenate 'vector hosts *logical-hosts*))) 63 (defun save-lisp-tree-shake-and-die (path &rest args) 64 "A naive tree-shaker for lisp." 66 (apply #'sb-ext:save-lisp-and-die path args)) 68 (defun save-lisp-and-live (filename completion-function restart &rest args) 69 (flet ((restart-sbcl () 70 (sb-debug::enable-debugger) 71 (setf sb-impl::*descriptor-handlers* nil) 73 ;; fork it - assumes only one thread is running 74 (multiple-value-bind (pipe-in pipe-out) (sb-posix:pipe) 75 (let ((pid (sb-posix:fork))) 76 (cond ((= pid 0) ;; make simple-restart core 77 (sb-posix:close pipe-in) 78 (sb-debug::disable-debugger) 79 (apply #'sb-ext:save-lisp-and-die filename 81 (list :toplevel #'restart-sbcl) 84 (sb-posix:close pipe-out) 85 (sb-sys:add-fd-handler 88 (sb-sys:invalidate-descriptor fd) 90 (multiple-value-bind (rpid status) (sb-posix:waitpid pid 0) ;; wait for master 92 (assert (sb-posix:wifexited status)) 93 (funcall completion-function 94 (zerop (sb-posix:wexitstatus status)))))))))))) 96 (defparameter *gc-logfile* #P"gc.log") 98 (defun enable-gc-logfile (&optional (file *gc-logfile*)) 99 (setf (sb-ext:gc-logfile) file)) 101 (defun forget-shared-object (name) 102 (setf (sb-alien::shared-object-dont-save 103 (find name sb-sys:*shared-objects* 104 :key 'sb-alien::shared-object-namestring 105 :test 'string-equal)) 108 (defun forget-shared-objects (&optional (objects sb-sys:*shared-objects*)) 109 "Set the DONT-SAVE slot of all objects in SB-SYS:*SHARED-OBJECTS* to T." 110 (mapcar (lambda (obj) (setf (sb-alien::shared-object-dont-save obj) t)) objects)) 112 (defun compile-lisp (name &key force save make package compression verbose version callable-exports executable (toplevel #'sb-impl::toplevel-init) forget save-runtime-options root-structures (purify t)) 113 (pkg:with-package (or package *package*) 114 (asdf:compile-system name :force force :verbose verbose :version version) 116 (apply 'asdf:make name (unless (eq t make) make))) 118 (forget-shared-objects (unless (eq t forget) forget))) 120 (when (probe-file save) 122 (sb-ext:save-lisp-and-die save :executable executable 124 :callable-exports callable-exports 125 :save-runtime-options save-runtime-options 126 :root-structures root-structures 128 :compression compression))))