haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
198 stars 50 forks source link

Determining the cpp to use in the test suite #162

Closed acowley closed 6 years ago

acowley commented 8 years ago

I'm trying to resolve the fact that the test suite fails on OS X using the Nix package manager. In looking into this, I came across this bit of code in Config.hs

cpp :: FilePath
cpp  = case os of
  "darwin" -> "gcc"
  _        -> "cpp"

The failure with Nix is due to an assumption of gcc somewhere, while clang is the system C compiler and gcc is actually unavailable in minimal build environments (which Nix users are big fans of). I'm not sure if this instance in the code is the problem, but it is at least a lurking problem.

I'm happy to fix this, but I don't know what the best strategy is. Using the gcc executable on darwin is probably a reasonable option for most people, but I need a way to override this. We could do this with some CPP or a cabal flag, for example.

I expect gcc works on darwin due to the way flags are interpreted, while the cpp executable provided by clang may require different options. But, in any case, some more flexible control over what executable to invoke would help.

/cc @peti

peti commented 8 years ago

Does the Setup.hs file not honor a --with-cpp flag during configure? If it does not, then that would surely be a bug.