Skip to content

Commit e292ebb

Browse files
committed
Merge remote-tracking branch 'origin/master' into static-nix-tools
2 parents cba484d + cd01875 commit e292ebb

File tree

10 files changed

+78
-39
lines changed

10 files changed

+78
-39
lines changed

builder/comp-builder.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, stdenv, buildPackages, pkgsBuildBuild, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs, nonReinstallablePkgs }@defaults:
1+
{ pkgs, stdenv, buildPackages, pkgsBuildBuild, ghc, llvmPackages, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs, nonReinstallablePkgs }@defaults:
22
lib.makeOverridable (
33
let self =
44
{ componentId
@@ -429,7 +429,8 @@ let
429429
nativeBuildInputs =
430430
[ghc buildPackages.removeReferencesTo]
431431
++ executableToolDepends
432-
++ (lib.optional stdenv.hostPlatform.isGhcjs buildPackages.nodejs);
432+
++ (lib.optional stdenv.hostPlatform.isGhcjs buildPackages.nodejs)
433+
++ (lib.optional (ghc.useLdLld or false) llvmPackages.bintools);
433434

434435
outputs = ["out"]
435436
++ (lib.optional keepConfigFiles "configFiles")

builder/haddock-builder.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, buildPackages, lib, haskellLib, ghc, ghcForComponent, nonReinstallablePkgs, runCommand, writeText, writeScript, makeConfigFiles }:
1+
{ stdenv, buildPackages, lib, haskellLib, ghc, ghcForComponent, nonReinstallablePkgs, runCommand, writeText, writeScript, makeConfigFiles, llvmPackages }:
22

33
{ componentId
44
, component
@@ -80,7 +80,8 @@ let
8080

8181
nativeBuildInputs =
8282
[ ghc buildPackages.removeReferencesTo ]
83-
++ componentDrv.executableToolDepends;
83+
++ componentDrv.executableToolDepends
84+
++ (lib.optional (ghc.useLdLld or false) llvmPackages.bintools);
8485

8586
configurePhase = ''
8687
mkdir -p $configFiles

builder/setup-builder.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles }@defaults:
1+
{ pkgs, stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles, llvmPackages }@defaults:
22

33
let self =
44
{ component, package, name, src, enableDWARF ? false, flags ? {}, revision ? null, patches ? [], defaultSetupSrc
@@ -67,7 +67,7 @@ let
6767
++ builtins.concatLists component.pkgconfig
6868
++ configFiles.libDeps
6969
++ [ghc]; # Needs to be a build input so that the boot libraries are included
70-
nativeBuildInputs = [ghc] ++ executableToolDepends;
70+
nativeBuildInputs = [ghc] ++ executableToolDepends ++ (lib.optional (ghc.useLdLld or false) llvmPackages.bintools);
7171

7272
passthru = {
7373
inherit (package) identifier;

compiler/ghc/default.nix

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let self =
7676
# don't use gold with with musl. Still seems to be
7777
# affected by 22266.
7878
&& !stdenv.targetPlatform.isMusl)
79-
79+
, useLdLld ? false
8080
, ghc-version ? src-spec.version
8181
, ghc-version-date ? null
8282
, ghc-commit-id ? null
@@ -95,6 +95,8 @@ assert !(enableIntegerSimple || enableNativeBignum) -> gmp != null;
9595
assert enableNativeBignum -> !enableIntegerSimple;
9696
assert enableIntegerSimple -> !enableNativeBignum;
9797

98+
assert !(useLdGold && useLdLld);
99+
98100
let
99101
src = src-spec.file or (fetchurl { inherit (src-spec) url sha256; });
100102

@@ -212,6 +214,11 @@ let
212214
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
213215
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
214216
"CONF_LD_LINKER_OPTS_STAGE2=-fuse-ld=gold" # See: <https://gitlab.haskell.org/ghc/ghc/-/issues/22550#note_466656>
217+
] ++ lib.optionals useLdLld [
218+
"LD=${llvmPackages.bintools}/bin/ld.lld"
219+
"CFLAGS=-fuse-ld=lld"
220+
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=lld"
221+
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=lld"
215222
] ++ lib.optionals enableDWARF [
216223
"--enable-dwarf-unwind"
217224
"--with-libdw-includes=${lib.getDev elfutils}/include"
@@ -449,7 +456,10 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
449456
''
450457
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
451458
+ ''
452-
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
459+
export LD="${if useLdLld then
460+
"${targetPackages.llvmPackages.bintools}/bin/${targetPackages.llvmPackages.bintools.targetPrefix}ld.lld"
461+
else
462+
"${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"}"
453463
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
454464
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
455465
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -467,6 +477,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
467477
# set LD explicitly if we want gold even if we aren't cross compiling
468478
''
469479
export LD="${targetCC.bintools}/bin/ld.gold"
480+
'' + lib.optionalString (targetPlatform == hostPlatform && useLdLld) ''
481+
export LD="${llvmPackages.bintools}/bin/ld.lld"
470482
'' + lib.optionalString (targetPlatform.isWindows) ''
471483
export DllWrap="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}dllwrap"
472484
export Windres="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}windres"
@@ -533,7 +545,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
533545
nativeBuildInputs = [
534546
perl autoconf automake m4 python3 sphinx
535547
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
536-
] ++ lib.optional (patches != []) autoreconfHook;
548+
] ++ lib.optional (patches != []) autoreconfHook
549+
++ lib.optional useLdLld llvmPackages.bintools;
537550

