From a61bd35edda5b84c8810061fcd75f3049f7caa17 Mon Sep 17 00:00:00 2001
From: Francois-Rene Rideau <fare@tunes.org>
Date: Mon, 6 Mar 2017 23:35:46 -0500
Subject: [PATCH] Stop having asdf.asd depend on uiop.asd

A DEFINE-OP "asdf" shouldn't depend on a DEFINE-OP "uiop", or
a circular dependency may be introduced by the "always load asdf first"
behavior. Instead, have asdf/driver do a low-level copy of the components
in uiop, rather than a transclusion of a system defined in a separate file.
---
 asdf.asd                     | 10 ++++++++--
 test/test-sysdef-asdf.script |  9 +++++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/asdf.asd b/asdf.asd
index 3f1249e0f..eca684e91 100644
--- a/asdf.asd
+++ b/asdf.asd
@@ -21,7 +21,13 @@
 
 #+asdf3
 (defsystem "asdf/driver"
-  :depends-on ("uiop"))
+  ;; This is the same as "uiop", but used for transclusion in asdf.lisp.
+  ;; Because asdf.asd can't afford to depend on reading uiop.asd
+  ;; (which would cause circularity, since everything depends on reading asdf.asd),
+  ;; we can't "just" :depends-on ("uiop") like we used to do.
+  :pathname "uiop"
+  :around-compile call-without-redefinition-warnings ;; we need be the same as uiop
+  :components #.(getf (read-file-form (subpathname *load-pathname* "uiop/uiop.asd") :at 2) :components))
 
 #+asdf3
 (defsystem "asdf/defsystem"
@@ -40,7 +46,7 @@
   :build-operation monolithic-concatenate-source-op
   :build-pathname "build/asdf" ;; our target
   :around-compile call-without-redefinition-warnings ;; we need be the same as uiop
-  :depends-on ("asdf/prelude" "uiop")
+  :depends-on ("asdf/prelude" "asdf/driver")
   :encoding :utf-8
   :components
   ((:file "upgrade")
diff --git a/test/test-sysdef-asdf.script b/test/test-sysdef-asdf.script
index 54639a4f5..d83417694 100644
--- a/test/test-sysdef-asdf.script
+++ b/test/test-sysdef-asdf.script
@@ -12,7 +12,8 @@
   (def-test-system "fooey")
   (def-test-system "foo")
   (defmethod input-files :after ((o load-op) (c system))
-    (tick))
+    (DBG :input-files-after-1 o c
+         (tick)))
   (assert-equal *ticks* 0)
   (input-files 'load-op "foo")
   (assert-equal *ticks* 1)
@@ -108,10 +109,10 @@
 (def-test-system "fooey")
 (setf *ticks* 10)
 (defmethod input-files :after ((o load-op) (c system))
-  (DBG :input-files o c)
-  (incf *ticks*))
+  (DBG :input-files-after-2 o c
+       (tick)))
 (input-files 'load-op "uiop")
-(assert-equal *ticks* 11)
+(assert-equal *ticks* 12)
 (with-expected-failure (#+xcl t)
   ;; expected-failure: XCL has trouble with the ASDF upgrade
   (load-system :asdf))
-- 
GitLab