Skip to content

Commit 8eb3f36

Browse files
authored
Add ghc980 and ghc99 (#2016)
Built using the `ghc-9.8` and `master` branch of ghc as flake inputs.
1 parent f398fc5 commit 8eb3f36

File tree

151 files changed

+15538
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+15538
-287
lines changed

build.nix

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ in rec {
4343
"ghc8107" = "3.4.1";
4444
}.${compiler-nix-name} or "latest";
4545
};
46-
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.6" < 0) {
46+
} // pkgs.lib.optionalAttrs (
47+
__compareVersions haskell.compiler.${compiler-nix-name}.version "9.2" >= 0
48+
&& __compareVersions haskell.compiler.${compiler-nix-name}.version "9.6" < 0) {
4749
stack =
4850
tool compiler-nix-name "stack" {
49-
version =
50-
if __compareVersions haskell.compiler.${compiler-nix-name}.version "9.2" < 0
51-
then "2.9.3.1"
52-
else "2.11.1";
51+
version = "2.11.1";
5352
inherit evalPackages;
5453
};
5554
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.6" < 0) {
@@ -78,17 +77,15 @@ in rec {
7877
update-hackage = import ./scripts/update-hackage.nix {
7978
inherit (pkgs) stdenv lib writeScript coreutils glibc git
8079
openssh nixFlakes gawk bash curl findutils;
81-
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
80+
# Update scripts use the internal nix-tools (compiled with a fixed GHC version)
8281
nix-tools = haskell.nix-tools-unchecked;
83-
cabal-install = haskell.internal-cabal-install;
8482
inherit (haskell) update-index-state-hashes cabal-issue-8352-workaround;
8583
};
8684
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {
8785
inherit (pkgs) stdenv lib writeScript coreutils glibc git
8886
openssh nixFlakes gawk bash curl findutils;
89-
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
87+
# Update scripts use the internal nix-tools (compiled with a fixed GHC version)
9088
nix-tools = haskell.nix-tools-unchecked;
91-
cabal-install = haskell.internal-cabal-install;
9289
inherit (haskell) cabal-issue-8352-workaround;
9390
};
9491
update-pins = haskell.callPackage ./scripts/update-pins.nix {};

builder/comp-builder.nix

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ let self =
3939

4040
, dontPatchELF ? component.dontPatchELF
4141
, dontStrip ? component.dontStrip
42+
, dontUpdateAutotoolsGnuConfigScripts ? component.dontUpdateAutotoolsGnuConfigScripts
4243
, hardeningDisable ? component.hardeningDisable
4344

4445
, enableStatic ? component.enableStatic
@@ -187,15 +188,23 @@ let
187188
"--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
188189
"--with-strip=${stdenv.cc.bintools.targetPrefix}strip"
189190
]
190-
) ++ [ # other flags
191+
) # Starting with ghc 9.10 the `ld command` will no longer be in the GHC `settings` file.
192+
# We need to start passing it explicitly to setup like we do for `ar` and `strip`.
193+
++ lib.optional (!stdenv.hostPlatform.isGhcjs && builtins.compareVersions defaults.ghc.version "9.8" >= 0)
194+
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
195+
++ lib.optionals (stdenv.hostPlatform.isGhcjs) [
196+
"--with-gcc=${buildPackages.emscripten}/bin/emcc"
197+
"--with-ld=${buildPackages.emscripten}/bin/emcc"
198+
]
199+
++ [ # other flags
191200
(disableFeature dontStrip "executable-stripping")
192201
(disableFeature dontStrip "library-stripping")
193202
(enableFeature enableLibraryProfiling "library-profiling")
194203
(enableFeature enableProfiling "profiling")
195204
(enableFeature enableStatic "static")
196205
(enableFeature enableShared "shared")
197206
(enableFeature doCoverage "coverage")
198-
(enableFeature enableLibraryForGhci "library-for-ghci")
207+
(enableFeature (enableLibraryForGhci && !stdenv.hostPlatform.isGhcjs) "library-for-ghci")
199208
] ++ lib.optionals (stdenv.hostPlatform.isMusl && (haskellLib.isExecutableType componentId)) [
200209
# These flags will make sure the resulting executable is statically linked.
201210
# If it uses other libraries it may be necessary for to add more
@@ -222,7 +231,7 @@ let
222231
++ lib.optionals useLLVM [
223232
"--ghc-option=-fPIC" "--gcc-option=-fPIC"
224233
]
225-
++ map (o: ''--ghc${lib.optionalString stdenv.hostPlatform.isGhcjs "js"}-options="${o}"'') ghcOptions
234+
++ map (o: ''--ghc${lib.optionalString (stdenv.hostPlatform.isGhcjs && builtins.compareVersions defaults.ghc.version "9" < 0) "js"}-options="${o}"'') ghcOptions
226235
++ lib.optional (
227236
# GHC 9.2 cross compiler built with older versions of GHC seem to have problems
228237
# with unique conters. Perhaps because the name changed for the counters.
@@ -260,8 +269,9 @@ let
260269
if builtins.isFunction shellHook then shellHook { inherit package shellWrappers; }
261270
else abort "shellHook should be a string or a function";
262271

263-
exeExt = if stdenv.hostPlatform.isGhcjs then ".jsexe/all.js" else
264-
stdenv.hostPlatform.extensions.executable;
272+
exeExt = if stdenv.hostPlatform.isGhcjs && builtins.compareVersions defaults.ghc.version "9.8" < 0
273+
then ".jsexe/all.js"
274+
else stdenv.hostPlatform.extensions.executable;
265275
exeName = componentId.cname + exeExt;
266276
testExecutable = "dist/build/${componentId.cname}/${exeName}";
267277

@@ -317,6 +327,9 @@ let
317327
// lib.optionalAttrs stdenv.hostPlatform.isMusl {
318328
# This fixes musl compilation of TH code that depends on C++ (for instance TH code that uses the double-conversion package)
319329
LD_LIBRARY_PATH="${pkgs.buildPackages.gcc-unwrapped.lib}/x86_64-unknown-linux-musl/lib";
330+
}
331+
// lib.optionalAttrs dontUpdateAutotoolsGnuConfigScripts {
332+
inherit dontUpdateAutotoolsGnuConfigScripts;
320333
};
321334

