From eac8e531e7a68155ff6d4612dd9d8c24b7d59dae Mon Sep 17 00:00:00 2001 From: snmsts Date: Wed, 17 Jan 2024 16:02:16 +0900 Subject: [PATCH] try detect rosetta environment --- bin/main.lisp | 1 + bin/uname.lisp | 11 +++++++++-- bin/util.lisp | 21 ++++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bin/main.lisp b/bin/main.lisp index ab46fbc..262f767 100644 --- a/bin/main.lisp +++ b/bin/main.lisp @@ -52,6 +52,7 @@ (sb-posix:unsetenv "P") (setf *stage1-commit* (uiop:read-file-line "lib/commit")) (lib-init) + (strip-run-cmd nil) ;; clear all cache (uname-s) (uname-m)) diff --git a/bin/uname.lisp b/bin/uname.lisp index c1982b6..917cf52 100644 --- a/bin/uname.lisp +++ b/bin/uname.lisp @@ -24,7 +24,14 @@ (defun uname-m () (let ((m (strip-run-cmd "uname -m" :cache t))) - (cond ((equal m "i86pc") + (cond ((equal m "x86_64") + (or + #+darwin + (when (equal (strip-run-cmd "sysctl -in sysctl.proc_translated" :cache t) + "1") + "arm64") ;;rosetta + "x86-64")) + ((equal m "i86pc") ;; solaris (if (equal (strip-run-cmd "isainfo -k" :cache t) "amd64") @@ -54,7 +61,7 @@ (defun core-path (base-path) (merge-pathnames (format nil "core/~A/~A/roswell~A" - (uname-m) + (uname-m) (uname-s) (exeext)) base-path)) diff --git a/bin/util.lisp b/bin/util.lisp index 0ab9a76..2127d98 100644 --- a/bin/util.lisp +++ b/bin/util.lisp @@ -39,15 +39,18 @@ (defvar *strip-run-cmd-hash* (make-hash-table :test 'equal)) (defun strip-run-cmd (cmd &key cache) - (unless cache - (remhash cmd *strip-run-cmd-hash*)) - (if (eql (gethash cmd *strip-run-cmd-hash* t) t) - (setf (gethash cmd *strip-run-cmd-hash*) - (uiop:run-program - cmd - :output '(:string :stripped t) - :ignore-error-status t)) - (gethash cmd *strip-run-cmd-hash*))) + (cond (cmd + (unless cache + (remhash cmd *strip-run-cmd-hash*)) + (if (eql (gethash cmd *strip-run-cmd-hash* t) t) + (setf (gethash cmd *strip-run-cmd-hash*) + (uiop:run-program + cmd + :output '(:string :stripped t) + :ignore-error-status t)) + (gethash cmd *strip-run-cmd-hash*))) + (t + (setf *strip-run-cmd-hash* (make-hash-table :test 'equal))))) (defun which (cmd) "find out command's full path."