Extract dummy-ghc, make it cross-aware, and fix plan-nix UnitId stability#2509
Merged
Conversation
…lity
Cabal-install reads `ghc --info` during plan elaboration to decide
per-unit settings (`--enable-shared` vs `--disable-shared`, RTS-way
inclusion, etc.) that feed into the recorded UnitId hash. The
inline `dummy-ghc` script in `lib/call-cabal-project-to-nix.nix`
was a stripped-down stub whose `--info` output didn't match the
real cross GHCs', so plan-nix recorded UnitIds that diverged from
what a downstream cabal v2-build (or any consumer running cabal
against the real compiler) would compute.
Three changes:
1. **`lib/dummy-ghc.nix`** (new): extract the dummy-ghc script and
emit cross-aware `--info` capabilities matching real cross GHCs
for windows, ghcjs, wasm, android, static, native-musl, and
native — `Support dynamic-too`, `Support shared libraries`,
`RTS ways`, `Stage`, `GHC Dynamic`, the iserv-related fields,
etc.
2. **`lib/call-cabal-project-to-nix.nix`**:
* gate the dummy-ghc-pkg `-inplace` suffix on GHC ≥ 9.8 — older
GHCs register pre-existing packages without it, so the dummy
was synthesising the wrong package ids for plan-to-nix
against ghc 8.10 / 9.0 / 9.2 / 9.4 / 9.6.
* pin `CABAL_INSTALLED_PACKAGE_ID_OS` to the build platform's
OS when running plan-to-nix. Without this the patched
cabal-install's installed-package-id format tracks the eval
system; a darwin host evaluating a linux derivation gets the
`VeryShort` form and forks UnitIds from what cabal v2-build
on a linux builder would compute.
3. **`lib/default.nix`**: tighten `uniqueWithNameKey` so
derivations (`.name = "<pkg>-<ver>"`) and module values
(`.identifier.{name,version}`) can't collide on shared name
fragments — partition into `unit-id:` / `id:` / `name:` buckets.
Correctness is unchanged when buckets are correct; this just
avoids the slow `lib.unique` fallback in more cases.
Pulled out of #2504 (`hkm/builder-v2`).
9e27803 to
e2d404b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cabal-install reads
ghc --infoduring plan elaboration to decide per-unit settings (--enable-sharedvs--disable-shared, RTS-way inclusion, etc.) that feed into the recorded UnitId hash. The inlinedummy-ghcinlib/call-cabal-project-to-nix.nixwas a stripped-down stub whose--infooutput didn't match the real cross GHCs', so plan-nix recorded UnitIds that diverged from what a downstream cabal v2-build (or anything running against the real compiler) would compute.Three changes:
lib/dummy-ghc.nix(new) — extract the dummy-ghc script and emit cross-aware--infocapabilities matching real cross GHCs for windows, ghcjs, wasm, android, static, native-musl, and native:Support dynamic-too,Support shared libraries,RTS ways,Stage,GHC Dynamic, iserv-related fields, etc.lib/call-cabal-project-to-nix.nix—-inplacesuffix on GHC ≥ 9.8: older GHCs register pre-existing packages without it.CABAL_INSTALLED_PACKAGE_ID_OSto the build platform's OS when running plan-to-nix. Without this the patched cabal-install's installed-package-id format tracks the eval system; a darwin host evaluating a linux derivation gets theVeryShortform and forks UnitIds.lib/default.nix— tightenuniqueWithNameKeyso derivations (.name = "<pkg>-<ver>") and module values (.identifier.{name,version}) can't collide on shared name fragments — partition intounit-id:/id:/name:buckets.Pulled out of #2504 (
hkm/builder-v2).