gpt4 book ai didi

haskell - OS X 10.9.5 上的 nvcc + c2hs

转载 作者:行者123 更新时间:2023-12-04 15:43:51 26 4
gpt4 key购买 nike

我正在构建一个需要 nvcc 的软件用于编译。我没有支持 CUDA 的 GPU,但实际上我不需要它——一个 friend 正在 Linux 上构建完全相同的软件,他没有 CUDA GPU,但一切都很好。

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

我能够在较小的范围内重现该问题:

$ 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 视网膜 15"2013 年末)。

最佳答案

根据 https://github.com/haskell/c2hs/issues/111 ,在 11 月 21 日,更改被推送到 c2hs HEAD 来解决这个问题,这是由 nvcc 中的上游怪癖引起的。所以此时,使用最新的c2hs确实应该工作。

关于haskell - OS X 10.9.5 上的 nvcc + c2hs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26125870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com