changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > core / lisp/lib/cli/tools/cc.lisp

revision 496: 6359b351657a
parent 471: 33b0614ee220
     1.1--- a/lisp/lib/cli/tools/cc.lisp	Sun Jun 30 22:36:21 2024 -0400
     1.2+++ b/lisp/lib/cli/tools/cc.lisp	Mon Jul 01 15:50:23 2024 -0400
     1.3@@ -9,7 +9,36 @@
     1.4 ;;; Code:
     1.5 (in-package :cli/tools/cc)
     1.6 
     1.7+(deferror cc-error (simple-error error) ())
     1.8+
     1.9+(defun cc-error (fmt &rest args)
    1.10+  (error 'cc-error :format-arguments args :format-control fmt))
    1.11+
    1.12 (defparameter *cc* (find-exe "clang"))
    1.13 
    1.14+(defparameter *ld*
    1.15+  (or
    1.16+   #+unix (find-exe "ld.lld")
    1.17+   #+darwin (find-exe "ld64.lld")
    1.18+   #+windows (find-exe "lld-link")
    1.19+   (find-exe "ld")))
    1.20+
    1.21 (defun run-cc (&rest args)
    1.22-  (apply #'sb-ext:run-program *cc* (or args (list nil))))
    1.23+  (let ((proc (sb-ext:run-program *cc* (or args nil) :output :stream)))
    1.24+    (with-open-stream (s (sb-ext:process-output proc))
    1.25+      (loop for l = (read-line s nil nil)
    1.26+            while l
    1.27+            do (write-line l)))
    1.28+    (if (eq 0 (sb-ext:process-exit-code proc))
    1.29+        nil
    1.30+        (cc-error "CC command failed: ~A ~A" *cc* (or args "")))))
    1.31+
    1.32+(defun run-ld (&rest args)
    1.33+  (let ((proc (sb-ext:run-program *ld* (or args nil) :output :stream)))
    1.34+    (with-open-stream (s (sb-ext:process-output proc))
    1.35+      (loop for l = (read-line s nil nil)
    1.36+            while l
    1.37+            do (write-line l)))
    1.38+    (if (eq 0 (sb-ext:process-exit-code proc))
    1.39+        nil
    1.40+        (cc-error "LD command failed: ~A ~A" *ld* (or args "")))))