Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

cabal install cabal-install fails if gcc not in /Developer/usr/bin/gcc #886

Closed
bos opened this Issue · 5 comments

1 participant

@bos
Owner

(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
Resolving dependencies...
Configuring cabal-install-0.10.2...
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:
ExitFailure 1
$ cabal --version
cabal-install version 0.8.0
using version 1.8.0.2 of the Cabal library
$ which gcc
/usr/bin/gcc
$ which clang
/usr/bin/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
@bos
Owner

(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.

@bos
Owner

(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

--with-gcc /Xcode_4_2/usr/bin/clang

instead of

--with-gcc=/Xcode_4_2/usr/bin/clang

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.

@bos
Owner

(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?

@bos
Owner

(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:

#!/bin/sh
exedir="/Library/Frameworks/GHC.framework/Versions/7.0.4-i386/usr/lib/ghc-7.0.4"
exeprog="ghc-stage2"
executablename="$exedir/$exeprog"
datadir="/Library/Frameworks/GHC.framework/Versions/7.0.4-i386/usr/share"
bindir="/Library/Frameworks/GHC.framework/Versions/7.0.4-i386/usr/bin"
topdir="/Library/Frameworks/GHC.framework/Versions/7.0.4-i386/usr/lib/ghc-7.0.4"
pgmgcc="/Developer/usr/bin/gcc"
executablename="$exedir/ghc"
exec "$executablename" -B"$topdir" -pgmc "$pgmgcc" -pgma "$pgmgcc"
-pgml "$pgmgcc" -pgmP "$pgmgcc -E -undef -traditional"
-optl"-Wl,-read_only_relocs,suppress" ${1+"$@"}
The line which defines pgmgcc contains the reference to /Developer.
However, XCode doesn't install there anymore since version 4. See also
haskell platform ticket 163 at http://trac.haskell.org/haskell-platform/ticket/163

@bos
Owner

(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.

@bos bos closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.