OS X 10.9.5 上的 nvcc + c2hs
Posted
技术标签:
【中文标题】OS X 10.9.5 上的 nvcc + c2hs【英文标题】:nvcc + c2hs on OS X 10.9.5 【发布时间】:2014-11-25 09:05:45 【问题描述】:我正在构建一个软件,它需要nvcc
进行编译。我没有支持 CUDA 的 GPU,但实际上我不需要它 - 一位朋友正在 Linux 上构建完全相同的软件,他没有 CUDA GPU,但一切都很好。 p>
我从https://developer.nvidia.com/cuda-downloads (cuda_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)
我不知道如何解决这个问题。顺便说一句,clang
和 gcc
都可以通过 -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" 2013 年末)。
【问题讨论】:
以前从未使用过 zsh,会不会是它以某种意想不到的方式扩展(?)您的命令行?即,mn,
部分似乎消失了。也许尝试在您的命令前添加noglob
?
已经试过了,用了sh
,可惜结果一模一样。
【参考方案1】:
根据https://github.com/haskell/c2hs/issues/111,在 11 月 21 日,一个更改被推送到c2hs
HEAD 以解决这个问题,这是由 nvcc 中的上游怪癖引起的。所以在这一点上,使用最新的c2hs
确实可以工作。
【讨论】:
谢谢,我会尽快重试的!以上是关于OS X 10.9.5 上的 nvcc + c2hs的主要内容,如果未能解决你的问题,请参考以下文章
An update on OS X Code Signing(OS X代码签名)
cuda报错: nvcc fatal : Host compiler targets unsupported OS