Nvcc + c2hs on OS X 10.9.5

I am creating software that requires nvcc to compile. I don’t have a GPU with CUDA support, but I don’t really need it - a friend builds the same software on Linux, he doesn’t have a CUDA GPU, but everything is fine.

I installed the latest CUDA toolkit from https://developer.nvidia.com/cuda-downloads ( cuda_6.5.14_mac_64.pkg ) without any problems. But when I built the software, I had problems.

I was able to reproduce the problem on a 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 -xc -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 a trace in my hand, I was able to penetrate deeper into the hole of the rabbit:

 $ /Developer/NVIDIA/CUDA-6.5/bin/nvcc -E -xc -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 -xc -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 -xc -D 'C2HS_MIN_VERSION(mj,mn,rv)=(mj<=0&&mn<=18&&rv<=2)' Device.chs.h (same issue) 

I do not know how to fix this. By the way, both clang and gcc are fine with passing macros with arguments through -D .

Perhaps 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 an Intel Iris Pro 5100 (mbp retina 15 "at the end of 2013).

+6
source share
1 answer

According to https://github.com/haskell/c2hs/issues/111 , on November 21, the change was ported to c2hs HEAD to work around the issue that caused the top quirk in nvcc. So at this stage, using the latest c2hs should really work.

+2
source

Source: https://habr.com/ru/post/976068/


All Articles