OS X 10.9.5上的nvcc + c2hs

时间:2014-09-30 16:38:38

标签: haskell cuda nvidia nvcc c2hs

我正在构建需要nvcc进行编译的软件。我不具备支持CUDA的GPU,但实际上我并不需要它 - 朋友正在Linux上构建完全相同的软件,他没有CUDA GPU,但是一切都是& #39;很好。

我从https://developer.nvidia.com/cuda-downloadscuda_6.5.14_mac_64.pkg)安装了最新的CUDA工具包而没有任何问题。但是当我构建软件时,我遇到了问题。

我能够以较小的规模重现这个问题:

$ mkdir temp; cd temp; cabal sandbox init


$ cabal get cuda
Unpacking to cuda-0.6.5.0/


$ cd cuda-0.6.5.0/Foreign/CUDA/Analysis


$ c2hs -d trace --cpp=/Developer/NVIDIA/CUDA-6.5/bin/nvcc --cppopts=-ccbin --cppopts=/usr/bin/clang --cppopts=-Xcompiler --cppopts=--stdlib=libstdc++ Device.chs
Attempting to read file `Device.chs'...
...parsing `Device'...
...successfully loaded `Device'.
Invoking cpp as `/Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -x c -ccbin /usr/bin/clang -Xcompiler --stdlib=libstdc++ -U__BLOCKS__ -DC2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2) Device.chs.h'...
In file included from <built-in>:170:
<command line>:3:29: error: expected comma in macro parameter list
#define C2HS_MIN_VERSION(mj 1
                            ^
<command line>:5:11: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
#define rv) (mj<=0&&mn<=18&&rv<=2)
          ^
Device.chs.h:1:10: fatal error: 'cbits/stubs.h' file not found
#include "cbits/stubs.h"
         ^
1 warning and 2 errors generated.
c2hs: Error during preprocessing custom header file

随着手中的痕迹,我能够更深入地进入兔子洞:

$ /Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -x c -ccbin /usr/bin/clang -Xcompiler --stdlib=libstdc++ -U__BLOCKS__ -DC2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2) Device.chs.h
zsh: parse error near `)'


$ /Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -x c -ccbin /usr/bin/clang -Xcompiler --stdlib=libstdc++ -U__BLOCKS__ -D'C2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2)' Device.chs.h
# 1 "Device.chs.h"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 170 "<built-in>" 3
# 1 "<command line>" 1
In file included from <built-in>:170:
<command line>:3:29: error: expected comma in macro parameter list
#define C2HS_MIN_VERSION(mj 1
                            ^
<command line>:5:11: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
#define rv) (mj<=0&&mn<=18&&rv<=2)
          ^
# 1 "<built-in>" 2
# 1 "Device.chs.h" 2
Device.chs.h:1:10: fatal error: 'cbits/stubs.h' file not found
#include "cbits/stubs.h"
         ^

1 warning and 2 errors generated.


$ Developer/NVIDIA/CUDA-6.5/bin/nvcc -x c -D 'C2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2)' Device.chs.h
(same issue)

我不知道如何解决这个问题。顺便说一下,clanggcc都可以通过-D传递带有参数的宏。

可能相关:

$ echo $PATH
/Users/konrad/bin:/Users/konrad/.ghc-current/bin:/Users/konrad/.cabal/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Developer/NVIDIA/CUDA-6.5/bin

$ echo $DYLD_LIBRARY_PATH
/Developer/NVIDIA/CUDA-6.5/lib:

$ echo $LD_LIBRARY_PATH
/usr/local/cuda/lib:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3

$ cabal --version
cabal-install version 1.20.0.3
using version 1.20.0.0 of the Cabal library

$ c2hs --version
C->Haskell Compiler, version 0.18.2 The shapeless maps, 31 Oct 2014
  build platform is "x86_64-darwin" <1, True, True, 1>

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

$ gcc-4.9 --version
gcc-4.9 (GCC) 4.9.0 20140411 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我有Intel Iris Pro 5100(mbp retina 15&#34; 2013年末)。

1 个答案:

答案 0 :(得分:2)

根据https://github.com/haskell/c2hs/issues/111,11月21日,一项变更被推到c2hs HEAD处理问题,这是由于nvcc的上游怪癖造成的。所以在这一点上,使用最新的c2hs确实可行。