<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">What I would recommend is to set up a fake component type for the host system, and then the system definition will automatically detect a change.</p>
<p dir="auto">The difficulty would be having the host system version be recorded in the filesystem so that ASDF can see it.</p>
<p dir="auto">I'd suggest you have an operation that reads a file with a version number in it, and updates that file if the SBCL version number has increased. Then if ASDF sees that the file's date is new, it will know that SBCL has been updated and rebuild everything.</p>
<p dir="auto">But... that requires comparing dates on input and output files, so you might need a <em>pair</em> of such files that you rotate -- you read the input file, and then write an output file, and ASDF will compare the dates on the two and decide whether it needs to update.</p>
<p dir="auto">That should be enough to get you started.</p>
<p dir="auto">On 17 Nov 2020, at 11:47, Pierre Neidhardt wrote:</p>
</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">Ha, that's a good starting point indeed!<br>
<br>
So I made the following system:<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
(defsystem "ambrevar/dump"<br>
:class :package-inferred-system<br>
:depends-on #.(append<br>
'(ambrevar/all asdf)<br>
#+sbcl<br>
'(sb-bsd-sockets sb-posix sb-introspect sb-cltl2))<br>
:build-operation image-op<br>
:build-pathname<br>
#+sbcl "sbcl.core-for-sly"<br>
#+ccl "ccl.core-for-sly")<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
<br>
And I'm building it with:<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
sbcl --no-userinit --eval '(require :asdf)' --eval '(asdf:make :ambrevar/dump)' --eval '(quit)'<br>
<br>
## And to test portability...<br>
ccl --no-init --eval '(require :asdf)' --eval '(asdf:make :ambrevar/dump)' --eval '(quit)'<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
What's missing is a way to rebuild the image when the compiler changes<br>
(e.g. SBCL gets updated).<br>
<br>
One way would be to load the core, return the<br>
(lisp-implementation-version), compare against the current compiler<br>
(lisp-implementation-version). But that's too much code.<br>
<br>
Alternatively, I can just try to start the implementation with the given<br>
core. If the version is wrong, it will fail. This is less code, but<br>
still (untested):<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
(defun ambrevar/dump-lisp-core (implementation core-flag extra-flags)<br>
(cl-flet ((find-core ()<br>
(first (directory-files ambrevar/lisp-core-root nil (format "%s.*" implementation)))))<br>
(let ((core (find-core)))<br>
(when (or (not core)<br>
;; Not right version<br>
(/= 0 (call-process implementation nil nil nil<br>
core-flag core<br>
extra-flags<br>
"--eval" "(quit)")))<br>
(let ((lisp-output-buffer (get-buffer-create " *Lisp dump log*")))<br>
(with-current-buffer lisp-output-buffer (erase-buffer))<br>
(apply #'call-process<br>
implementation nil (list lisp-output-buffer t) nil<br>
"--eval" "(require :asdf)"<br>
"--eval" "(asdf:make :ambrevar/dump)"<br>
"--eval" "(quit)"))))<br>
(or core (find-core))))<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
Would there be a way to tell ASDF "dump image only if version differs"?<br>
<br>
I'm not sure this is doable with ASDF, because this means starting an<br>
implementation and loading ASDF, which is already too slow.<br>
<br>
So we need a way to tell that the image is out of date in a fraction of<br>
a second (<50ms I'd say), i.e. without loading ASDF.<br>
<br>
Maybe create a new (contrib?) system that loads in an instant with just<br>
one function, one that checks if a core is valid or not.<br>
<br>
Thoughts?<br>
<br>
--<br>
Pierre Neidhardt<br>
<a href="https://ambrevar.xyz/" style="color:#777">https://ambrevar.xyz/</a></p>
</blockquote></div>
<div style="white-space:normal">
</div>
</div>
</body>
</html>