Accept -jN arg to build-all-cores

and don't redirect *stdout* and *stderr* if -j1.

You can specify more than one target, and they will follow one another
with no chance of overlap since it's sequential. This should give more-or-less
the same behavior as the deleted crossbuild-runner/build-all.sh script.

We can add a few more indicators of where each build starts,
but this is probably adequate for now.
This commit is contained in:
Douglas Katzman 2024-02-05 03:51:28 -05:00
parent c4d1903ebf
commit ff13bbf506
3 changed files with 30 additions and 11 deletions

View file

@ -2,7 +2,6 @@
./run-sbcl.sh --noprint --disable-debugger $* <<\EOF
(defvar *configs-to-build* (cdr *posix-argv*))
;;; TODO: allow this to be specified on the command line
(defparameter *jobs*
(max 1
#+unix
@ -11,7 +10,22 @@
(function sb-alien:long sb-alien:int))
sb-unix::sc-nprocessors-onln)
2)))
(format t "~&Using up to ~D job~:P~%" *jobs*)
(let ((first (car *configs-to-build*)))
(if (and (stringp first)
(>= (length first) 2)
(string= first "-j" :end1 2))
;; allow "-jN" as two args
(cond ((= (length first) 2)
(pop *configs-to-build*)
(setq *jobs* (parse-integer (pop *configs-to-build*))))
((digit-char-p (char first 2)) ; or "-jN" as one arg
(setq *jobs* (parse-integer first :start 2))
(pop *configs-to-build*))
(t
(error "-j requires a number")))))
(when (> *jobs* 1) (format t "~&Using up to ~D job~:P~%" *jobs*))
;;; I should probably have a way to add a fixed set of features in
;;; for an architecture, such as :LITTLE-ENDIAN for x86{-64}.
@ -102,6 +116,7 @@ obj/xbuild/{cfg}.core: obj/xbuild/{cfg}/xc.core
*all-configurations*))))
(ensure-directories-exist "obj/xbuild/")
;; if it's just one target this could exec() instead
(defvar *process*
(run-program "make"
`(,(format nil "-j~D" *jobs*)

View file

@ -12,10 +12,12 @@
;; (format t "~&added features: ~S~%" add-features)
(ensure-directories-exist objroot)
(defvar *sbcl-host-obj-prefix* objroot)
(setq sb-sys:*stdout* (open (format nil "~A/stdout" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede)
sb-sys:*stderr* (open (format nil "~A/stderr" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede))
(let ((makeflags (sb-ext:posix-getenv "MAKEFLAGS")))
(when (search "--jobserver-fds" makeflags)
(setq sb-sys:*stdout* (open (format nil "~A/stdout" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede)
sb-sys:*stderr* (open (format nil "~A/stderr" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede))))
(defvar *sbcl-local-target-features-file* ltf)
(with-open-file (*standard-output* ltf :direction :output
:if-does-not-exist :create

View file

@ -9,11 +9,13 @@
(defparameter *host-obj-prefix* (format nil "~A/from-host/" build-dir))
(defparameter *target-obj-prefix* objroot)
(defparameter *build-dependent-generated-sources-root* objroot)
(setq sb-sys:*stdout* (open (format nil "~A/stdout" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede)
sb-sys:*stderr* (open (format nil "~A/stderr" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede)))
(setf (sb-impl::fd-stream-buffering sb-sys:*stdout*) :line)
(let ((makeflags (sb-ext:posix-getenv "MAKEFLAGS")))
(when (search "--jobserver-fds" makeflags)
(setq sb-sys:*stdout* (open (format nil "~A/stdout" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede)
sb-sys:*stderr* (open (format nil "~A/stderr" objroot) :direction :output
:if-does-not-exist :create :if-exists :supersede))
(setf (sb-impl::fd-stream-buffering sb-sys:*stdout*) :line))))
(load "src/cold/set-up-cold-packages.lisp")
(load "src/cold/defun-load-or-cload-xcompiler.lisp")
(load-or-cload-xcompiler #'host-load-stem)