dump-ecl: Defeat ASDF's magic internal knowledge of itself.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 27 May 2021 00:14:17 +0000 (01:14 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 3 Jun 2021 02:45:23 +0000 (03:45 +0100)
When you load ASDF, it comes with built-in knowledge of itself as a
system, but without details of any source files (or, indeed, any
information about how to do anything with it).  When you try to find the
`asdf' system, it does check the filesystem, but does a quick check of
the reported version number against its current version number and skips
loading the full system definition if it's already up-to-date.

This would all be fine in a resident system, because once the system is
loaded, we don't really care much.  But ECL isn't a resident system: it
compiles to external files, and this poses a problem.  If the initially
loaded ASDF matches the one in the system registry, then we don't have
any source filename details, and `lib-op' does nothing.

Defeat this by locating and loading the system-definition by hand and
stuffing it into ASDF's internal structures before we try to do stuff.

This is, of course, completely terrible.

dump-ecl

index 4ec27b4..e777e50 100755 (executable)
--- a/dump-ecl
+++ b/dump-ecl
@@ -33,6 +33,30 @@ run () { echo "$*"; "$@"; }
 cat >"$tmp/ecl-build.lisp" <<'EOF'
 (require "asdf")
 
+;; Defeat ASDF's built-in knowledge of itself.  If we've just loaded the most
+;; up-to-date version of ASDF then it won't bother loading the system
+;; definition from disk which knows about the actual source files.  And if it
+;; doesn't think it has any source files then it won't compile anything.
+(asdf:load-asd
+ (funcall (let* ((cache-pkg (find-package "ASDF/CACHE"))
+                              (with-cache (and cache-pkg
+                                               ))
+                              (session-pkg (find-package "ASDF/SESSION"))
+                              (with-session (and session-pkg
+                                                 (find-symbol
+                                                  "CALL-WITH-ASDF-SESSION"))))
+           (symbol-function
+            (cond (cache-pkg
+                   (find-symbol "CALL-WITH-ASDF-CACHE" cache-pkg))
+                  (session-pkg
+                   (find-symbol "CALL-WITH-ASDF-SESSION" session-pkg))
+                  (t
+                   (error "I don't know how to hack this version of ASDF: ~
+                           please report this as a bug.")))))
+         (lambda ()
+           (asdf:search-for-system-definition "asdf")))
+ :name "asdf")
+
 (defparameter *asdf* (asdf:find-system "asdf")
   "The `asdf' system itself.")