# 検証用に強制インストールオプションつけただけ
$ cabal install --reinstall --force-reinstalls text -v3
…
*** C pre-processor:
'/usr/bin/gcc' '-E' '-undef' '-traditional' '-m64' '-fno-stack-protector' '-m64' '-I' 'dist/build' '-I' 'dist/build/autogen' '-I' 'dist/build' '-I' '/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/bytestring-0.10.0.2/include' '-I' '/usr/local/Ce
llar/ghc/7.6.3/lib/ghc-7.6.3/base-4.6.0.1/include' '-I' '/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include' '-D__GLASGOW_HASKELL__=706' '-Ddarwin_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Ddarwin_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' '-U __PIC__'
'-D__PIC__' '-DHAVE_DEEPSEQ' '-DINTEGER_GMP' '-include' 'dist/build/autogen/cabal_macros.h' '-x' 'c' './Data/Text.hs' '-o' '/var/folders/_n/g5d3dg1s0rx7sc0vq5lxbgyr0000gn/T/ghc79084_0/ghc79084_0.hscpp'
…
Data/Text.hs:1059:4:
error: invalid preprocessing directive
#-}
…
fatal error: too many errors emitted, stopping now [-ferror-limit=]
27 warnings and 20 errors generated.
*** Deleting temp files:
Deleting: /var/folders/_n/g5d3dg1s0rx7sc0vq5lxbgyr0000gn/T/ghc79084_0/ghc79084_0.hscpp
Warning: deleting non-existent /var/folders/_n/g5d3dg1s0rx7sc0vq5lxbgyr0000gn/T/ghc79084_0/ghc79084_0.hscpp
*** Deleting temp dirs:
Deleting: /var/folders/_n/g5d3dg1s0rx7sc0vq5lxbgyr0000gn/T/ghc79084_0
/usr/local/bin/ghc returned ExitFailure 1
Failed to install text-0.11.3.1
World file is already up to date.
cabal: Error: some packages failed to install:
text-0.11.3.1 failed during the building phase. The exception was:
ExitFailure 1
$ ghc --info
[("Project name","The Glorious Glasgow Haskell Compilation System")
,("GCC extra via C opts"," -fwrapv")
,("C compiler command","/usr/bin/gcc")
...
/usr/bin/gcc
の実体はclang
$ /usr/bin/gcc -v
Configured with: --prefix=/Applications/Xcode5.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
とりえあずgcc入れる
brew tap homebrew/versions
brew install gcc49
オプションで渡してみる
cabal install --reinstall --force-reinstalls text -v3 --with-gcc=/usr/local/bin/gcc-4.9
…
*** C pre-processor:
'/usr/bin/gcc' '-E' '-undef' '-traditional' '-m64' '-fno-stack-protector' '-m64' '-I' 'dist/build' '-I' 'dist/build/autogen' '-I' 'dist/build' '-I' '/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/bytestring-0.10.0.2/include' '-I' '/usr/local/Ce
llar/ghc/7.6.3/lib/ghc-7.6.3/base-4.6.0.1/include' '-I' '/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include' '-D__GLASGOW_HASKELL__=706' '-Ddarwin_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Ddarwin_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' '-U __PIC__'
'-D__PIC__' '-DHAVE_DEEPSEQ' '-DINTEGER_GMP' '-include' 'dist/build/autogen/cabal_macros.h' '-x' 'c' './Data/Text.hs' '-o' '/var/folders/_n/g5d3dg1s0rx7sc0vq5lxbgyr0000gn/T/ghc79156_0/ghc79156_0.hscpp'
かわってない……
$ vi /usr/local/opt/ghc/lib/ghc-7.6.3/settings
で直接"C compiler command"を書き換えるとビルドはできる
$ cabal install --reinstall --force-reinstalls text
...
Registering text-0.11.3.1...
("/usr/local/bin/ghc-pkg",["update","-","--global","--user","-v2"])
Installed text-0.11.3.1
World file is already up to date.
があんまりお作法がよくない。
知りたいこと
ユーザー設定でcabal-installのghcオプションで設定済みのCコンパイラの切り替え方・その設定