Optionally preserve EFLAGS in WITH-REGISTERS-PRESERVED
[sbcl.git] / crossbuild-runner / pass-2.lisp
blobc31a25979d918acc977b647aa6ff4c50848fa3b9
1 (defvar *config-name* (second sb-ext:*posix-argv*))
2 (defvar *sbcl-local-target-features-file*
3 (format nil "obj/xbuild/~A/local-target-features" *config-name*))
4 (load "src/cold/shared.lisp")
5 (in-package "SB-COLD")
6 (let* ((build-dir (format nil "obj/xbuild/~A/" cl-user::*config-name*))
7 (objroot (format nil "~A/from-xc/" build-dir)))
8 (ensure-directories-exist objroot)
9 (defparameter *host-obj-prefix* (format nil "~A/from-host/" build-dir))
10 (defparameter *target-obj-prefix* objroot)
11 (defparameter *build-dependent-generated-sources-root* objroot)
12 (let ((makeflags (sb-ext:posix-getenv "MAKEFLAGS")))
13 (when (search "--jobserver" makeflags)
14 (setq sb-sys:*stdout* (open (format nil "~A/stdout" objroot) :direction :output
15 :if-does-not-exist :create :if-exists :supersede)
16 sb-sys:*stderr* (open (format nil "~A/stderr" objroot) :direction :output
17 :if-does-not-exist :create :if-exists :supersede))
18 (setf (sb-impl::fd-stream-buffering sb-sys:*stdout*) :line))))
19 (load "src/cold/set-up-cold-packages.lisp")
20 (load "src/cold/defun-load-or-cload-xcompiler.lisp")
21 (load-or-cload-xcompiler #'host-load-stem)
22 (preload-perfect-hash-generator (perfect-hash-generator-journal :input))
24 ;;; Redefine STEM-SOURCE-PATH to take 'stuff-groveled-from-headers' from the
25 ;;; configuration-dependent location, but otherwise the normal locpation.
26 (host-sb-int:encapsulate 'stem-source-path 'wrap
27 (lambda (realfun stem)
28 (if (string= stem "output/stuff-groveled-from-headers")
29 (let ((arch (string-downcase (sb-cold::target-platform-keyword))))
30 (flet ((try (name &optional (check-existence t))
31 (let ((fullname
32 (format nil "crossbuild-runner/backends/~a/~a.lisp" arch name)))
33 (when (or (not check-existence) (probe-file fullname))
34 fullname))))
35 (or (and (member :win32 sb-xc:*features*) (try "win32-headers"))
36 (and (member :linux sb-xc:*features*) (try "linux-headers"))
37 (and (member :darwin sb-xc:*features*) (try "darwin-headers"))
38 (try "posix-headers")
39 (try "stuff-groveled-from-headers" nil))))
40 (funcall realfun stem))))
42 (format t "~&Target features: ~S~%" sb-xc:*features*)
43 (let ((warnings (sb-xc:with-compilation-unit ()
44 (load "src/cold/compile-cold-sbcl.lisp")
45 sb-c::*undefined-warnings*)))
46 (finish-output host-sb-sys:*stdout*)
47 (finish-output host-sb-sys:*stderr*)
48 (when warnings
49 (error "Fail")))
51 (load "tools-for-build/corefile.lisp" :verbose nil)
52 (host-cload-stem "src/compiler/generic/genesis" nil)
53 (let (object-file-names)
54 (do-stems-and-flags (stem flags 2)
55 (unless (member :not-target flags)
56 (push (stem-object-path stem flags :target-compile) object-file-names)))
57 (genesis :object-file-names (nreverse object-file-names)
58 :defstruct-descriptions (find-bootstrap-file "output/defstructs.lisp-expr" t)
59 :tls-init (read-from-file "output/tls-init.lisp-expr" :build-dependent t)
60 :core-file-name (format nil "obj/xbuild/~A.core" cl-user::*config-name*)))