538551
# For building runtime libs
539552
depsBuildTarget = toolsForTarget;
@@ -684,7 +697,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
684697
'';
685698

686699
passthru = {
687-
inherit bootPkgs targetPrefix libDir llvmPackages enableShared enableTerminfo useLLVM hadrian hadrianProject;
700+
inherit bootPkgs targetPrefix libDir llvmPackages enableShared enableTerminfo useLLVM useLdLld hadrian hadrianProject;
688701

689702
# Our Cabal compiler name
690703
haskellCompilerName = "ghc-${version}";

docs/reference/library.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ needed for `importAndFilterProject`.
273273
|----------------------|------|---------------------|
274274
| `name` | String | Optional name for better error messages. |
275275
| `src` | Path | Location of the cabal project files. |
276-
| `compiler-nix-name` | String | The name of the ghc compiler to use eg. "ghc884" |
277-
| `index-state` | Timestamp | Optional hackage index-state, eg. "2019-10-10T00:00:00Z". |
276+
| `compiler-nix-name` | String | The name of the ghc compiler to use eg. "ghc9122" |
277+
| `index-state` | Timestamp | Optional hackage index-state, eg. "2025-01-10T00:00:00Z". |
278278
| `index-sha256` | Sha256 | Optional hash of the truncated hackage index-state. |
279279
| `plan-sha256` | Sha256 | Optional hash of the plan-to-nix output (makes the plan-to-nix step a fixed output derivation). |
280280
| `cabalProject` | String | Optional cabal project file contents (defaults to readFile "${src}/cabal.project"). |

flake.lock

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

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
url = "github:input-output-hk/hackage.nix/for-stackage";
3232
flake = false;
3333
};
34+
hackage-internal = {
35+
url = "github:input-output-hk/hackage.nix";
36+
flake = false;
37+
};
3438
stackage = {
3539
url = "github:input-output-hk/stackage.nix";
3640
flake = false;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,9 @@ let
678678
# Setting the desired `index-state` here in case it is not
679679
# in the cabal.project file. This will further restrict the
680680
# packages used by the solver (cached-index-state >= index-state-max).
681-
pkgs.lib.optionalString (index-state != null) "--index-state=${index-state}"
681+
# Cabal treats `--index-state` > the last known package as an error,
682+
# so we only include this if it is < cached-index-state.
683+
pkgs.lib.optionalString (index-state != null && index-state < cached-index-state) "--index-state=${index-state}"
682684
} \
683685
-w ${
684686
# We are using `-w` rather than `--with-ghc` here to override

mk-local-hackage-repo/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
pkgs:
1818
{ name, index }:
1919

20-
pkgs.buildPackages.runCommand "hackage-repo-${name}" { preferLocalBuild = true; } ''
20+
pkgs.pkgsBuildBuild.runCommand "hackage-repo-${name}" { preferLocalBuild = true; } ''
2121
mkdir -p $out
2222
export expires="4000-01-01T00:00:00Z"
2323
@@ -29,7 +29,7 @@ ${
2929
# of the index derivation (when the `extra-hackages` feature is used the index
3030
# may not have an outputHash).
3131
pkgs.lib.optionalString (index ? outputHash) ''
32-
if [[ "${index.outputHash}" != "$index_sha256" ]]; then
32+
if [[ "$(${pkgs.pkgsBuildBuild.nix}/bin/nix-hash --type sha256 --to-base16 ${index.outputHash})" != "$index_sha256" ]]; then
3333
echo "ERROR See https://github.com/input-output-hk/haskell.nix/issues/884"
3434
exit 1
3535
fi

overlays/haskell.nix

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ final: prev: {
437437
# If you want to update this value it important to check the
438438
# materializations. Turn `checkMaterialization` on below and
439439
# check the CI results before turning it off again.
440-
internalHackageIndexState = "2024-10-17T00:00:00Z"; # Remember to also update ../nix-tools/cabal.project and ../nix-tools/flake.lock
441-
440+
internalHackageIndexState = builtins.head (builtins.attrNames (
441+
import (sources.hackage-internal + "/index-state.nix")));
442442
checkMaterialization = false; # This is the default. Use an overlay to set it to true and test all the materialized files
443443

444444
# Helps materialize the output of derivations
@@ -601,7 +601,13 @@ final: prev: {
601601
# Takes a haskell src directory runs cabal new-configure and plan-to-nix.
602602
# Resulting nix files are added to nix-plan subdirectory.
603603
callCabalProjectToNix = import ../lib/call-cabal-project-to-nix.nix {
604-
index-state-hashes = import indexStateHashesPath;
604+
index-state-hashes =
605+
(
606+
if builtins.pathExists (hackageSrc + "/index-state.nix")
607+
then import (hackageSrc + "/index-state.nix")
608+
else import (hackageSrc + "/index-state-hashes.nix")
609+
)
610+
// import (sources.hackage-internal + "/index-state.nix");
605611
inherit (final.buildPackages.haskell-nix) haskellLib;
606612
pkgs = final.buildPackages.pkgs;
607613
inherit (final.buildPackages.pkgs) cacert;
@@ -832,18 +838,13 @@ final: prev: {
832838
shellFor' = crossPlatforms:
833839
let
834840
shellArgs = builtins.removeAttrs rawProject.args.shell [ "crossPlatforms" ];
835-
# These are the args we will pass to the shells for the corss compiler
836-
argsCross =
837-
# These things should match main shell
838-
final.lib.filterAttrs (n: _: builtins.elem n [
839-
"packages" "components" "additional" "exactDeps" "packageSetupDeps"
840-
]) shellArgs // {
841-
# The main shell's hoogle will probably be faster to build.
842-
withHoogle = false;
843-
};
844841
# Shells for cross compilation
845-
crossShells = builtins.map (project: project.shellFor' (_p: []) argsCross)
846-
(crossPlatforms projectCross);
842+
crossShells = builtins.map (project: project.shellFor {
843+
# Prevent recursion
844+
crossPlatforms = final.lib.mkForce (_p: []);
845+
# The main shell's hoogle will probably be faster to build.
846+
withHoogle = final.lib.mkForce false;
847+
}) (crossPlatforms projectCross);
847848
in rawProject.hsPkgs.shellFor (shellArgs // {
848849
# Add inputs from the cross compilation shells
849850
inputsFrom = shellArgs.inputsFrom or [] ++ crossShells;
@@ -1152,7 +1153,7 @@ final: prev: {
11521153
let
11531154
ghc = final.buildPackages.haskell-nix.compiler.${compiler-nix-name}.override { hadrianEvalPackages = evalPackages; };
11541155
in
1155-
final.recurseIntoAttrs ({
1156+
final.recurseIntoAttrs ({
11561157
# Things that require no IFD to build
11571158
source-pin-hackage = hackageSrc;
11581159
source-pin-stackage = stackageSrc;

0 commit comments

Comments
 (0)