Skip to content

Fix ghc 9.4.3 TH support #1814

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

Merged
merged 44 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
71d53f7
Fix TH support in GHC 9.4.3
hamishmack Dec 9, 2022
336fa45
Merge remote-tracking branch 'origin/master' into hkm/fix-ghc943-th
hamishmack Dec 12, 2022
ef7dbb2
Update materialization
hamishmack Dec 12, 2022
81f2d36
More TH fixes
hamishmack Dec 14, 2022
c4ca4f9
Disable failing test
hamishmack Dec 14, 2022
8d3ef00
Disable failing test
hamishmack Dec 14, 2022
a2bc721
Disable failing test
hamishmack Dec 14, 2022
3e59878
Disable failing test
hamishmack Dec 14, 2022
c01e28e
ifdLevel 0
hamishmack Dec 14, 2022
725c888
ifdLevel 3
hamishmack Dec 14, 2022
4b2e5a8
Fix ci
hamishmack Dec 14, 2022
3b93846
Merge remote-tracking branch 'origin/master' into hkm/fix-ghc943-th
hamishmack Jan 4, 2023
338bd57
Bump stack version
hamishmack Jan 4, 2023
cb0176a
Skip hls for ghc 9.4 for now
hamishmack Jan 4, 2023
9b2a076
Remove redundant quotes
hamishmack Jan 4, 2023
f6acc59
Disable ghcjs-overlay test for ghc 9.4
hamishmack Jan 4, 2023
266408e
Fix for TH on ghc 9.4
hamishmack Jan 4, 2023
cb0ca4c
genprimopcode and deriveConstants
hamishmack Jan 4, 2023
56f4818
Use binary-dist-dir to install ghc
hamishmack Jan 4, 2023
e6fce20
Skip hls for ghc 9.4 for now
hamishmack Jan 4, 2023
2b24a4a
Fix for gitlab in flake-compat
hamishmack Jan 4, 2023
578a2ff
Fix for installing dwarf enabled ghc
hamishmack Jan 4, 2023
cfeacb5
Fix for building hls 1.9 from hackage
hamishmack Jan 4, 2023
453de10
disable broken tests
hamishmack Jan 4, 2023
aec9447
Update materialized files
hamishmack Jan 4, 2023
9334ced
More fixes for tests
hamishmack Jan 5, 2023
58e953a
Skip stack build on ghc 9.4
hamishmack Jan 5, 2023
4670879
Workaround for restrict-eval true
hamishmack Jan 5, 2023
96e3425
fix configureFlags
hamishmack Jan 5, 2023
efc3051
Disable broken tests
hamishmack Jan 6, 2023
994be90
Add materialized files
hamishmack Jan 6, 2023
c6cf5c9
Merge remote-tracking branch 'origin/master' into hkm/fix-ghc943-th
hamishmack Jan 6, 2023
321a4bf
Merge remote-tracking branch 'origin/master' into hkm/fix-ghc943-th
hamishmack Jan 13, 2023
003426d
Merge remote-tracking branch 'origin/master' into hkm/fix-ghc943-th
hamishmack Jan 17, 2023
5ceea8f
Materialized files
hamishmack Jan 17, 2023
a1122dd
Fix for ghc 9.4, macOS and system-cxx-std-lib
hamishmack Jan 19, 2023
daaad40
Fix C++ DLL issue for GHC 9.4
hamishmack Jan 20, 2023
732fccb
Build 9.4 cross compilers with 9.4
hamishmack Jan 20, 2023
80139ed
Merge remote-tracking branch 'origin/master' into hkm/fix-ghc943-th
hamishmack Jan 20, 2023
0d8b034
Disable windows cross compile on macOS for now
hamishmack Jan 22, 2023
b272d92
Add check for roots
hamishmack Jan 22, 2023
aa435a5
Try adding sleep
hamishmack Jan 23, 2023
8c9101a
Use --check
hamishmack Jan 23, 2023
f305c8b
Use nix-build
hamishmack Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ in rec {
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
pkgs.recurseIntoAttrs ({
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
stack = tool compiler-nix-name "stack" { version = "2.9.1"; inherit evalPackages; };
hlint-latest = tool compiler-nix-name "hlint" {
inherit evalPackages;
version = {
Expand All @@ -40,7 +39,15 @@ in rec {
"ghc8107" = "3.4.1";
}.${compiler-nix-name} or "latest";
};
hls-latest = tool compiler-nix-name "haskell-language-server" { inherit evalPackages; };
} // pkgs.lib.optionalAttrs (!__elem compiler-nix-name ["ghc941" "ghc942" "ghc943"]) {
stack = tool compiler-nix-name "stack" { version = "2.9.3"; inherit evalPackages; };
hls-latest = tool compiler-nix-name "haskell-language-server" {
inherit evalPackages;
version =
if __compareVersions haskell.compiler.${compiler-nix-name}.version "9.4" < 0
then "1.8.0.0"
else "latest";
};
})
);

