ほんとのこと知りたいだけなのに。

夏休みはもうおわり。

Windows で trival-ssh が出来ない件

(ql:quickload :trivial-ssh) すると [package libssh2]. で停止する。

表示されるコマンドを msys2 のターミナルで叩くと成功する模様

yanqi@ MINGW64 ~/.emacs.d/dist/emacs                                                                                                                              
$ gcc -o "C:\Users\yanqi\AppData\Local\common-lisp\sbcl-1.3.15-win-x64\C\Users\yanqi\prj\trivial-ssh\libssh2\libssh2-libc-cffi__grovel-tmpGHU3ALSV.obj" -c -m64 -IC:/Users/y 
anqi/prj/cffi/ "C:\Users\yanqi\AppData\Local\common-lisp\sbcl-1.3.15-win-x64\C\Users\yanqi\prj\trivial-ssh\libssh2\libssh2-libc-cffi__grovel.c"                              
                                                                                                                                                                             
yanqi@ MINGW64 ~/.emacs.d/dist/emacs                                                                                                                              
$ echo $?                                                                                                                                                                    
0                                                                                                                                                                            

yanqi@ MINGW64 ~/.emacs.d/dist/emacs
$ ls -la /c/Users/yanqi/AppData/Local/common-lisp/sbcl-1.3.15-win-x64/C/Users/yanqi/prj/trivial-ssh/libssh2/libssh2-libc-cffi__grovel-tmpGHU3ALSV.obj
-rw-r--r-- 1 PC568+yanqi PC568+yanqi 5537 9月   2 14:52 /c/Users/yanqi/AppData/Local/common-lisp/sbcl-1.3.15-win-x64/C/Users/yanqi/prj/trivial-ssh/libssh2/libssh2-libc-cffi_ _grovel-tmpGHU3ALSV.obj

コードを眺めてみる。

trivial-ssh-libssh2.asd(cffi-grovel:grovel-file "libssh2-libc-cffi") で libssh2 をコンパイルしているがここで止っている様子

cffi-grovel:grovel-file

cffi-grovel:grovel-file はクラスでした。

(defclass grovel-file (process-op-input cc-flags-mixin)
  ()
  (:default-initargs
   :generated-lisp-file-type "processed-grovel-file")
  (:documentation
   "This ASDF component represents an input file that is processed
    by PROCESS-GROVEL-FILE."))

grovel.lisp

grovel.lispprocess-grovel-file で帰ってこない模様。

(cc-compile o-file inputs)
;;; *PACKAGE* is rebound so that the IN-PACKAGE form can set it during
;;; *the extent of a given grovel file.
(defun process-grovel-file (input-file &optional (output-defaults input-file))
  (with-standard-io-syntax
    (let* ((c-file (generate-c-file input-file output-defaults))
           (o-file (make-o-file-name c-file))
           (exe-file (make-exe-file-name c-file))
           (lisp-file (tmp-lisp-file-name c-file))
           (inputs (list (cc-include-grovel-argument) c-file)))
      (handler-case
          (progn
            ;; at least MKCL wants to separate compile and link
            (cc-compile o-file inputs)
            (link-executable exe-file (list o-file)))
        (error (e)
          (grovel-error "~a" e)))
      (invoke exe-file lisp-file)
      lisp-file)))

cc-compile

cc-compile は コンパイルしているだけ。

(defun cc-compile (output-file inputs)
  (apply 'invoke-builder (list *cc* "-o") output-file
         "-c" (append *cc-flags* #-windows '("-fPIC") inputs)))

invoke-builder

(defun invoke-builder (builder output-file &rest args)
  "Invoke the C Compiler with given OUTPUT-FILE and arguments ARGS"
  (with-temporary-output (output-file)
    (apply 'invoke `(,@builder ,output-file ,@args))))

invoke

ここの以下の場所で帰ってこない。

(run-program cmd :output :interactive :error-output :interactive)

(defun invoke (command &rest args)
  (when (pathnamep command)
    (setf command (native-namestring command))
    #+os-unix
    (unless (absolute-pathname-p command)
      (setf command (strcat "./" command))))
  (let ((cmd (cons command (mapcar 'program-argument args))))
    (safe-format! *debug-io* "; ~A~%" (escape-command cmd))
    (dolist (d cmd)
      (print d))
    (run-program cmd :output :interactive :error-output :interactive)))

run-program

UIOP/RUN-PROGRAM:RUN-PROGRAM な様子。

UIOP か。。。

UIOP 見るかぁ

で、時間がないので今度にしよう。