Skip to content

Commit 7573eb3

Browse files
authored
Fix ghc 9.4.3 TH support (#1814)
1 parent 39cd405 commit 7573eb3

File tree

67 files changed

+4071
-130
lines changed

Some content is hidden

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

67 files changed

+4071
-130
lines changed

build.nix

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ in rec {
2323
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
2424
pkgs.recurseIntoAttrs ({
2525
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
26-
stack = tool compiler-nix-name "stack" { version = "2.9.1"; inherit evalPackages; };
2726
hlint-latest = tool compiler-nix-name "hlint" {
2827
inherit evalPackages;
2928
version = {
@@ -40,7 +39,15 @@ in rec {
4039
"ghc8107" = "3.4.1";
4140
}.${compiler-nix-name} or "latest";
4241
};
43-
hls-latest = tool compiler-nix-name "haskell-language-server" { inherit evalPackages; };
42+
} // pkgs.lib.optionalAttrs (!__elem compiler-nix-name ["ghc941" "ghc942" "ghc943"]) {
43+
stack = tool compiler-nix-name "stack" { version = "2.9.3"; inherit evalPackages; };
44+
hls-latest = tool compiler-nix-name "haskell-language-server" {
45+
inherit evalPackages;
46+
version =
47+
if __compareVersions haskell.compiler.${compiler-nix-name}.version "9.4" < 0
48+
then "1.8.0.0"
49+
else "latest";
50+
};
4451
})
4552
);
4653

builder/comp-builder.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, zlib, ncurses, nodejs }@defaults:
1+
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs }@defaults:
22
lib.makeOverridable (
33
let self =
44
{ componentId
@@ -556,7 +556,10 @@ let
556556
'')
557557
+ (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) (''
558558
echo "Symlink libffi and gmp .dlls ..."
559-
for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
559+
for p in ${lib.concatStringsSep " " ([ libffi gmp ] ++
560+
# Also include C++ and mcfgthreads DLLs for GHC 9.4.1 and newer
561+
lib.optionals (builtins.compareVersions defaults.ghc.version "9.4.1" >= 0)
562+
[ buildPackages.gcc-unwrapped windows.mcfgthreads ])}; do
560563
find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
561564
done
562565
''

ci.nix

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
ghc902 = false;
5757
ghc924 = false;
5858
ghc925 = true;
59+
ghc943 = true;
5960
}));
6061
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
6162
# We need to use the actual nixpkgs version we're working with here, since the values
@@ -66,7 +67,7 @@
6667
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107"]))) {
6768
inherit (lib.systems.examples) ghcjs;
6869
} // lib.optionalAttrs (nixpkgsName == "unstable"
69-
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc925"])
70+
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc925" "ghc943"])
7071
|| (system == "x86_64-darwin" && __elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
7172
inherit (lib.systems.examples) mingwW64;
7273
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc925"]) {
@@ -88,11 +89,11 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
8889
# TODO: can we merge this into the general case by picking an appropriate "cross system" to mean native?
8990
native = pkgs.recurseIntoAttrs ({
9091
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
91-
ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";
92+
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
9293
} // pkgs.lib.optionalAttrs runTests {
9394
inherit (build) tests tools maintainer-scripts maintainer-script-cache;
9495
} // pkgs.lib.optionalAttrs (ifdLevel >= 1) {
95-
iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
96+
inherit (pkgs.haskell-nix.iserv-proxy-exes.${compiler-nix-name}) iserv-proxy;
9697
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
9798
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }).getComponent "exe:hello";
9899
});
@@ -104,19 +105,19 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
104105
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name haskellNix; };
105106
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
106107
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
107-
ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";
108+
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
108109
# TODO: look into cross compiling ghc itself
109-
# ghc = pkgs.haskell-nix.compiler."${compiler-nix-name}";
110+
# ghc = pkgs.haskell-nix.compiler.${compiler-nix-name};
110111
# TODO: look into making tools work when cross compiling
111112
# inherit (build) tools;
112113
} // pkgs.lib.optionalAttrs (runTests && crossSystemName != "aarch64-multiplatform") {
113114
# Tests are broken on aarch64 cross https://github.com/input-output-hk/haskell.nix/issues/513
114115
inherit (build) tests;
115-
}) // pkgs.lib.optionalAttrs (ifdLevel >= 2 && crossSystemName != "ghcjs") {
116-
# GHCJS builds its own template haskell runner.
117-
remote-iserv = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "remote-iserv:exe:remote-iserv";
118-
iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
119-
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
116+
})
117+
# GHCJS builds its own template haskell runner.
118+
// pkgs.lib.optionalAttrs (ifdLevel >= 2 && crossSystemName != "ghcjs")
119+
pkgs.haskell-nix.iserv-proxy-exes.${compiler-nix-name}
120+
// pkgs.lib.optionalAttrs (ifdLevel >= 3) {
120121
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit compiler-nix-name; }).getComponent "exe:hello";
121122
})
122123
))

