4

I'm trying to loads cl-mpi system with quicklisp. This is the system definition:

(asdf:defsystem cl-mpi
    :description "Common Lisp bindings for the Message Passing Interface (MPI)"
    :author "Alex Fukunaga"
    :version "0.1.0"
    :license "MIT"
    :depends-on (:cffi :cffi-grovel)
    :components
    ((:file "packages")
     (:file "cl-mpi-configure" :depends-on ("packages"))
     (cffi-grovel:grovel-file "mpi-grovel" :depends-on ("packages" "cl-mpi-configure"))
     (:file "mpi" :depends-on ("packages"))))

This fails to compile because it "doesn't know" what $CC is set to. I need it to be set to mpicc. I found the code, where I think it sets it:

(defun cc-compile-and-link (input-file output-file &key library)
  (let ((arglist
         `(,(or (getenv "CC") *cc*)
           ,@*cpu-word-size-flags*
           ,@*cc-flags*
           ;; add the cffi directory to the include path to make common.h visible
           ,(format nil "-I~A"
                    (directory-namestring
                     (truename
                      (asdf:system-definition-pathname :cffi-grovel))))
           ,@(when library *platform-library-flags*)
           "-o" ,(native-namestring output-file)
           ,(native-namestring input-file))))
    (when library
      ;; if it's a library that may be used, remove it
      ;; so we won't possibly be overwriting the code of any existing process
      (ignore-some-conditions (file-error)
        (delete-file output-file)))
    (apply #'invoke arglist)))

The above is inside the asdf package. However I can't understand how to change the defsystem to account for the compiler.

PS: This is what the error looks like:

External process exited with code 1.
Command was: "cc" "-m64" "-I/home/wvxvw/quicklisp/dists/quicklisp/software/cffi_0.11.1/" 
"-o" "/home/wvxvw/.cache/common-lisp/sbcl-1.1.2-1.fc18-linux-x64/home/wvxvw/quicklisp/local-projects/cl-mpi/mpi-grovel" 
"/home/wvxvw/.cache/common-lisp/sbcl-1.1.2-1.fc18-linux-x64/home/wvxvw/quicklisp/local-projects/cl-mpi/mpi-grovel.c"

Output was:
/home/wvxvw/.cache/common-lisp/sbcl-1.1.2-1.fc18-linux-x64/home/wvxvw/quicklisp/local-projects/cl-mpi/mpi-grovel.c:6:34: 
fatal error: /usr/include/mpi/mpi.h: No such file or directory

compilation terminated.

formatted for readability. The compiler doesn't find the header because it's not the proper compiler (mpicc "knows" where to look for mpi.h header, it won't be looking in the /usr/include).


Sorry for the confusion. I could set $CC to mpicc, but it still doesn't find /usr/include/mpich-x86_64/mpi.h header - so maybe I need to set include path rather than compiler? If so, how?

This is how I managed to set it to mpicc:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :cffi-grovel)
  (setf cffi-grovel::*cc* "mpicc"))

before defsystem

EDIT: Whoops, it's cffi that generates the bad include :( which looks like this:

#include </usr/include/mpi/mpi.h>

instead of:

#include "mpi.h"

Is there any way to do something about it?


Applying lots of hackery and trickery I could get it working. It appears that the path to the library was set in the code itself, so I had to

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :cffi-grovel)
  (setf cffi-grovel::*cc* "mpicc"
        mpi::*mpi-header-file* "/usr/include/mpich-x86_64/mpi.h"))

I also had to make several changes particular to my system to compile the whole thing.

But, I would like this question to be answered in general, if possible! I.e., what is the way to set the C compiler and its options in a generic and acceptable way?

4

1 回答 1

1

cl-mpi 包含一个名为“cl-mpi-configure.lisp”的文件。该文件看起来像是要更改为配置 cl-mpi 以使用正确的系统路径。

特别是这一行:

(defvar *mpi-header-file* "/usr/include/mpi/mpi.h") ; this is where  ubuntu apt-get install puts mpi.h. 

定义 mpi 头文件的路径。您需要更改此行以在系统上使用 mpi.h 的路径。这有点烦人,因为您不需要使用本地版本,而不是直接从 quicklisp 下载。

或者,您可以制作一个补丁来更智能地确定路径(例如使用pkg-config),并将其提交到上游。

于 2015-04-19T01:58:34.137 回答