Expand Down
7 changes: 5 additions & 2 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, zlib, ncurses, nodejs }@defaults:
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs }@defaults:
lib.makeOverridable (
let self =
{ componentId
Expand Down Expand Up @@ -556,7 +556,10 @@ let
'')
+ (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) (''
echo "Symlink libffi and gmp .dlls ..."
for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
for p in ${lib.concatStringsSep " " ([ libffi gmp ] ++
# Also include C++ and mcfgthreads DLLs for GHC 9.4.1 and newer
lib.optionals (builtins.compareVersions defaults.ghc.version "9.4.1" >= 0)
[ buildPackages.gcc-unwrapped windows.mcfgthreads ])}; do
find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
done
''
Expand Down
21 changes: 11 additions & 10 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
ghc902 = false;
ghc924 = false;
ghc925 = true;
ghc943 = true;
}));
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
# We need to use the actual nixpkgs version we're working with here, since the values
Expand All @@ -66,7 +67,7 @@
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107"]))) {
inherit (lib.systems.examples) ghcjs;
} // lib.optionalAttrs (nixpkgsName == "unstable"
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc925"])
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc925" "ghc943"])
|| (system == "x86_64-darwin" && __elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
inherit (lib.systems.examples) mingwW64;
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc925"]) {
Expand All @@ -88,11 +89,11 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
# TODO: can we merge this into the general case by picking an appropriate "cross system" to mean native?
native = pkgs.recurseIntoAttrs ({
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
} // pkgs.lib.optionalAttrs runTests {
inherit (build) tests tools maintainer-scripts maintainer-script-cache;
} // pkgs.lib.optionalAttrs (ifdLevel >= 1) {
iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
inherit (pkgs.haskell-nix.iserv-proxy-exes.${compiler-nix-name}) iserv-proxy;
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }).getComponent "exe:hello";
});
Expand All @@ -104,19 +105,19 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name haskellNix; };
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
# TODO: look into cross compiling ghc itself
# ghc = pkgs.haskell-nix.compiler."${compiler-nix-name}";
# ghc = pkgs.haskell-nix.compiler.${compiler-nix-name};
# TODO: look into making tools work when cross compiling
# inherit (build) tools;
} // pkgs.lib.optionalAttrs (runTests && crossSystemName != "aarch64-multiplatform") {
# Tests are broken on aarch64 cross https://github.com/input-output-hk/haskell.nix/issues/513
inherit (build) tests;
}) // pkgs.lib.optionalAttrs (ifdLevel >= 2 && crossSystemName != "ghcjs") {
# GHCJS builds its own template haskell runner.
remote-iserv = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "remote-iserv:exe:remote-iserv";
iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
})
# GHCJS builds its own template haskell runner.
// pkgs.lib.optionalAttrs (ifdLevel >= 2 && crossSystemName != "ghcjs")
pkgs.haskell-nix.iserv-proxy-exes.${compiler-nix-name}
// pkgs.lib.optionalAttrs (ifdLevel >= 3) {
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit compiler-nix-name; }).getComponent "exe:hello";
})
))
Expand Down
78 changes: 50 additions & 28 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let self =
# build-tools
, bootPkgs
, buildPackages
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx, numactl, elfutils
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx, numactl, elfutils, libcxx, libcxxabi
, autoreconfHook
, bash

Expand Down Expand Up @@ -172,14 +172,40 @@ let
BUILD_PROF_LIBS = NO
'';

