;;;; -*- Lisp -*-

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

;;; a linear ordering of system sources which works both to
;;; compile/load the cross-compiler under the host Common Lisp and
;;; then to cross-compile the complete system into the
;;; under-construction target SBCL
;;;
;;; The keyword flags (:NOT-HOST, :NOT-TARGET, :ASSEM...) are
;;; documented in the code which implements their effects. (As of
;;; sbcl-0.7.10, the comments are on DEFPARAMETER *EXPECTED-STEM-FLAGS*
;;; in src/cold/shared.lisp.)
;;;
;;; Of course, it'd be very nice to have this be a dependency DAG
;;; instead, so that we could do automated incremental recompilation.
;;; But the dependencies are varied and subtle, and it'd be extremely
;;; difficult to extract them automatically, and it'd be extremely
;;; tedious and error-prone to extract them manually, so we don't
;;; extract them. (It would be nice to fix this someday. The most
;;; feasible approach that I can think of would be to make the
;;; dependencies work on a package level, not an individual file
;;; level. Doing it at the package level would make the granularity
;;; coarse enough that it would probably be pretty easy to maintain
;;; the dependency information manually, and the brittleness of the
;;; package system would help make most violations of the declared
;;; dependencies obvious at build time. -- WHN 20000803

;;; make-host-n build steps
;;; All uses of #+ and #- reader macros within this file refer to
;;; the chosen target features, and not CL:*FEATURES*.
;;; If you must test a host feature, use "#.(cl:if ..)" syntax.
(
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; miscellaneous
 ;; This comes as early as possible, so that we catch the source locations
 ;; for everything.
 ("src/code/early-source-location" :c-headers)
 ("src/code/cross-early" :c-headers :not-target)

 ;; This comes early because it's useful for debugging everywhere.
 ("src/code/show" :c-headers)
 ("src/compiler/early-constantp" :c-headers)
 ("src/code/defsetfs" :not-host)

 ;; Declare all target special variables defined by ANSI
 ("src/code/cl-specials" :not-host)

 ;; Things like DX-FLET and AWHEN are available for use in both the
 ;; host and target very early.
 ("src/code/primordial-extensions" :c-headers)
 ("src/code/cold-init-helper-macros" :c-headers)
 ("src/code/early-defmethod" :not-host)

 ;; ASAP we replace the host's backquote reader with our own, to avoid leaking
 ;; details of the host into the target. This is not a concern in make-host-2
 ;; becase IN-TARGET-CROSS-COMPILATION-MODE assigns the reader macros before
 ;; compiling anything. It is, however, a minor concern for make-host-1, but
 ;; usually a problem can be exposed only by contrived code / poor style.
 ;; e.g. if the host's reader were used when compiling
 ;;  (EVAL-WHEN (#-SB-XC :COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
 ;;    (DEFUN A-MACRO-HELPER () '`(FOO ,A ,B))
 ;; then A-MACRO-HELPER returns host code, and calling it might be wrong, either
 ;; obviously or subtly. If the result is (LIST* 'FOO (LIST* A (LIST B)))
 ;; then it's subtly wrong because it might not be the optimal strategy;
 ;; whereas if it's (BACKQUOTE (FOO (UNQUOTE A) (UNQUOTE B))) then it's
 ;; flat out wrong. At any rate, judicious avoidance of EVAL-WHEN and nested
 ;; quasiquotation in 'primordial-extensions' prevents any such issues.
 ("src/code/backq")

 ;; It's difficult to be too early with a DECLAIM SPECIAL (or DEFVAR
 ;; or whatever) thanks to the sullenly-do-the-wrong-thing semantics
 ;; of CL special binding when the variable is undeclared.
 ("src/code/globals" :not-host)

 ("src/code/cmacros" :not-host)

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; cross-compiler-only replacements for stuff which in target Lisp would be
 ;;; supplied by basic machinery

 ("src/code/cross-byte"  :c-headers :not-target)
 ("src/code/cross-misc"  :c-headers :not-target)
 ("src/code/cross-char"  :c-headers :not-target)
 ("src/code/cross-float" :c-headers :not-target)
 ("src/code/cross-io"    :not-target)
 ("src/code/cross-condition" :not-target)

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; stuff needed early both in cross-compilation host and in target Lisp

 ("src/code/uncross" :c-headers)

 ("src/code/defbangtype" :c-headers)
 ("src/code/early-constants" :c-headers)

 ("src/compiler/deftype" :c-headers)     ; on host for SB-XC:DEFTYPE
 ("src/compiler/early-lexenv" :c-headers)
 ("src/compiler/early-globaldb" :c-headers)

 ;; comes early so that stuff can reason about function names
 ("src/code/function-names" :c-headers)

 ;; for various constants e.g. SB-XC:MOST-POSITIVE-FIXNUM and
 ;; SB-VM:N-LOWTAG-BITS, needed by "early-objdef" and others
 ("src/compiler/generic/parms" :c-headers)
 ("src/compiler/target/parms" :c-headers)
 ("src/compiler/generic/early-vm" :c-headers)
 ("src/compiler/generic/early-objdef" :c-headers)
 ("src/code/early-array" :c-headers) ; needs "early-vm" numbers

 ;; This has the BARRIER stuff that the threading support needs,
 ;; required for some code in 'early-extensions'
 ("src/code/barrier" :not-host)
 ("src/code/parse-body" :c-headers)       ; on host for PARSE-BODY
 ("src/compiler/policy" :c-headers)
 #+sb-fasteval ("src/interpreter/basic-env")
 ;; PARSE-{UNKNOWN,DEPRECATED}-TYPE and other things should be known
 ;; condition subtypes as soon as possible
 ("src/code/condition-boot" :not-host)
 ("src/code/early-extensions" :c-headers) ; on host for COLLECT, SYMBOLICATE, etc.
 ("src/compiler/parse-lambda-list" :c-headers)
 ("src/code/restart" :not-host) ; %DEFCONSTANT can bind a restart

 ("src/code/early-cl")
 ("src/code/ansi-stream" :not-host)
 ("src/code/early-fasl" :c-headers)

 ("src/code/defbangstruct" :c-headers)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; basic machinery for the target Lisp. Note that although most of these
 ;;; files are flagged :NOT-HOST, a few might not be.

 ("src/code/early-print" :not-host)
 ("src/code/early-pprint" :not-host)
 ("src/code/early-impl" :not-host)

 ("src/code/target-extensions" :not-host)

 ;; Needed before the first use of WITH-SINGLE-PACKAGE-LOCKED-ERROR.
 ("src/code/early-package" :not-host)

 ("src/compiler/defconstant")

 ("src/code/early-raw-slots" :c-headers)

 ("src/code/funutils" :not-host)

 ("src/code/maphash" :not-host)
 ("src/code/xset" :c-headers) ; for representation of MEMBER type
 ;; This needs DEF!STRUCT, and is itself needed early so that structure
 ;; accessors and inline functions defined here can be compiled inline
 ;; later. (Avoiding full calls increases efficiency)
 ("src/code/type-class" :c-headers)

 ("src/code/cas" :not-host)
 ("src/compiler/early-c" :c-headers)
 ("src/compiler/fun-info" :c-headers)
 ("src/pcl/slot-name") ; for calls from 'info-vector'
 ;; 'info-vector' is needed at least as early as 'fdefinition' so that the
 ;; inlined INFO-VECTOR-FDEFINITION is available to %COERCE-CALLABLE-TO-FUN.
 ("src/code/signal" :not-host)
 ("src/code/sysmacs" :not-host)
 ("src/code/target-lfhash" :not-host)
 ("src/compiler/info-vector" :c-headers)
 ("src/compiler/globaldb" :c-headers)
 ("src/compiler/generic/vm-array" :c-headers)
 ("src/code/string-hash" :c-headers)
 ("src/code/primordial-type" :c-headers)
 ("src/code/early-classoid" :c-headers)
 ("src/code/early-alieneval" :c-headers)  ; for funs and vars needed at build and run time
 ("src/code/target-error" :not-host)

 ;; "src/code/toplevel.lisp" is the first to need this. It's generated
 ;; automatically by grovel_headers.c, i.e. it's not under source control.
 ("output/stuff-groveled-from-headers" :not-host)

 ("src/code/cold-error"  :not-host)
 ;; Define at most one INTERPRETED-FUNCTION type based on target features
 #+sb-eval ("src/code/early-full-eval" :not-host)
 #+sb-fasteval ("src/interpreter/function" :not-host)
 ("src/code/fdefinition" :not-host)

 ("src/code/weak"          :not-host)
 ;; 'target-alieneval' needs FILL-POINTER which is defined in 'array'
 ("src/code/array"         :not-host) ; needs WEAK-POINTER-VALUE
 ("src/code/debug-var-io")

 ("src/code/target-alieneval" :not-host)
 ("src/code/target-c-call"    :not-host)
 ("src/code/target-allocate"  :not-host)

 ;; This needs DEFINE-ALIEN-ROUTINE from target-alieneval.
 ("src/code/misc-aliens" :not-host)

 ("src/code/early-float")
 ("src/pcl/early-low" :not-host)
 ("src/code/pred" :not-host)
 ("src/compiler/generic/pinned-objects" :not-host)

 ("src/code/target-sxhash" :not-host) ; needs most-fooative-foo-float constants

 ("src/code/list"   :not-host)
 ("src/code/seq"    :not-host) ; "code/seq" should come after "code/list".
 ("src/code/coerce" :not-host)

 ("src/code/huffman")
 ("src/code/target-char"    :not-host)
 ("src/code/target-unicode" :not-host)
 ("src/code/string"     :not-host)
 ("src/code/mipsstrops" :not-host)

 ("src/code/early-time" :c-headers)
 ("src/code/unix" :not-host)
 #+win32 ("src/code/win32" :not-host)

 #+android ("src/code/android-os" :not-host)
 #+sunos ("src/code/sunos-os" :not-host)
 #+hpux  ("src/code/hpux-os"  :not-host)
 #+bsd   ("src/code/bsd-os"   :not-host)
 #+linux ("src/code/linux-os" :not-host)
 #+haiku ("src/code/haiku-os" :not-host)
 #+win32 ("src/code/win32-os" :not-host)

 ("src/code/share-vm" :not-host)

 ("src/code/thread" :not-host) ; provides *CURRENT-THREAD* for target-signal
 ("src/code/target-signal-common" :not-host)

 ("src/code/bignum"     :not-host)
 ("src/code/numbers"    :not-host)
 ("src/code/float-trap" :not-host)
 ("src/code/float"      :not-host)
 ("src/code/irrat"      :not-host)

 ("src/code/misc" :c-headers)

 ("src/code/symbol"        :not-host)
 ("src/code/late-cas"      :not-host)
 ("src/code/fd-stream"     :not-host)
 ("src/code/stream"        :not-host)
 ("src/code/early-format")

 ("src/code/common-os" :not-host)

 ("src/code/deadline" :not-host)
 ("src/code/serve-event" :not-host)

 ("src/code/query"  :not-host)

 ("src/code/sort"  :not-host)
 ("src/code/time"  :not-host)

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; compiler (and a few miscellaneous files whose dependencies make it
 ;;; convenient to stick them here)

 ("src/compiler/policies")

 ("src/compiler/macros" :c-headers)

 ("src/compiler/constantp" :c-headers)
 ("src/compiler/info-functions" :c-headers)
 ("src/code/specializable-array" :not-target)

 ("src/compiler/generic/vm-macs" :c-headers)
 ("src/compiler/generic/objdef" :c-headers)

 ;; needed by "compiler/vop"
 ("src/compiler/sset" :c-headers)
 ("src/code/early-type" :c-headers)
 ;; sparc-vm and ppc-vm need sc+offset defined to get at internal
 ;; error args. This file contains stuff previously in
 ;; debug-info.lisp.  Should it therefore be :not-host?  -- CSR,
 ;; 2002-02-05
 ("src/code/sc-offset" :c-headers)

 ;; for e.g. BLOCK-ANNOTATION, needed by "compiler/vop"
 ("src/compiler/node" :c-headers)
 ;; RECONSTRUCT-LEXENV needs types GLOBAL-VAR and DEFINED-FUN
 ("src/compiler/lexenv")

 ;; This has ASSEMBLY-UNIT-related stuff needed by core.lisp.
 ;; and LABEL, needed by IR2-NLX-INFO
 ("src/compiler/early-assem")

 ;; for e.g. PRIMITIVE-TYPE, needed by "vmdef"
 ("src/compiler/vop" :c-headers)
 ("src/compiler/constant-leaf")

 ;; needed by "vm" and "primtype"
 ("src/compiler/backend" :c-headers)

 ;; for e.g. MAX-VOP-TN-REFS, needed by "meta-vmdef"
 ("src/compiler/vmdef" :c-headers)

 ("src/code/defmacro" :c-headers)
 ("src/code/destructuring-bind" :c-headers)

 ;; for e.g. !DEF-PRIMITIVE-TYPE, needed by primtype.lisp, and
 ;; DEFINE-STORAGE-CLASS, needed by target/vm.lisp
 ("src/compiler/meta-vmdef" :c-headers)

 ("src/compiler/fixup") ; for DEFSTRUCT FIXUP, needed by generic/core
 ("src/compiler/generic/core") ; for CORE-OBJECT-P, needed by x86-64/vm

 ;; for e.g. DESCRIPTOR-REG, needed by primtype.lisp
 ("src/compiler/target/vm" :c-headers)

 ;; KLUDGE: I'd prefer to have this done with a "code/target" softlink
 ;; instead of a bunch of reader macros. -- WHN 19990308
 #+sparc ("src/code/sparc-vm")
 #+hppa  ("src/code/hppa-vm")
 #+x86   ("src/code/x86-vm"   :not-host)
 #+x86-64("src/code/x86-64-vm"   :not-host)
 #+(or ppc ppc64)
 ("src/code/ppc-vm")
 #+alpha ("src/code/alpha-vm")
 #+mips  ("src/code/mips-vm")
 #+arm   ("src/code/arm-vm")
 #+arm64 ("src/code/arm64-vm")
 #+riscv ("src/code/riscv-vm")

 ;; RANDOM-LAYOUT-CLOS-HASH (in 'class') uses RANDOM, the transform for which
 ;; uses GENERATE-RANDOM-EXPR-FOR-POWER-OF-2 which becomes BIG-RANDOM-CHUNK,
 ;; which wants to be inlined, and which when inlined becomes RANDOM-CHUNK,
 ;; which also wants to be inlined.
 ("src/code/target-random" :not-host)
 ;; META-FIXME: I think I figured out why this was, and fixed that,
 ;; and never removed the following comment, nor can I remember why.
 ;; FIXME: Classic CMU CL had (OPTIMIZE (SAFETY 2) (DEBUG 2) declared
 ;; around the compilation of "code/class". Why?
 ("src/code/class" :c-headers)
 ("src/pcl/pre-warm")
 ("src/pcl/low" :not-host)

 ("src/code/debug-info" :c-headers
  #.(cl:if (and (cl:find :sb-xc-host cl:*features*)
                (cl:find :cmucl cl:*features*)) ; gets fatal warnings in CMUCL 20c
        :ignore-failure-p))

 ("src/code/source-location")
 ("src/code/early-class")
 ("src/code/condition" :not-host)
 #-win32 ("src/code/target-signal" :not-host) ; needs OS-CONTEXT-T from share-vm
 #+win32 ("src/code/target-exception" :not-host)
 ("src/code/toplevel"  :not-host)
 ("src/code/parse-defmacro-errors")
 ("src/code/format-directive")
 ;; Target-only stuff should usually be compiled late unless it has
 ;; compile-time side-effects. This file could probably be later,
 ;; but should certainly be no earlier than the definitions
 ;; of FORMAT-ERROR and FORMAT-DIRECTIVE.
 ("src/code/target-format" :not-host)

 ("src/compiler/generic/primtype" :c-headers)

 ;; for DEFSTRUCT ALIEN-TYPE, needed by host-type.lisp
 ("src/code/host-alieneval")

 ;; can't be done until definition of e.g. DEFINE-ALIEN-TYPE-CLASS in
 ;; host-alieneval.lisp
 ("src/code/host-c-call")

 ;; SB-XC:DEFTYPE is needed in order to compile late-type
 ;; in the host Common Lisp, and in order to run, it needs
 ;; %COMPILER-DEFTYPE.
 ("src/compiler/compiler-deftype" :c-headers)

 ;; These appear here in the build sequence because they require
 ;;   * the macro INFO, defined in globaldb.lisp, and
 ;;   * the function PARSE-DEFMACRO, defined in parse-defmacro.lisp,
 ;; and because they define
 ;;   * the function SPECIFIER-TYPE, which is used in fndb.lisp.
 ("src/code/late-type" :c-headers)
 ;; Compile target-only stuff after all defglobals like *CONS-T-T-TYPE*
 ;; and all type-classes are defined.
 ("src/code/deftypes-for-target" :c-headers)

 ;; defines IR1-ATTRIBUTES macro, needed by proclaim.lisp
 ("src/compiler/knownfun")

 ;; stuff needed by "code/defstruct"
 ("src/code/cross-type" :c-headers :not-target)
 ("src/compiler/generic/vm-type" :c-headers)
 ("src/compiler/proclaim" :c-headers)

 ("src/code/class-init" :c-headers)

 ;; The DEFSTRUCT machinery needs SB-XC:SUBTYPEP, defined in
 ;; "code/late-type", and SB-XC:TYPEP, defined in "code/cross-type",
 ;; and SPECIALIZE-ARRAY-TYPE, defined in "compiler/generic/vm-type",
 ;; and SB-XC:PROCLAIM, defined in "src/compiler/proclaim"
 ("src/code/defstruct"  :c-headers)
 ("src/code/target-defstruct" :not-host)

 ;; ALIEN-VALUE has to be defined as a class (done by DEFSTRUCT
 ;; machinery) before we can set its superclasses here.
 ("src/code/alien-type")

 ;; This needs not just the SB-XC:DEFSTRUCT machinery, but also
 ;; the TYPE= stuff defined in late-type.lisp, and the
 ;; CHECK-FUN-NAME defined in proclaim.lisp.
 ("src/code/force-delayed-defbangstructs" :c-headers)

 ("src/compiler/compiler-error")

 ("src/code/type-init")
 ;; Now that the type system is initialized, fix up UNKNOWN types that
 ;; have crept in.
 ("src/compiler/fixup-type")

 ;; These define target types needed by fndb.lisp.
 ("src/code/package" :c-headers)
 ("src/code/typep" :not-host)
 ("src/code/random")
 ("src/code/hash-table" :c-headers)
 ("src/code/readtable")
 ("src/code/pathname")
 ("src/code/host-pprint") ; defines QUEUED-OP needed by 'pprint'

 ("src/compiler/fndb")
 ("src/compiler/generic/vm-fndb")

 ("src/compiler/generic/late-objdef" :c-headers)

 ("src/compiler/generic/interr" :c-headers)

 ("src/compiler/bit-util")

 ("src/code/load")

 #+linkage-table ("src/code/linkage-table" :not-host)
 ("src/code/foreign" :not-host)
 #+os-provides-dlopen ("src/code/foreign-load" :not-host)
 #+(and os-provides-dlopen (not win32)) ("src/code/unix-foreign-load" :not-host)
 #+(and os-provides-dlopen win32) ("src/code/win32-foreign-load" :not-host)

 ("src/code/fop") ; needs macros from code/load.lisp

 ("src/compiler/ctype")
 ("src/compiler/disassem")
 ("src/compiler/assem")

 ;; Compiling this requires fop definitions from code/fop.lisp and
 ("src/compiler/dump")
 ("src/compiler/target-dump" :not-host) ; needs stuff from compiler/dump.lisp

 ("src/compiler/ir1report") ; for COMPILER-ERROR-CONTEXT
 ("src/code/target-pathname" :not-host) ; needs "code/pathname"
 ("src/compiler/main") ; needs DEFSTRUCT FASL-OUTPUT from dump.lisp
 ("src/compiler/xref")
 ("src/compiler/target-main" :not-host)
 ("src/compiler/ir1tran")
 ("src/compiler/ir1tran-lambda")
 ("src/compiler/ir1-translators"
  ;; workaround for ABCL warnings that are not of type STYLE-WARNING:
  ;;  "Unable to compile function IR1-CONVERT-TAGBODY.  Using interpreted form instead."
  #.(cl:if (and (cl:find :sb-xc-host cl:*features*)
                (cl:find :abcl cl:*features*))
        :ignore-failure-p))
 ("src/compiler/ir1util")
 ("src/compiler/callable-args")
 ("src/compiler/ir1opt")
 ("src/compiler/loop")

 ("src/compiler/ir1final")
 ("src/compiler/constraint")
 ("src/compiler/array-tran")
 ("src/compiler/seqtran")
 ("src/compiler/saptran")
 ("src/compiler/modarith")
 ("src/compiler/sxhash")
 ("src/code/quantifiers")
 ("src/compiler/bitops-derive-type")
 ("src/compiler/locall")
 ("src/compiler/dfo")
 ("src/compiler/dce")
 ("src/compiler/checkgen")

 ("src/compiler/tn")
 ("src/compiler/life")

 ("src/compiler/debug-dump")
 ("src/compiler/generic/utils" :c-headers)
 ("src/compiler/fopcompile")

 ("src/assembly/assemfile" :not-target)

 ("src/compiler/target-dstate" :not-host)
 ("src/compiler/asm-target/insts")
 #+avx2
 ("src/compiler/target/avx2-insts")
 ("src/compiler/target/macros")
 ("src/compiler/generic/early-type-vops")

 ("src/assembly/target/support")

 ("src/compiler/target/move")
 ("src/compiler/target/float")
 #+sb-simd-pack
 ("src/compiler/target/simd-pack")
  #+sb-simd-pack-256
 ("src/compiler/target/simd-pack-256")
 ("src/compiler/target/sap")
 ("src/compiler/target/system")
 ("src/compiler/target/char")
 ("src/compiler/target/memory")
 ("src/compiler/target/arith"
  ;; KLUDGE: for ppc and sparc this appears to be necessary, as it
  ;; used to be for array VOPs for X86 until ca. 0.8.5.24 when CSR's
  ;; patch for that architecture was finally committed
  ;;
  ;; old (0.8.5.23) comment on the array-VOP hack for X86:
  ;; x Compiling this file for X86 raises alarming warnings of
  ;; x the form
  ;; x    Argument FOO to VOP CHECK-BOUND has SC restriction
  ;; x    DESCRIPTOR-REG which is not allowed by the operand type:
  ;; x      (:OR POSITIVE-FIXNUM)
  ;; x This seems not to be something that I broke, but rather a "feature"
  ;; x inherited from classic CMU CL. (Debian cmucl_2.4.8.deb compiling
  ;; x Debian cmucl_2.4.8.tar.gz raises the same warning). Thus, even though
  ;; x these warnings are severe enough that they would ordinarily abort
  ;; x compilation, for now we blithely ignore them and press on to more
  ;; x pressing problems. Someday, though, it would be nice to figure out
  ;; x what the problem is and fix it.
  #+(or ppc ppc64) :ignore-failure-p)
 ("src/compiler/target/pred")

 ;; this file defines the INTERVAL struct which is also used in 'srctran'
 ("src/compiler/float-tran")
 ;; This is a terrible name for a file that contains type derivers
 ;; and IR1 transforms. Maybe split it up into more appropriately named pieces.
 ("src/compiler/srctran")
 ("src/compiler/generic/vm-tran")
 ("src/compiler/generic/late-type-vops")
 ("src/compiler/target/type-vops")
 ("src/compiler/typetran")
 ("src/compiler/generic/vm-typetran")
 ("src/code/cross-modular"  :not-target)

 ("src/compiler/target/subprim")
 ("src/compiler/target/debug")
 ("src/compiler/target/c-call")
 ("src/compiler/target/cell")
 ("src/compiler/target/values")
 ("src/compiler/target/alloc")
 ("src/compiler/target/call")
 ("src/compiler/target/nlx")
 ("src/compiler/generic/late-nlx")
 ("src/compiler/target/show")
 ("src/compiler/target/array")
 ("src/compiler/generic/type-error")
 ("src/compiler/physenvanal")

 ;; KLUDGE: The assembly files need to be compiled twice: once as
 ;; normal lisp files, and once by sb-c:assemble-file.  We use a
 ;; different suffix / "file type" for the :assem versions to make
 ;; sure we don't scribble over anything we shouldn't.

 ("src/assembly/target/assem-rtns")
 ("src/assembly/target/array")
 ("src/assembly/target/arith")
 ("src/assembly/target/alloc")
 ;; assembly files are all loaded by genesis before any compiled files.
 ("src/assembly/master" :assem :not-host)

 ("src/compiler/pseudo-vops")

 ("src/compiler/aliencomp")

 ("src/compiler/ltv")
 ("src/compiler/gtn")
 ("src/compiler/ltn")
 ("src/compiler/stack")
 ("src/compiler/control")
 ("src/compiler/entry")
 ("src/compiler/ir2tran")

 ("src/compiler/generic/vm-ir2tran")

 ("src/compiler/copyprop")
 ("src/compiler/represent")
 ("src/compiler/ir2opt")
 ("src/compiler/pack")
 ("src/compiler/pack-iterative")
 ("src/compiler/codegen")
 ("src/compiler/debug")

 #+sb-dyncount ("src/compiler/dyncount")
 #+sb-dyncount ("src/code/dyncount")

 ("src/code/format-time" :not-host)

 ;; needed by various unhappy-path cases in the cross-compiler
 ("src/code/error")

 ;; This wasn't in classic CMU CL "comcom.lisp", but it has some stuff
 ;; that Python-as-cross-compiler has turned out to need.
 ("src/code/macroexpand")

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; files which depend in some way (directly or indirectly) on stuff
 ;; compiled as part of the compiler

 ("src/code/late-extensions") ; needs condition system
 ("src/compiler/generic/target-core" :not-host) ; uses stuff from
                                                ;   "compiler/generic/core"

 ("src/code/alloc"             :not-host) ; needs foo-SPACE-START
 ("src/code/simple-fun"        :not-host) ; function slot accessors
 ("src/code/eval"              :not-host) ; uses INFO, wants compiler macro
 ("src/code/target-package"    :not-host) ; needs "code/package"
 ("src/code/bignum-random"     :not-host) ; needs "code/random" and
                                          ;   "code/bignum"
 ("src/code/target-hash-table" :not-host) ; needs "code/hash-table"
 ("src/code/final" :not-host)
 ("src/code/pprint" :not-host) ; defines WITH-PRETTY-STREAM needed by 'print'
 ("src/code/reader" :not-host) ; needs "code/readtable"
 ("src/code/print" :not-host)

 ("src/code/target-stream"     :not-host) ; needs WHITESPACEP from "code/reader"
 #-win32
 ("src/code/unix-pathname"     :not-host)
 #+win32
 ("src/code/win32-pathname"    :not-host)
 ("src/code/filesys"           :not-host) ; needs HOST from "code/pathname"

 ("src/code/target-misc"       :not-host) ; dribble-stream, used by "save"
 ("src/code/sharpm"            :not-host) ; uses stuff from "code/reader"

 ("src/code/early-step")                  ; target-thread needs *STEP-OUT*

 ("src/code/gc"                :not-host)
 ("src/code/avltree"           :not-host)
 ("src/code/target-thread"     :not-host)
 ("src/code/timer" :not-host)

 ("src/code/error-error" :not-host) ; needs WITH-STANDARD-IO-SYNTAX macro
 ;; defines SB-DI:DO-DEBUG-FUN-BLOCKS, needed by target-disassem.lisp
 ("src/code/debug-int" :not-host)
 ("src/code/interr" :not-host)

 ("src/code/target-load" :not-host) ; for *assembler-routines*, needed by target-disassem

 ;; target-only assemblerish stuff
 ("src/compiler/target-disassem"     :not-host)
 ("src/compiler/asm-target/target-insts" :not-host)
 #+avx2
 ("src/compiler/target/target-avx2-insts" :not-host)

 ("src/code/debug" :not-host)

 ("src/code/octets" :not-host)
 ("src/code/external-formats/enc-basic" :not-host)
 #+sb-unicode
 ("src/code/external-formats/enc-ucs" :not-host) ; win32 needs this

 #+sb-eval
 ("src/code/full-eval"   :not-host) ; uses INFO, ARG-COUNT-ERROR

 ("src/code/bit-bash"    :not-host) ; needs %NEGATE from assembly/target/arith

 #-(or x86 x86-64)
 ("src/compiler/generic/sanctify" :not-host)

 ("src/code/cold-init" :not-host) ; needs (SETF EXTERN-ALIEN) macroexpansion

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; target macros and DECLAIMs installed at build-the-cross-compiler time

 ;; FIXME: here? earlier?  can probably be as late as possible.  Also
 ;; maybe call it FORCE-DELAYED-PROCLAIMS?
 ("src/compiler/late-proclaim")

 ("src/code/setf")
 ("src/code/macros")
 ("src/code/loop")

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; other target-code-building stuff which can't be processed until
 ;; machinery like SB-XC:DEFMACRO exists

 ("src/code/late-format" ; needs SB-XC:DEFMACRO
  #.(cl:if (and (cl:find :sb-xc-host cl:*features*)
                (cl:find :cmucl cl:*features*)) ; gets fatal warnings in CMUCL 20c
        :ignore-failure-p))

 ("src/code/late-globaldb" :not-host)
 ("src/code/redblack" :not-host)
 ;; This file, which must be last, contains sanity-checks of the cross-compile.
 ;; The inputs and outputs of certain functions (currently just SXHASH) are stored
 ;; in global symbols. Relying on the fact that data are easily dumped as constants
 ;; (assuming we don't have a genesis bug), the forms in this file can audit
 ;; whether things came out right.
 ("src/code/last-file" :not-host))

;;; make-target-2 build steps
(("src/code/early-ntrace" ; lets PCL hook into tracing
  "src/code/room" ; for MAP-ALLOCATED-OBJECTS
  #+immobile-code "src/code/immobile-space" ; needs src/code/room
  ;; Delay (re)defining WARN until after remove-static-links works.
  ;; The definition in cold-error is good enough for self-build.
  "src/code/warm-error"
  "src/code/icf"
  ;; We re-nickname SB-SEQUENCE as SEQUENCE now.
  ;; It could be done in genesis, but not earlier,
  ;; since the host has a package of that name.
  "src/code/defpackage"
  "src/code/target-lflist"
  "src/pcl/walk") ; needs DEFPACKAGE

 #+sb-fasteval
 ("src/interpreter/macros"
  "src/interpreter/checkfuns"
  "src/interpreter/env"
  "src/interpreter/sexpr"
  "src/interpreter/special-forms"
  "src/interpreter/eval"
  "src/interpreter/debug")

 ("src/code/external-formats/enc-ebcdic")
 #+sb-unicode
 ("src/code/external-formats/enc-cyr"
  "src/code/external-formats/enc-dos"
  "src/code/external-formats/enc-iso"
  "src/code/external-formats/enc-win"
  "src/code/external-formats/enc-mac"
  "src/code/external-formats/mb-util"
  "src/code/external-formats/enc-cn-tbl"
  "src/code/external-formats/enc-cn"
  "src/code/external-formats/enc-jpn-tbl"
  "src/code/external-formats/enc-jpn"
  "src/code/external-formats/enc-utf")

 ("src/code/stubs")

 ;; CLOS, derived from the PCL reference implementation
 ;;
 ;; This PCL build order is based on a particular
 ;; (arbitrary) linearization of the declared build
 ;; order dependencies from the old PCL defsys.lisp
 ;; dependency database.
 ("src/pcl/macros"
  "src/pcl/compiler-support"
  "src/pcl/defclass"
  "src/pcl/defs"
  "src/pcl/fngen"
  "src/pcl/wrapper"
  "src/pcl/cache"
  "src/pcl/dlisp"
  "src/pcl/boot"
  "src/pcl/vector"
  "src/pcl/slots-boot"
  "src/pcl/combin"
  "src/pcl/dfun"
  "src/pcl/ctor"
  "src/pcl/braid"
  "src/pcl/dlisp3"
  "src/pcl/generic-functions"
  "src/pcl/slots"
  "src/pcl/init"
  "src/pcl/std-class"
  "src/pcl/cpl"
  "src/pcl/fsc"
  "src/pcl/methods"
  "src/pcl/fixup"
  "src/pcl/defcombin"
  "src/pcl/ctypes"
  "src/pcl/env"
  "src/pcl/documentation"
  "src/pcl/print-object"
  "src/pcl/precom1"
  "src/pcl/precom2"
  "src/code/ntrace")

 ("src/code/setf-funs"
  ;; miscellaneous functionality which depends on CLOS
  "src/code/late-condition"

  ;; CLOS-level support for the Gray OO streams
  ;; extension (which is also supported by various
  ;; lower-level hooks elsewhere in the code)
  "src/pcl/gray-streams-class"
  "src/pcl/gray-streams"

  ;; CLOS-level support for User-extensible sequences.
  "src/pcl/sequence"

  ;; other functionality not needed for cold init, moved
  ;; to warm init to reduce peak memory requirement in
  ;; cold init
  "src/code/describe"

  "src/code/describe-policy"
  "src/code/inspect"
  "src/code/profile"
  #+(and x86-64 sb-thread) "src/code/aprof" ; precise allocation profiler
  "src/code/step"
  "src/code/warm-lib"
  "src/code/alien-callback"
  "src/code/run-program"
  #+win32 "src/code/warm-mswin"
  #+gencgc "src/code/traceroot"

  "src/code/repack-xref"
  #+cheneygc "src/code/purify"
  "src/code/module"
  "src/code/save"))
