Skip to content

Commit d3c8653

Browse files
committed
Merge branch 'master' of github.com:input-output-hk/haskell.nix into circuithub
2 parents c0af1cc + 2b25ea4 commit d3c8653

File tree

72 files changed

+18396
-75
lines changed

Some content is hidden

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

72 files changed

+18396
-75
lines changed

builder/comp-builder.nix

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,13 @@ let
165165
) ++ [ "$(cat $configFiles/configure-flags)"
166166
] ++ commonConfigureFlags);
167167

168-
# From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one
169-
pkgConfigHasPrefix = builtins.compareVersions lib.version "20.09pre" >= 0;
170-
171168
commonConfigureFlags = ([
172169
# GHC
173170
"--with-ghc=${ghc.targetPrefix}ghc"
174171
"--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
175172
"--with-hsc2hs=${ghc.targetPrefix}hsc2hs"
176-
] ++ lib.optional (pkgConfigHasPrefix && pkgconfig != [])
177-
"--with-pkg-config=${ghc.targetPrefix}pkg-config"
173+
] ++ lib.optional (pkgconfig != [])
174+
"--with-pkg-config=${buildPackages.cabalPkgConfigWrapper.targetPrefix}pkg-config"
178175
++ lib.optionals (stdenv.hasCC or (stdenv.cc != null))
179176
( # CC
180177
[ "--with-gcc=${stdenv.cc.targetPrefix}cc"

builder/ghc-for-component-wrapper.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ let
3939
''
4040
# ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
4141
+ ''
42-
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
42+
if [ -d $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/bin ]; then
43+
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
44+
else
45+
ln -s $unwrappedGhc/lib/bin ${libDir}
46+
fi
4347
''
4448
# ... and the ghcjs shim's if they are available ...
4549
+ ''

ci.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@
5858
ghc902 = false;
5959
ghc927 = true;
6060
ghc944 = true;
61-
ghc96020230302 = true;
6261
ghc961 = true;
6362
}));
6463
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
6564
# We need to use the actual nixpkgs version we're working with here, since the values
6665
# of 'lib.systems.examples' are not understood between all versions
6766
let lib = nixpkgs.lib;
6867
in lib.optionalAttrs (nixpkgsName == "unstable"
69-
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc865" "ghc884" "ghc8107"])
70-
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107"]))) {
68+
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc865" "ghc884" "ghc8107" "ghc961"])
69+
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc961"]))) {
7170
inherit (lib.systems.examples) ghcjs;
7271
} // lib.optionalAttrs (nixpkgsName == "unstable"
7372
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc944" "ghc961"])

compiler/ghc/default.nix

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ let self =
2020
, # GHC can be built with system libffi or a bundled one.
2121
libffi ? null
2222

23-
, useLLVM ? !stdenv.targetPlatform.isx86
23+
, # we don't need LLVM for x86, aarch64, or ghcjs
24+
useLLVM ? with stdenv.targetPlatform; !(isx86 || isAarch64 || isGhcjs)
2425
, # LLVM is conceptually a run-time-only dependency, but for
2526
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
2627
# build-time dependency too.
@@ -121,8 +122,10 @@ let
121122

122123
# TODO(@Ericson2314) Make unconditional
123124
targetPrefix = lib.optionalString
124-
(targetPlatform != hostPlatform)
125-
"${targetPlatform.config}-";
125+
(targetPlatform != hostPlatform) (
126+
if useHadrian && targetPlatform.isGhcjs
127+
then "javascript-unknown-ghcjs-"
128+
else "${targetPlatform.config}-");
126129

