Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
stdenv, haskell: bonafied GHCJS cross compilation without stdenv.cc #74090
Motivation for this change
This commit allows treating GHCJS builds as cross compilation. This is useful for a number of correctness reasons, chiefly getting the right build-time
There is some trickiness to get this to work however. Read the first commit for details. In short, as usual, dependency "splicing" is a terrible idea but one with no better alternative that isn't a huge refactor.
I was very careful to break any interfaces with this e.g. existing native and cross platforms will have the same hashes, and whether
Before, we'd always use `cc = null`, and check for that. The problem is this breaks for cross compilation to platforms that don't support a C compiler. It's a very subtle issue. One might think there is no problem because we have `stdenvNoCC`, and presumably one would only build derivations that use that. The problem is that one still wants to use tools at build-time that are themselves built with a C compiler, and those are gotten via "splicing". The runtime version of those deps will explode, but the build time / `buildPackages` versions of those deps will be fine, and splicing attempts to work this by using `builtins.tryEval` to filter out any broken "higher priority" packages (runtime is the default and highest priority) so that both `foo` and `foo.nativeDrv` works. However, `tryEval` only catches certain evaluation failures (e.g. exceptions), and not arbitrary failures (such as `cc.attr` when `cc` is null). This means `tryEval` fails to let us use our build time deps, and everything comes apart. The right solution is, as usually, to get rid of splicing. Or, baring that, to make it so `foo` never works and one has to explicitly do `foo.*`. But that is a much larger change, and certaily one unsuitable to be backported to stable. Given that, we instead make an exception-throwing `cc` attribute, and create a `hasCC` attribute for those derivations which wish to condtionally use a C compiler: instead of doing `stdenv.cc or null == null` or something similar, one does `stdenv.hasCC`. This allows quering without "tripping" the exception, while also allowing `tryEval` to work. No platform without a C compiler is yet wired up by default. That will be done in a following commit.
This platform doesn't have a C compiler, and so relies and the changes in the previous commit to work.
This is a bit dubvious, but the alternative of making nodejs a nativeBuildInput for node packages is worse. In general the cross story for interpreted languages is murky, and this fits that pattern.