# `--with` flags for libraries needed for RTS linker
configureFlags = [
"--datadir=$doc/share/doc/ghc"
"--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
] ++ lib.optionals (!enableIntegerSimple) [
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ lib.optionals (targetPlatform != hostPlatform) [
"--with-iconv-includes=${targetIconv}/include" "--with-iconv-libraries=${targetIconv}/lib"
] ++ lib.optionals (targetPlatform != hostPlatform) [
"--enable-bootstrap-with-devel-snapshot"
] ++ lib.optionals (disableLargeAddressSpace) [
"--disable-large-address-space"
] ++ lib.optionals (targetPlatform.isAarch32) [
"CFLAGS=-fuse-ld=gold"
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
] ++ lib.optionals enableDWARF [
"--enable-dwarf-unwind"
"--with-libdw-includes=${lib.getDev elfutils}/include"
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
];

# Splicer will pull out correct variations
libDeps = platform: lib.optional enableTerminfo [ targetPackages.ncurses targetPackages.ncurses.dev ]
++ [targetLibffi]
++ lib.optional (!enableIntegerSimple) gmp
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
++ lib.optional (enableNUMA && platform.isLinux && !platform.isAarch32 && !platform.isAndroid) numactl
# 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
++ lib.optional (!enableTerminfo && haskell-nix.haskellLib.isCrossTarget && (stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) && builtins.compareVersions ghc-version "8.10" < 0) ncurses.dev;
++ lib.optional (!enableTerminfo && haskell-nix.haskellLib.isCrossTarget && (stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) && builtins.compareVersions ghc-version "8.10" < 0) ncurses.dev
++ lib.optional enableDWARF (lib.getLib elfutils);

toolsForTarget =
if hostPlatform == buildPlatform then
Expand Down Expand Up @@ -232,7 +258,7 @@ stdenv.mkDerivation (rec {
version = ghc-version;
name = "${targetPrefix}ghc-${version}";

inherit src;
inherit src configureFlags;
patches = ghc-patches;

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

configurePlatforms = [ "build" "host" "target" ];
# `--with` flags for libraries needed for RTS linker
configureFlags = [
"--datadir=$doc/share/doc/ghc"
"--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
] ++ lib.optional (!enableIntegerSimple) [
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
] ++ lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ lib.optional (targetPlatform != hostPlatform) [
"--with-iconv-includes=${targetIconv}/include" "--with-iconv-libraries=${targetIconv}/lib"
] ++ lib.optionals (targetPlatform != hostPlatform) [
"--enable-bootstrap-with-devel-snapshot"
] ++ lib.optionals (disableLargeAddressSpace) [
"--disable-large-address-space"
] ++ lib.optionals (targetPlatform.isAarch32) [
"CFLAGS=-fuse-ld=gold"
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
] ++ lib.optionals enableDWARF [
"--enable-dwarf-unwind"
"--with-libdw-includes=${lib.getDev elfutils}/include"
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
];

enableParallelBuilding = true;
postPatch = "patchShebangs .";
Expand Down Expand Up @@ -595,8 +597,16 @@ stdenv.mkDerivation (rec {
fi
'';
} // lib.optionalAttrs useHadrian {
postConfigure = lib.optionalString stdenv.isDarwin ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
find . -name 'system*.conf*'
cat mk/system-cxx-std-lib-1.0.conf
'';
buildPhase = ''
${hadrian}/bin/hadrian ${hadrianArgs}
'' + lib.optionalString installStage1 ''
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:libiserv
'' + lib.optionalString targetPlatform.isMusl ''
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:terminfo
'';
Expand All @@ -623,7 +633,19 @@ stdenv.mkDerivation (rec {
--replace ',("windres command", "/bin/false")' ',("windres command", "${targetCC.bintools.targetPrefix}windres")'
''
else ''
${hadrian}/bin/hadrian ${hadrianArgs} install --prefix=$out
${hadrian}/bin/hadrian ${hadrianArgs} binary-dist-dir
cd _build/bindist/ghc-*
./configure --prefix=$out ${lib.concatStringsSep " " configureFlags}
${lib.optionalString stdenv.isDarwin ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
substituteInPlace lib/package.conf.d/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
''}
mkdir -p utils
cp -r ../../../utils/completion utils
make install
cd ../../..
runHook postInstall
'';
});
Expand Down
22 changes: 12 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
nixpkgs-2205 = { url = "github:NixOS/nixpkgs/nixpkgs-22.05-darwin"; };
nixpkgs-2211 = { url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin"; };
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
flake-compat = { url = "github:input-output-hk/flake-compat"; flake = false; };
flake-compat = { url = "github:input-output-hk/flake-compat/hkm/gitlab-fix"; flake = false; };
flake-utils = { url = "github:numtide/flake-utils"; };
tullia = {
url = "github:input-output-hk/tullia";
Expand Down Expand Up @@ -61,8 +61,8 @@
};
iserv-proxy = {
type = "git";
url = "https://gitlab.haskell.org/ghc/iserv-proxy.git";
rev = "6e95df7be6dd29680f983db07a057fc2f34f81f6";
url = "https://gitlab.haskell.org/hamishmack/iserv-proxy.git";
ref = "hkm/remote-iserv";
flake = false;
};
};
Expand Down Expand Up @@ -147,12 +147,15 @@

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

ciJobs =
allJobs =
let
inherit (legacyPackages) lib;
inherit (import ./ci-lib.nix { pkgs = legacyPackagesUnstable; }) stripAttrsForHydra filterDerivations;
ci = import ./ci.nix { inherit (self.internal) compat; inherit system; };
allJobs = stripAttrsForHydra (filterDerivations ci);
in stripAttrsForHydra (filterDerivations ci);

ciJobs =
let
inherit (legacyPackages) lib;
names = x: lib.filter (n: n != "recurseForDerivations" && n != "meta")
(builtins.attrNames x);
requiredJobs =
Expand Down
3 changes: 2 additions & 1 deletion lib/system-nixpkgs-map.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ let
in
# -- linux
{ crypto = [ openssl ];
"c++" = []; # no libc++
"c++" = [ libcxx ];
"c++abi" = [ libcxxabi ];
system-cxx-std-lib = [];
"stdc++" = gcclibs;
"stdc++-6" = gcclibs;
Expand Down
Loading