127130
buildMK = ''
128131
BuildFlavour = ${ghcFlavour}
@@ -177,13 +180,13 @@ let
177180
# `--with` flags for libraries needed for RTS linker
178181
configureFlags = [
179182
"--datadir=$doc/share/doc/ghc"
180-
"--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
181-
] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
182-
] ++ lib.optionals (!enableIntegerSimple) [
183+
] ++ lib.optionals (!targetPlatform.isGhcjs) ["--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
184+
] ++ lib.optionals (targetLibffi != null && !targetPlatform.isGhcjs) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
185+
] ++ lib.optionals (!enableIntegerSimple && !targetPlatform.isGhcjs) [
183186
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
184187
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
185188
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
186-
] ++ lib.optionals (targetPlatform != hostPlatform) [
189+
] ++ lib.optionals (targetPlatform != hostPlatform && !targetPlatform.isGhcjs) [
187190
"--with-iconv-includes=${targetIconv}/include" "--with-iconv-libraries=${targetIconv}/lib"
188191
] ++ lib.optionals (targetPlatform != hostPlatform) [
189192
"--enable-bootstrap-with-devel-snapshot"
@@ -198,29 +201,35 @@ let
198201
"--enable-dwarf-unwind"
199202
"--with-libdw-includes=${lib.getDev elfutils}/include"
200203
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
201-
];
204+
] ++ lib.optional (targetPlatform.isGhcjs) "--target=javascript-unknown-ghcjs"; # TODO use configurePlatforms once tripple is updated in nixpkgs
202205

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

213216
toolsForTarget =
214-
if hostPlatform == buildPlatform then
215-
[ targetPackages.stdenv.cc ] ++ lib.optional useLLVM llvmPackages.llvm
217+
if targetPlatform.isGhcjs
218+
then [ buildPackages.emscripten ]
219+
else if hostPlatform == buildPlatform
220+
then [ targetPackages.stdenv.cc ] ++ lib.optional useLLVM llvmPackages.llvm
216221
else assert targetPlatform == hostPlatform; # build != host == target
217222
[ stdenv.cc ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
218223

219224
targetCC = builtins.head toolsForTarget;
220225

221226
useHadrian = builtins.compareVersions ghc-version "9.4" >= 0;
222227
# Indicates if we are installing by copying the hadrian stage1 output
223-
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || targetPlatform.isMusl);
228+
# I think we want to _always_ just install stage1. For now let's do this
229+
# for musl only; but I'd like to stay far away from the unnecessary
230+
# bindist logic as we can. It's slow, and buggy, and doesn't provide any
231+
# value for us.
232+
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || stdenv.targetPlatform.isMusl);
224233

