-
Notifications
You must be signed in to change notification settings - Fork 847
Description
I want to override default GCC location, which is required in some FFI use-cases. Originally, the discussion was started on haskell-stack mailing group.
Let's use some basic example: https://github.com/kgadek/ffi-stack-test . I want to compile this FFI code that uses C++. The important part: I'm using OS X 10.9 so /usr/bin/gcc is actually clang; I have GCC 5.0 from homebrew in /usr/local/bin/gcc-5.
First: cabal. Only having the repo, cabal build fails the first time and magically works the second — vide: http://lpaste.net/136600 . After some struggling, I finally made it work by adding this in the ~/.cabal/config:
program-locations
gcc-location: /usr/local/bin/gcc-5
The obvious wart is that this is a global setting, but I could live with that.
But how to make that work in stack? The output from stack build:
ffi-stack-test-0.1.0.0: configure
Configuring ffi-stack-test-0.1.0.0...
Setup.hs: Missing dependency on a foreign library:
* Missing (or bad) header file: foo.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
-- While building package ffi-stack-test-0.1.0.0 using:
/Users/konrad/.ghc-current/bin/runhaskell -package=Cabal-1.18.1.5 -clear-package-db -global-package-db -package-db=/Users/konrad/.stack/snapshots/x86_64-osx/lts-2.18/7.8.4/pkgdb/ /var/folders/ht/r6kkmd8s467c4hwqbbpvymxh0000gp/T/stack90764/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.18.1.5/ configure --user --package-db=clear --package-db=global --package-db=/Users/konrad/.stack/snapshots/x86_64-osx/lts-2.18/7.8.4/pkgdb/ --package-db=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/pkgdb/ --constraint=base==4.7.0.2 --libdir=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/lib --bindir=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/bin --datadir=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/share --docdir=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/doc/ffi-stack-test-0.1.0.0 --htmldir=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/doc/ffi-stack-test-0.1.0.0 --haddockdir=/Users/konrad/tmp/ffi-stack-test/.stack-work/install/x86_64-osx/lts-2.18/7.8.4/doc/ffi-stack-test-0.1.0.0
Process exited with code: ExitFailure 1
This is the error I have seen when trying to fix the project for cabal. Verbose output: http://lpaste.net/136624
Is there any workaround before this feature is implemented, except for symlinking /usr/bin/gcc?