compiler/ghc/default.nix

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let self =
99
# build-tools
1010
, bootPkgs
1111
, buildPackages
12-
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx, numactl, elfutils
12+
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx, numactl, elfutils, libcxx, libcxxabi
1313
, autoreconfHook
1414
, bash
1515

@@ -172,14 +172,40 @@ let
172172
BUILD_PROF_LIBS = NO
173173
'';
174174

175+
# `--with` flags for libraries needed for RTS linker
176+
configureFlags = [
177+
"--datadir=$doc/share/doc/ghc"
178+
"--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
179+
] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
180+
] ++ lib.optionals (!enableIntegerSimple) [
181+
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
182+
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
183+
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
184+
] ++ lib.optionals (targetPlatform != hostPlatform) [
185+
"--with-iconv-includes=${targetIconv}/include" "--with-iconv-libraries=${targetIconv}/lib"
186+
] ++ lib.optionals (targetPlatform != hostPlatform) [
187+
"--enable-bootstrap-with-devel-snapshot"
188+
] ++ lib.optionals (disableLargeAddressSpace) [
189+
"--disable-large-address-space"
190+
] ++ lib.optionals (targetPlatform.isAarch32) [
191+
"CFLAGS=-fuse-ld=gold"
192+
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
193+
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
194+
] ++ lib.optionals enableDWARF [
195+
"--enable-dwarf-unwind"
196+
"--with-libdw-includes=${lib.getDev elfutils}/include"
197+
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
198+
];
199+
175200
# Splicer will pull out correct variations
176201
libDeps = platform: lib.optional enableTerminfo [ targetPackages.ncurses targetPackages.ncurses.dev ]
177202
++ [targetLibffi]
178203
++ lib.optional (!enableIntegerSimple) gmp
179204
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
180205
++ lib.optional (enableNUMA && platform.isLinux && !platform.isAarch32 && !platform.isAndroid) numactl
181206
# Even with terminfo disabled some older ghc cross arm and windows compilers do not build unless `ncurses` is found and they seem to want the buildPlatform version
182-
++ lib.optional (!enableTerminfo && haskell-nix.haskellLib.isCrossTarget && (stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) && builtins.compareVersions ghc-version "8.10" < 0) ncurses.dev;
207+
++ lib.optional (!enableTerminfo && haskell-nix.haskellLib.isCrossTarget && (stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) && builtins.compareVersions ghc-version "8.10" < 0) ncurses.dev
208+
++ lib.optional enableDWARF (lib.getLib elfutils);
183209