225234
inherit ((buildPackages.haskell-nix.cabalProject {
226235
compiler-nix-name = "ghc8107";
@@ -248,9 +257,11 @@ let
248257
# For build flavours and flavour transformers
249258
# see https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md
250259
hadrianArgs = "--flavour=${
251-
"default"
260+
(if targetPlatform.isGhcjs then "quick" else "default")
252261
+ lib.optionalString (!enableShared) "+no_dynamic_ghc"
253262
+ lib.optionalString useLLVM "+llvm"
263+
+ lib.optionalString enableDWARF "+debug_info"
264+
+ lib.optionalString targetPlatform.isGhcjs "+native_bignum+no_profiled_libs"
254265
} --docs=no-sphinx -j --verbose";
255266

256267
# When installation is done by copying the stage1 output the directory layout
@@ -310,10 +321,15 @@ stdenv.mkDerivation (rec {
310321
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
311322
export "''${env#TARGET_}=''${!env}"
312323
done
324+
'' + lib.optionalString (targetPlatform.isGhcjs) ''
325+
export CC="${targetCC}/bin/emcc"
326+
export CXX="${targetCC}/bin/em++"
327+
export LD="${targetCC}/bin/emcc"
328+
export EM_CACHE=$(mktemp -d)
313329
''
314330
# GHC is a bit confused on its cross terminology, as these would normally be
315331
# the *host* tools.
316-
+ ''
332+
+ lib.optionalString (!targetPlatform.isGhcjs) (''
317333
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
318334
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
319335
''
@@ -329,7 +345,7 @@ stdenv.mkDerivation (rec {
329345
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
330346
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
331347
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
332-
'' + lib.optionalString (targetPlatform == hostPlatform && useLdGold)
348+
'') + lib.optionalString (targetPlatform == hostPlatform && useLdGold)
333349
# set LD explicitly if we want gold even if we aren't cross compiling
334350
''
335351
export LD="${targetCC.bintools}/bin/ld.gold"
@@ -376,7 +392,7 @@ stdenv.mkDerivation (rec {
376392
./boot
377393
'';
378394

379-
configurePlatforms = [ "build" "host" "target" ];
395+
configurePlatforms = [ "build" "host" ] ++ lib.optional (!targetPlatform.isGhcjs) "target";
380396

381397
enableParallelBuilding = true;
382398
postPatch = "patchShebangs .";
@@ -399,8 +415,8 @@ stdenv.mkDerivation (rec {
399415

400416
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
401417

402-
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
403-
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
418+
depsTargetTarget = lib.optionals (!targetPlatform.isGhcjs) (map lib.getDev (libDeps targetPlatform));
419+
depsTargetTargetPropagated = lib.optionals (!targetPlatform.isGhcjs) (map (lib.getOutput "out") (libDeps targetPlatform));
404420

405421
# required, because otherwise all symbols from HSffi.o are stripped, and
406422
# that in turn causes GHCi to abort
@@ -438,7 +454,7 @@ stdenv.mkDerivation (rec {
438454
# The ghcprog fixup is for musl (where runhaskell script just needs to point to the correct
439455
# ghc program to work).
440456
sed -i \
441-
-e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' \
457+
-e '2i export PATH="$PATH:${lib.makeBinPath (lib.optionals (!targetPlatform.isGhcjs) [ targetPackages.stdenv.cc.bintools coreutils ])}"' \
442458
-e 's/ghcprog="ghc-/ghcprog="${targetPrefix}ghc-/' \
443459
$i
444460
done
@@ -586,6 +602,10 @@ stdenv.mkDerivation (rec {
586602
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
587603
find . -name 'system*.conf*'
588604
cat mk/system-cxx-std-lib-1.0.conf
605+
'' + lib.optionalString (installStage1 && stdenv.targetPlatform.isMusl) ''
606+
substituteInPlace hadrian/cfg/system.config \
607+
--replace 'cross-compiling = YES' \
608+
'cross-compiling = NO'
589609
'';
590610
});
591611

@@ -651,13 +671,24 @@ stdenv.mkDerivation (rec {
651671
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
652672
find . -name 'system*.conf*'
653673
cat mk/system-cxx-std-lib-1.0.conf
674+
'' + lib.optionalString (installStage1 && stdenv.targetPlatform.isMusl) ''
675+
substituteInPlace hadrian/cfg/system.config \
676+
--replace 'cross-compiling = YES' \
677+
'cross-compiling = NO'
654678
'';
655679
buildPhase = ''
656680
${hadrian}/bin/hadrian ${hadrianArgs}
657-
'' + lib.optionalString installStage1 ''
681+
'' + lib.optionalString (installStage1 && !stdenv.targetPlatform.isGhcjs) ''
658682
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:libiserv
659683
'' + lib.optionalString targetPlatform.isMusl ''
660684
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:terminfo
685+
'' + lib.optionalString (installStage1 && !haskell-nix.haskellLib.isCrossTarget) ''
686+
${hadrian}/bin/hadrian ${hadrianArgs} stage2:exe:iserv
687+
pushd _build/stage1/bin
688+
for exe in *; do
689+
mv $exe ${targetPrefix}$exe
690+
done
691+
popd
661692
'';
662693

663694
# Hadrian's installation only works for native compilers, and is broken for cross compilers.

compiler/windows/include/windows.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
typedef unsigned long DWORD;
99
typedef void * PVOID;
10+
typedef PVOID HANDLE;
11+
typedef void CRITICAL_SECTION;
1012

1113
typedef struct _RTL_CONDITION_VARIABLE { PVOID Ptr; } RTL_CONDITION_VARIABLE;
1214
typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE;

flake.lock

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

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
nixpkgs-2211 = { url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin"; };
1111
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
1212
flake-compat = { url = "github:input-output-hk/flake-compat/hkm/gitlab-fix"; flake = false; };
13-
flake-utils = { url = "github:numtide/flake-utils"; };
13+
flake-utils = { url = "github:hamishmack/flake-utils/hkm/nested-hydraJobs"; };
1414
tullia = {
1515
url = "github:input-output-hk/tullia";
1616
inputs.nixpkgs.follows = "nixpkgs";

0 commit comments

Comments
 (0)