I'm building a software that needs nvcc
for compilation. I don't have a CUDA-capable GPU, but actually I don't need that – a friend is building the exact same software on Linux, he has no CUDA GPU, but everything's fine.
I installed the newest CUDA toolkit from https://developer.nvidia.com/cuda-downloads (cuda_6.5.14_mac_64.pkg
) without an issue. But as I was building the software I got into problems.
I was able to reproduce the issue on the smaller scale:
$ 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
With the trace in hand, I was able to go deeper into the rabbit hole:
$ /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)
I have no idea how to fix that. By the way, both clang
and gcc
are okay with passing macros with arguments via -D
.
Probably relevant:
$ 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.
I have Intel Iris Pro 5100 (mbp retina 15" late 2013).