184210
toolsForTarget =
185211
if hostPlatform == buildPlatform then
@@ -232,7 +258,7 @@ stdenv.mkDerivation (rec {
232258
version = ghc-version;
233259
name = "${targetPrefix}ghc-${version}";
234260

235-
inherit src;
261+
inherit src configureFlags;
236262
patches = ghc-patches;
237263

238264
# configure was run by configured-src already.
@@ -308,30 +334,6 @@ stdenv.mkDerivation (rec {
308334
'';
309335

310336
configurePlatforms = [ "build" "host" "target" ];
311-
# `--with` flags for libraries needed for RTS linker
312-
configureFlags = [
313-
"--datadir=$doc/share/doc/ghc"
314-
"--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
315-
] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
316-
] ++ lib.optional (!enableIntegerSimple) [
317-
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
318-
] ++ lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
319-
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
320-
] ++ lib.optional (targetPlatform != hostPlatform) [
321-
"--with-iconv-includes=${targetIconv}/include" "--with-iconv-libraries=${targetIconv}/lib"
322-
] ++ lib.optionals (targetPlatform != hostPlatform) [
323-
"--enable-bootstrap-with-devel-snapshot"
324-
] ++ lib.optionals (disableLargeAddressSpace) [
325-
"--disable-large-address-space"
326-
] ++ lib.optionals (targetPlatform.isAarch32) [
327-
"CFLAGS=-fuse-ld=gold"
328-
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
329-
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
330-
] ++ lib.optionals enableDWARF [
331-
"--enable-dwarf-unwind"
332-
"--with-libdw-includes=${lib.getDev elfutils}/include"
333-
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
334-
];
335337

336338
enableParallelBuilding = true;
337339
postPatch = "patchShebangs .";
@@ -595,8 +597,16 @@ stdenv.mkDerivation (rec {
595597
fi
596598
'';
597599
} // lib.optionalAttrs useHadrian {
600+
postConfigure = lib.optionalString stdenv.isDarwin ''
601+
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
602+
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
603+
find . -name 'system*.conf*'
604+
cat mk/system-cxx-std-lib-1.0.conf
605+
'';
598606
buildPhase = ''
599607
${hadrian}/bin/hadrian ${hadrianArgs}
608+
'' + lib.optionalString installStage1 ''
609+
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:libiserv
600610
'' + lib.optionalString targetPlatform.isMusl ''
601611
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:terminfo
602612
'';
@@ -623,7 +633,19 @@ stdenv.mkDerivation (rec {
623633
--replace ',("windres command", "/bin/false")' ',("windres command", "${targetCC.bintools.targetPrefix}windres")'
624634
''
625635
else ''
626-
${hadrian}/bin/hadrian ${hadrianArgs} install --prefix=$out
636+
${hadrian}/bin/hadrian ${hadrianArgs} binary-dist-dir
637+
cd _build/bindist/ghc-*
638+
./configure --prefix=$out ${lib.concatStringsSep " " configureFlags}
639+
${lib.optionalString stdenv.isDarwin ''
640+
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
641+
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
642+
substituteInPlace lib/package.conf.d/system-cxx-std-lib-1.0.conf \
643+
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
644+
''}
645+
mkdir -p utils
646+
cp -r ../../../utils/completion utils
647+
make install
648+
cd ../../..
627649
runHook postInstall
628650
'';
629651
});

flake.lock

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

flake.nix

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
nixpkgs-2205 = { url = "github:NixOS/nixpkgs/nixpkgs-22.05-darwin"; };
1010
nixpkgs-2211 = { url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin"; };
1111
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
12-
flake-compat = { url = "github:input-output-hk/flake-compat"; flake = false; };
12+
flake-compat = { url = "github:input-output-hk/flake-compat/hkm/gitlab-fix"; flake = false; };
1313
flake-utils = { url = "github:numtide/flake-utils"; };
1414
tullia = {
1515
url = "github:input-output-hk/tullia";
@@ -61,8 +61,8 @@
6161
};
6262
iserv-proxy = {
6363
type = "git";
64-
url = "https://gitlab.haskell.org/ghc/iserv-proxy.git";
65-
rev = "6e95df7be6dd29680f983db07a057fc2f34f81f6";
64+
url = "https://gitlab.haskell.org/hamishmack/iserv-proxy.git";
65+
ref = "hkm/remote-iserv";
6666
flake = false;
6767
};
6868
};
@@ -147,12 +147,15 @@
147147

148148
packages = ((self.internal.compat { inherit system; }).hix).apps;
149149

150-
ciJobs =
150+
allJobs =
151151
let
152-
inherit (legacyPackages) lib;
153152
inherit (import ./ci-lib.nix { pkgs = legacyPackagesUnstable; }) stripAttrsForHydra filterDerivations;
154153
ci = import ./ci.nix { inherit (self.internal) compat; inherit system; };
155-
allJobs = stripAttrsForHydra (filterDerivations ci);
154+
in stripAttrsForHydra (filterDerivations ci);
155+
156+
ciJobs =
157+
let
158+
inherit (legacyPackages) lib;
156159
names = x: lib.filter (n: n != "recurseForDerivations" && n != "meta")
157160
(builtins.attrNames x);
158161
requiredJobs =

lib/system-nixpkgs-map.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ let
1919
in
2020
# -- linux
2121
{ crypto = [ openssl ];
22-
"c++" = []; # no libc++
22+
"c++" = [ libcxx ];
23+
"c++abi" = [ libcxxabi ];
2324
system-cxx-std-lib = [];
2425
"stdc++" = gcclibs;
2526
"stdc++-6" = gcclibs;

0 commit comments

Comments
 (0)