New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for environment-configurable toolchains #1662
Conversation
Note than you can use
in |
Great, that is good to know! We have Although I do not see |
Actually, on a second thought... Note that |
Since CPP is invoked by GHC and not Cabal, you need to use GHC's |
So the principle of Cabal knowing about the toolchain is fine. Currently we have a generic mechanism for configuring programs (so you can set where they are, extra flags etc). But this is a totally generic mechanism, it does not know that any of these programs are special in any way. So if you want to set "the linker" then that would currently translate into several things: telling Cabal where ld is, because Cabal invokes ld directly, but then you'd also have to tell Cabal to tell ghc where ld is because it uses it too (usually via gcc). So a toolchain system where we know what the toolchain programs are and that they are special in some way, and then tell other things we call to use them too, that's all good. On this specific patch: we don't want to use env vars in general. We have mechanism for configuring cabal, with config files etc. The one exception is we do have a single env var for specifying which config file to use. But I don't think we want a proliferation of env vars, it makes it very hard to work out where things are coming from if you're trying to debug it. |
Oh, but the env vars in the bootstrap is fine. |
Ok, looking at the patch more closely, I don't think we want to go that way. We already have mechanism for configuring. Perhaps the right solution here is system-global config, so per-user configs can inherit from some system defaults set by the distro. That would be a reasonable way to go. There's two approaches there: explicit includes, where e.g. the default per-user config explicitly asks for /etc/cabal/config, or implicit. I'd prefer explicit if we can make that work. It'd be a useful general mechanism, and easier to see what's going on. |
Merged the @pgj Thanks for the contribution! |
I accept your comments Duncan, but I think you missed this comment of mine: Note that Cabal is also used by GHC where there is no such fancy config file to set the program locations. For that reason, I also had to patch the Cabal library shipped with GHC to make it work with GCC 4.6. I am open to any other solution, but currently the environment variables are needed in order to make GHC build itself on a system where there is no |
Okay, just for the record: I have verified my claims, and it turned out I was wrong, GHC can be built without the referenced changes. I will not have to change neither |
Both
Cabal
andcabal-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 asgcc46
for GCC 4.6 (orclang34
for Clang 3.4) and so on -- basically, where setting thePATH
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
andLD
forCabal
. (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 forcabal-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.