haskell/cabal — pull request #1662 by pgj (2014-01-31 18:04:13+00:00)
Title: Support for environment-configurable toolchains

Both `Cabal` and `cabal-install` is currently lacking support for setting what C compiler, linker or C preprocessor to use. However, on systems like FreeBSD, one may want to specify which binaries to use at the various stages. Like one can install different versions of the GCC (such as 4.6, 4.7, and 4.8) that may even co-exist on the same system (not talking about Clang). Hence each version is identified by a version-specific suffix, such as `gcc46` for GCC 4.6 (or `clang34` for Clang 3.4) and so on -- basically, where setting the `PATH` would not really help.

I tried to work this problem around by implementing support for specifying the toolchain components from environment variables, such as `CC` and `LD` for `Cabal`. (Note that I have been using those patches for a while now in the FreeBSD Ports Collection.) I also met a similar problem in the bootstrap script for `cabal-install`, so I also changed it to make this possible there too.

I am aware that `cabal-install` supports `--with-gcc` and `--with-ld` flags but I felt it tedious to set them every time when I want to install something.