322335
haddock = haddockBuilder {
@@ -531,7 +544,7 @@ let
531544
# we assume that if the SETUP_HS command fails and the following line was found in the error
532545
# log, that it was the only error. Hence if we do _not_ find the line, grep will fail and this derivation
533546
# will be marked as failure.
534-
cat $SETUP_ERR | grep 'Error: Setup: No executables and no library found\. Nothing to do\.'
547+
cat $SETUP_ERR | grep 'No executables and no library found\. Nothing to do\.'
535548
fi
536549
''}
537550
${lib.optionalString (haskellLib.isLibrary componentId) ''
@@ -583,13 +596,13 @@ let
583596
'')
584597
}
585598
''}
586-
${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId) ''
599+
${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || (haskellLib.isExe componentId && stdenv.hostPlatform.isGhcjs)) ''
587600
mkdir -p $out/bin
588601
if [ -f ${testExecutable} ]; then
589602
mkdir -p $(dirname $out/bin/${exeName})
590603
${lib.optionalString stdenv.buildPlatform.isLinux "sync"}
591-
${if stdenv.hostPlatform.isGhcjs then ''
592-
cat <(echo \#!${lib.getBin buildPackages.nodejs-18_x}/bin/node) ${testExecutable} >| $out/bin/${exeName}
604+
${if stdenv.hostPlatform.isGhcjs && builtins.compareVersions defaults.ghc.version "9.8" < 0 then ''
605+
cat <(echo \#!/usr/bin/env node) ${testExecutable} >| $out/bin/${exeName}
593606
chmod +x $out/bin/${exeName}
594607
'' else ''
595608
cp -r ${testExecutable} $(dirname $out/bin/${exeName})

ci.nix

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"unstable" = inputs.nixpkgs-unstable;
2525
};
2626

27+
ghc980X = pkgs: "ghc980${__substring 0 8 pkgs.haskell-nix.sources.ghc980.lastModifiedDate}";
28+
ghc99X = pkgs: "ghc99${__substring 0 8 pkgs.haskell-nix.sources.ghc99.lastModifiedDate}";
29+
2730
nixpkgsArgs = {
2831
# set checkMaterialization as per top-level argument
2932
overlays = [
@@ -49,15 +52,15 @@
4952
nixpkgs.lib.filterAttrs (compiler-nix-name: _:
5053
# We have less x86_64-darwin build capacity so build fewer GhC versions
5154
(system != "x86_64-darwin" || (
52-
!__elem compiler-nix-name ["ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]))
55+
!builtins.elem compiler-nix-name ["ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]))
5356
&&
5457
# aarch64-darwin requires ghc 8.10.7
5558
(system != "aarch64-darwin" || (
56-
!__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]))
59+
!builtins.elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]))
5760
&&
5861
# aarch64-linux requires ghc 8.8.4
5962
(system != "aarch64-linux" || (
60-
!__elem compiler-nix-name ["ghc865" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]
63+
!builtins.elem compiler-nix-name ["ghc865" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]
6164
)))
6265
(builtins.mapAttrs (compiler-nix-name: runTests: {
6366
inherit runTests;
@@ -87,30 +90,32 @@
8790
ghc947 = true;
8891
ghc962 = true;
8992
ghc9820230704 = true;
93+
${ghc980X nixpkgs} = true;
94+
${ghc99X nixpkgs} = true;
9095
}));
9196
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
9297
# We need to use the actual nixpkgs version we're working with here, since the values
9398
# of 'lib.systems.examples' are not understood between all versions
9499
let lib = nixpkgs.lib;
95100
in lib.optionalAttrs (nixpkgsName == "unstable"
96-
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
97-
|| (system == "aarch64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
98-
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
99-
|| (system == "aarch64-darwin" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
101+
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" (ghc980X nixpkgs) (ghc99X nixpkgs)])
102+
|| (system == "aarch64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" (ghc980X nixpkgs) (ghc99X nixpkgs)])
103+
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" (ghc980X nixpkgs) (ghc99X nixpkgs)])
104+
|| (system == "aarch64-darwin" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" (ghc980X nixpkgs) (ghc99X nixpkgs)])
100105
)) {
101106
inherit (lib.systems.examples) ghcjs;
102107
} // lib.optionalAttrs (nixpkgsName == "unstable"
103-
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"])
108+
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" (ghc980X nixpkgs) (ghc980X nixpkgs)])
104109
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
105110
inherit (lib.systems.examples) mingwW64;
106-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"]) {
111+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" (ghc980X nixpkgs) (ghc980X nixpkgs)]) {
107112
# Musl cross only works on linux
108113
# aarch64 cross only works on linux
109114
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
110115
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc927" "ghc928"]) {
111116
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
112117
inherit (lib.systems.examples) aarch64-multiplatform-musl;
113-
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"]) {
118+
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc927" "ghc928" "ghc947" "ghc962" (ghc980X nixpkgs) (ghc980X nixpkgs)]) {
114119
inherit (lib.systems.examples) aarch64-multiplatform-musl;
115120
};
116121
isDisabled = d: d.meta.disabled or false;

compiler/ghc/default.nix

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ let self =
7272

7373
, ghc-version ? src-spec.version
7474
, ghc-version-date ? null
75+
, ghc-commit-id ? null
7576
, src-spec
7677
, ghc-patches ? []
7778

@@ -239,18 +240,25 @@ let
239240
# value for us.
240241
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || stdenv.targetPlatform.isMusl);
241242

242-
hadrian = buildPackages.pinned-haskell-nix.tool "ghc8107" "hadrian" {
243+
hadrian =
244+
let
245+
compiler-nix-name = if buildPackages.haskell.compiler ? "ghc928"
246+
then "ghc928"
247+
else "ghc8107";
248+
in buildPackages.pinned-haskell-nix.tool compiler-nix-name "hadrian" {
243249
compilerSelection = p: p.haskell.compiler;
244250
index-state = buildPackages.haskell-nix.internalHackageIndexState;
245251
# Verions of hadrian that comes with 9.6 depends on `time`
246252
materialized =
247253
if builtins.compareVersions ghc-version "9.4" < 0
248-
then ../../materialized/ghc8107/hadrian-ghc92
254+
then ../../materialized/${compiler-nix-name}/hadrian-ghc92
249255
else if builtins.compareVersions ghc-version "9.6" < 0
250-
then ../../materialized/ghc8107/hadrian-ghc94
256+
then ../../materialized/${compiler-nix-name}/hadrian-ghc94
251257
else if builtins.compareVersions ghc-version "9.8" < 0
252-
then ../../materialized/ghc8107/hadrian-ghc96
253-
else ../../materialized/ghc8107/hadrian-ghc98;
258+
then ../../materialized/${compiler-nix-name}/hadrian-ghc96
259+
else if builtins.compareVersions ghc-version "9.9" < 0
260+
then ../../materialized/${compiler-nix-name}/hadrian-ghc98
261+
else ../../materialized/${compiler-nix-name}/hadrian-ghc99;
254262
modules = [{
255263
# Apply the patches in a way that does not require using something
256264
# like `srcOnly`. The problem with `pkgs.srcOnly` was that it had to run
@@ -263,10 +271,6 @@ let
263271
cd hadrian
264272
'';
265273
}];
266-
cabalProject = ''
267-
packages:
268-
.
269-
'';
270274
cabalProjectLocal = null;
271275
cabalProjectFreeze = null;
272276
src = haskell-nix.haskellLib.cleanSourceWith {
@@ -278,6 +282,7 @@ let
278282
filterPath = { path, ... }: path;
279283
};
280284
subDir = "hadrian";
285+
includeSiblings = true;
281286
};
282287
};
283288

@@ -372,6 +377,7 @@ stdenv.mkDerivation (rec {
372377
export CC="${targetCC}/bin/emcc"
373378
export CXX="${targetCC}/bin/em++"
374379
export LD="${targetCC}/bin/emcc"
380+
export NM="${targetCC}/share/emscripten/emnm"
375381
export EM_CACHE=$(mktemp -d)
376382
mv config.sub.ghcjs config.sub
377383
''
@@ -434,9 +440,11 @@ stdenv.mkDerivation (rec {
434440
'' + lib.optionalString (ghc-version-date != null) ''
435441
substituteInPlace configure --replace 'RELEASE=YES' 'RELEASE=NO'
436442
echo '${ghc-version-date}' > VERSION_DATE
443+
'' + lib.optionalString (ghc-commit-id != null) ''
444+
echo '${ghc-commit-id}' > GIT_COMMIT_ID
437445
''
438446
# The official ghc 9.2.3 tarball requires booting.
439-
+ lib.optionalString (ghc-version == "9.2.3" || ghc-version == "9.8.20230704") ''
447+
+ lib.optionalString (ghc-version == "9.2.3" || ghc-version == "9.8.20230704" || src-spec.needsBooting or false) ''
440448
python3 ./boot
441449
'';
442450

@@ -644,7 +652,7 @@ stdenv.mkDerivation (rec {
644652
for a in libraries/*/*.cabal.in utils/*/*.cabal.in compiler/ghc.cabal.in; do
645653
${hadrian}/bin/hadrian ${hadrianArgs} "''${a%.*}"
646654
done
647-
'' + lib.optionalString (builtins.compareVersions ghc-version "9.8.1" >= 0) ''
655+
'' + lib.optionalString (ghc-version == "9.8.20230704") ''
648656
for a in bytearray-access-ops.txt.pp addr-access-ops.txt.pp primops.txt; do
649657
${hadrian}/bin/hadrian ${hadrianArgs} _build/stage0/compiler/build/$a
650658
cp _build/stage0/compiler/build/$a compiler/GHC/Builtin/$a

flake.lock

Lines changed: 43 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
nixpkgs-2211 = { url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin"; };
1111
nixpkgs-2305 = { url = "github:NixOS/nixpkgs/nixpkgs-23.05-darwin"; };
1212
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
13+
ghc980 = {
14+
flake = false;
15+
url = "git+https://gitlab.haskell.org/ghc/ghc?ref=ghc-9.8&submodules=1";
16+
};
17+
ghc99 = {
18+
flake = false;
19+
url = "git+https://gitlab.haskell.org/ghc/ghc?submodules=1";
20+
};
1321
flake-compat = { url = "github:input-output-hk/flake-compat/hkm/gitlab-fix"; flake = false; };
1422
"hls-1.10" = { url = "github:haskell/haskell-language-server/1.10.0.0"; flake = false; };
1523
"hls-2.0" = { url = "github:haskell/haskell-language-server/2.0.0.1"; flake = false; };

lib/call-cabal-project-to-nix.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
, cabalProjectFileName ? "cabal.project"
1212
, cabalProject ? null
1313
, cabalProjectLocal ? null
14+
, cabalProjectDefaults ? null
1415
, cabalProjectFreeze ? null
1516
, caller ? "callCabalProjectToNix" # Name of the calling function for better warning messages
1617
, compilerSelection ? p: p.haskell-nix.compiler
@@ -138,6 +139,10 @@ in let
138139
-- Added from `cabalProjectLocal` argument to the `cabalProject` function
139140
${cabalProjectLocal}
140141
''
142+
+ pkgs.lib.optionalString (cabalProjectDefaults != null) ''
143+
-- Added from `cabalProjectDefaults` argument to the `cabalProject` function
144+
${cabalProjectDefaults}
145+
''
141146
}
142147
'';
143148

0 commit comments

Comments
 (0)