Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building requires compiler change on OS X 10.9 #15

Open
acfoltzer opened this issue May 12, 2014 · 5 comments
Open

Building requires compiler change on OS X 10.9 #15

acfoltzer opened this issue May 12, 2014 · 5 comments

Comments

@acfoltzer
Copy link

The default C compiler on newer versions of OS X is clang rather than gcc. Using clang, the bitset installation fails as it can't find the "./gmp.h" include. For now, using cabal install bitset --with-gcc=$MY_GCC works, but it would be nice if the build worked with clang as well. Thanks!

@superbobry
Copy link
Member

Can you please add clang output to the issue? Building bitset seems to work fine for me on OS X 10.9.2 with

$ clang -v
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 7.6.3
$ cabal -V
cabal-install version 1.20.0.1
using version 1.20.0.0 of the Cabal library

@acfoltzer
Copy link
Author

Sure thing, here's the output:

% cabal install bitset --with-gcc=/usr/bin/clang
Resolving dependencies...
Notice: installing into a sandbox located at /private/tmp/.cabal-sandbox
Configuring bitset-1.4.8...
Building bitset-1.4.8...
Failed to install bitset-1.4.8
Last 10 lines of the build log ( /private/tmp/.cabal-sandbox/logs/bitset-1.4.8.log ):
[1 of 1] Compiling Main             ( /var/folders/qk/bpmfcc8s3pq64gs7bn80k60r0000gp/T/bitset-1.4.8-8598/bitset-1.4.8/dist/dist-sandbox-39782a75/setup/setup.hs, /var/folders/qk/bpmfcc8s3pq64gs7bn80k60r0000gp/T/bitset-1.4.8-8598/bitset-1.4.8/dist/dist-sandbox-39782a75/setup/Main.o )
Linking /var/folders/qk/bpmfcc8s3pq64gs7bn80k60r0000gp/T/bitset-1.4.8-8598/bitset-1.4.8/dist/dist-sandbox-39782a75/setup/setup ...
Configuring bitset-1.4.8...
bin/mkDerivedGmpConstants.c:15:10: fatal error: './gmp.h' file not found
#include "./gmp.h"
         ^
1 error generated.
cabal: Error: some packages failed to install:
bitset-1.4.8 failed during the building phase. The exception was:
ExitFailure 1
% /usr/bin/clang --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
% cabal --version
cabal-install version 1.20.0.1
using version 1.20.0.0 of the Cabal library

By default in 10.9, gcc is just an alias for clang, so I point it to a MacPorts-installed gcc instead and everything works.

@superbobry
Copy link
Member

Can you please try building the version from master? It uses system-wide gmp.h, so make sure you have gmp installed before building.

@acfoltzer
Copy link
Author

I expected this to work, so when it did not I dug into how clang looks for includes. When passing --extra-include-dirs=/opt/local/include to cabal, the build still fails, but if I set C_INCLUDE_PATH=/opt/local/include, it works. I suspect then that this is actually a cabal bug in that it is not passing along the custom include path to the underlying C compiler if that compiler happens to be clang. I'll bother them about it; sorry for the trouble!

@creswick
Copy link

FYI: I just ran into this, and the same fix @acfoltzer used worked (on El Capitan, with ghc 7.8.4 and:

 $ cabal --version
cabal-install version 1.22.7.0
using version 1.22.5.0 of the Cabal library

according to cabal ... --verbose=3 ... cabal is passing on the --extra-include-dirs and --extra-lib-dirs flags, but that seems to be insufficient.

It's also possibly worth mentioning that setting the environment variable on the command line works if you're just installing bitset, it does not work if bitset is a dependency of something you're installing, so I'm still stuck, actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants