(Imported from Trac #896, reported by jeremyw.sherman on 2011-10-20)
Under Mac OS X, cabal assumes gcc is at /Developer/usr/bin/gcc. This fails when Xcode is installed to another directory. Xcode has supported installing to an arbitrary folder since at least Xcode 3.x. This is particularly common among iOS developers, as they frequently require multiple parallel Xcode installs.
Since Xcode installs gcc to both $DEVELOPER/usr/bin/gcc and /usr/bin/gcc, this could be fixed by using /usr/bin/gcc directly or the result of a search in $PATH for gcc.
The user workaround for now is to symlink /Xcode_4_2 (or whatever the user's latest Xcode install directory is) to /Developer.
(Apple is moving from gcc to clang, anyway. Apple's gcc has been frozen at an ancient version for some time now.)
Sample session exhibiting this bug:
$ cabal install cabal-install
ghc: could not execute: /Developer/usr/bin/gcc
cabal: Error: some packages failed to install:
cabal-install-0.10.2 failed during the configure step. The exception was:
$ cabal --version
cabal-install version 0.8.0
using version 184.108.40.206 of the Cabal library
$ which gcc
$ which clang
$ ls -l `which gcc`
lrwxr-xr-x 1 root wheel 12 13 Okt 15:37 /usr/bin/gcc@ -> llvm-gcc-4.2
$ ls -l `which clang`
-rwxrwxr-x 1 root admin 41251344 27 Aug 03:53 /usr/bin/clang*
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.3
(Imported comment by @dcoutts on 2011-10-20)
Hmm. Vanilla cabal just looks for gcc on the $PATH. It's plausible this is a customisation by the OSX Haskell Platform package, but if so I wasn't aware and I can't see how it's doing it. You're sure the file /Developer/usr/bin/gcc does not exist? It's odd since if one used --with-gcc=/Developer/usr/bin/gcc then it checks if it exists before it gets round to actually executing it, so we'd get a different error message.
(Imported comment by jeremyw.sherman on 2011-10-23)
I am sure that /Developer/usr/bin/gcc did not exist. I have different versions of Xcode installed in /Xcode_3_2_6 and /Xcode_4_2, but no version installed in /Developer. Just so it would build, I ran sudo ln -s /Xcode_4_2 /Developer, and it successfully built after that.
My PATH does not include any /Developer or /Xcode* directory. I also do not have CC set in my shell environment variables.
I tried using --with-gcc and --with-cc to give it the correct compiler, and it ignored me and tried to use the /Developer one. Based on your comment, the issue there looks to have been that I did not use an equals sign between the option and argument, that is, I wrote
All I can think is that it had to have been somehow hardcoded to look in /Developer, since that's the default install location for Xcode. Xcode also installs the build tools under /usr/bin, no matter what directory Xcode itself was installed to, so that path is more reliable.
(Imported comment by @kosmikus on 2011-10-24)
I made a scan of the Cabal and cabal-install sources and can't find any mention of the /Developer directory anywhere. So I don't know where this assumption is coming from. As Duncan said, by default Cabal just looks for gcc in PATH. Any more information on this bug?
(Imported comment by @kosmikus on 2012-03-03)
Communicated to me by Erik Hesselink:
I think this is a problem with the Mac haskell platform, not with
cabal. The /usr/bin/ghc on the mac is a shell script, which reads:
exec "$executablename" -B"$topdir" -pgmc "$pgmgcc" -pgma "$pgmgcc"
-pgml "$pgmgcc" -pgmP "$pgmgcc -E -undef -traditional"
(Imported comment by @kosmikus on 2012-03-11)
Ok, so I'll work with the assumption that this is a platform bug and close this as "invalid" for cabal-install.