tmcdonell / cuda

Haskell FFI bindings to CUDA
Other
76 stars 36 forks source link

Build failure w/ cuda-12.2: parsing error in cuda.h #78

Closed leftaroundabout closed 1 month ago

leftaroundabout commented 1 month ago

This is using the unmerged PR version that addresses v0.12.2, but the error is actually the same on the master version.

Ubuntu 22.04, cabal 3.6.2, GHC 9.2.7, c2hs 0.28.8.

Configuring cuda-0.12.2.0...
Found CUDA toolkit at: /usr/local/cuda-12.2 (set CUDA_PATH to override this)
Storing parameters to cuda.buildinfo.generated
Using build information from 'cuda.buildinfo.generated'.
Provide a 'cuda.buildinfo' file to override this behaviour.
Using build information from 'cuda.buildinfo.generated'.
Provide a 'cuda.buildinfo' file to override this behaviour.
Preprocessing library for cuda-0.12.2.0..
c2hs: C header contains errors:

/usr/local/cuda-12.2/include/cuda.h:2930: (column 5) [ERROR]  >>> Syntax error !
  The symbol `_Alignas' does not fit here.

cabal: Failed to build cuda-0.12.2.0

It appears like _Alignas is a macro which is available when compiling with a C compiler, but c2hs is not aware of it.

noahmartinwilliams commented 1 month ago

Yes, that's why I made a modification to the language-c library to handle _Alignas. I did a PR but I don't think the maintainer for that project accepted it yet. You'll need that and a modified version of c2hs which uses it in order to compile cuda-12.2. Sorry, I should have mentioned that.

leftaroundabout commented 1 month ago

@noahmartinwilliams right, https://github.com/visq/language-c/pull/94 seems to fix this issue.

Not completely sure as I'm getting different compilation errors now...

noahmartinwilliams commented 1 month ago

@leftaroundabout , What are the new errors?

leftaroundabout commented 1 month ago

@noahmartinwilliams I think it is completely unrelated to this issue. The error is

undefined symbol: _ZSt7nothrow

This happens specifically when I'm running Template Haskell splices while depending on cublas (regardless of whether I actually use anything the cublas package exports). It does not seem to happen when I only depend on cuda, nor when compiling a TH-free program with cublas and it certainly hasn't to do with C headers, so I'm closing this here.