Skip to content

Commit a538ce3

Browse files
committed
Merge remote-tracking branch 'origin/master' into revert_bzip2_musl
2 parents cd21eaf + 071f213 commit a538ce3

File tree

3,881 files changed

+65061
-712132
lines changed

Some content is hidden

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

3,881 files changed

+65061
-712132
lines changed

BUGLOG

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
This file contains bugs we find while working on haskell.nix. The format is as
2+
follow:
3+
<separator: 80 * '-'>
4+
YYYY-MM-DD: nix-job name
5+
6+
<error>
7+
8+
<discussion>
9+
10+
--------------------------------------------------------------------------------
11+
2024-04-09 x86_64-linux.R2305.ghc8107.mingwW64.ghc
12+
13+
/build/ghc62733_0/ghc_1.s:50:0: error:
14+
Error: CFI instruction used without previous .cfi_startproc
15+
|
16+
50 | .cfi_escape 0x16, 0x07, 0x04, 0x77, 152, 65
17+
| ^
18+
`x86_64-w64-mingw32-cc' failed in phase `Assembler'. (Exit code: 1)
19+
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgCRun.o] Error 1
20+
21+
The source for this is
22+
> https://github.com/ghc/ghc/blob/1f02b7430b2fbab403d7ffdde9cfd006e884678e/rts/StgCRun.c#L433
23+
24+
It appears that GCC C17 12.2.0 does _not_ emit .cfi_startproc / .cfi_endprocs
25+
whereas GCC C17 13.2.0 _does_. Specificall x86_64-w64-mingw32-cc. So this might
26+
be a cross compilation issue.
27+
28+
The -g is hardcoded in
29+
https://github.com/ghc/ghc/blob/1f02b7430b2fbab403d7ffdde9cfd006e884678e/mk/config.mk.in#L361
30+
31+
Turns out, this was disabled for anything but linux in https://github.com/ghc/ghc/commit/5b08e0c06e038448a63aa9bd7f163b23d824ba4b,
32+
hence we backport that patch to GHC-8.10 when targeting windows (to prevent mass rebuilds for
33+
other archs).
34+
35+
--------------------------------------------------------------------------------
36+
2024-04-10 x86_64-linux.R2305.ghc902.mingwW64.ghc
37+
38+
make[1]: *** [utils/hsc2hs/ghc.mk:22: utils/hsc2hs/dist-install/build/tmp/hsc2hs.exe] Error 1
39+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x2a): relocation truncated to fit: R_X86_64_32S against `.text'
40+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x46): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.data'
41+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x8b): relocation truncated to fit: R_X86_64_32S against symbol `stg_bh_upd_frame_info' defined in .text section in /build/ghc-9.0.2/rts/dist/build/libHSrts.a(Updates.o)
42+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x95): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.rdata'
43+
utils/runghc/dist-install/build/Main.o:fake:(.text+0xe3): relocation truncated to fit: R_X86_64_32S against symbol `stg_bh_upd_frame_info' defined in .text section in /build/ghc-9.0.2/rts/dist/build/libHSrts.a(Updates.o)
44+
utils/runghc/dist-install/build/Main.o:fake:(.text+0xed): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.rdata'
45+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x13b): relocation truncated to fit: R_X86_64_32S against symbol `stg_bh_upd_frame_info' defined in .text section in /build/ghc-9.0.2/rts/dist/build/libHSrts.a(Updates.o)
46+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x145): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.rdata'
47+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x193): relocation truncated to fit: R_X86_64_32S against symbol `stg_bh_upd_frame_info' defined in .text section in /build/ghc-9.0.2/rts/dist/build/libHSrts.a(Updates.o)
48+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x19d): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.rdata'
49+
utils/runghc/dist-install/build/Main.o:fake:(.text+0x1eb): additional relocation overflows omitted from the output
50+
51+
We notice `fake`, which is GHC failing to provide .file identifier in the source.
52+
We also see lots of R_X64_64_32S relocations, which are signed 32bit relocations.
53+
These fall with ASLR and high entropy base images from later binutils.
54+
55+
The underlying issue is that GHC emits _absolute_ label loads (mov $... reg), instead
56+
of %rpi or other relative loads. This then leads to the linker emitting 32bit
57+
absolute relocation. With the final image being potentially loaded into high memory
58+
(e.g. dynamic base, and the base image being set to some high address), the linker
59+
starts falling over itself, because it simply can't resolve those absolute addresses
60+
in the 32bit slots.
61+
62+
This was fixed in GHC upstream in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7449,
63+
while the patch in haskell.nix is a bit more pedestrian and just sets PIC on windows to
64+
always be on, and then uses the PIC pipeline.
65+
66+
--------------------------------------------------------------------------------
67+
2024-06-18 x86_64-linux.unstable.ghc9101.ucrt64.tests.th-dlls-minimal.build
68+
69+
0024:err:seh:call_stack_handlers invalid frame 00007FFFFF68EF18 (0000000000022000-0000000000220000)
70+
0024:err:seh:NtRaiseException Exception frame is not in stack limits => unable to dispatch exception.
71+
iserv-proxy: {handle: <socket: 11>}: GHCi.Message.remoteCall: end of file
72+
73+
This is due to GHC mislinking GNU import libraries (dll.a). What happens is that
74+
GHC ends up creating GOT entries for function calls instead of PLT entries. The
75+
loader/linker in GHC for Windows has logic to lazy load .dll's as referenced. For
76+
this symbols get a dependency symbol attached, this could be a symbol indicating
77+
the DLL that needs to be loaded. While walking the dependencies to find the dll to
78+
load (or in some cases just the dependent symbol, not the dll), we override the
79+
symbol type with the one of the dependent symbol. This however means we'll
80+
override the type of a symbol with the DATA type each time the symbol leads to a
81+
dllInstance to be loaded. Subsequently we end up creating a GOT entry instead of
82+
a PLT entry for the symbol, irrepsective of the original symbol being a code or
83+
data symbol. If code symbols end up getting GOT stubs, we see the above crash as
84+
the control flow jumps to the location of the stub, and instead of a PLT/jump
85+
island just lands in the address of the target symbol, which is in most cases
86+
non-sensical machine code.

build.nix

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ in rec {
2626

2727
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
2828
pkgs.recurseIntoAttrs ({
29-
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
29+
cabal-latest = tool compiler-nix-name "cabal" ({
30+
inherit evalPackages;
31+
} // pkgs.lib.optionalAttrs (ghcFromTo "9.10" "9.12") {
32+
cabalProjectLocal = builtins.readFile ./test/cabal.project.local;
33+
});
3034
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.8" < 0) {
3135
hlint-latest = tool compiler-nix-name "hlint" {
3236
inherit evalPackages;
@@ -58,10 +62,10 @@ in rec {
5862
inherit evalPackages;
5963
src = pkgs.haskell-nix.sources."hls-2.2";
6064
};
61-
} // pkgs.lib.optionalAttrs (ghcFromTo "9.0" "9.8") {
62-
"hls-26" = tool compiler-nix-name "haskell-language-server" {
65+
} // pkgs.lib.optionalAttrs (ghcFromTo "9.0" "9.11") {
66+
"hls-29" = tool compiler-nix-name "haskell-language-server" {
6367
inherit evalPackages;
64-
src = pkgs.haskell-nix.sources."hls-2.6";
68+
src = pkgs.haskell-nix.sources."hls-2.9";
6569
};
6670
})
6771
);

builder/comp-builder.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ let
418418

419419
nativeBuildInputs =
420420
[ghc buildPackages.removeReferencesTo]
421-
++ executableToolDepends;
421+
++ executableToolDepends
422+
++ (lib.optional stdenv.hostPlatform.isGhcjs buildPackages.nodejs);
422423

423424
outputs = ["out"]
424425
++ (lib.optional keepConfigFiles "configFiles")

builder/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
# tl;dr: the builder must not re-introduce any reference to the build plan.
1515

16-
{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, nonReinstallablePkgs, hsPkgs, compiler }:
16+
{ pkgs, buildPackages, pkgsBuildBuild, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, nonReinstallablePkgs, hsPkgs, compiler }:
1717

1818
let
1919
# Builds a single component of a package.
@@ -85,7 +85,7 @@ let
8585

8686
# Same as haskellPackages.shellFor in nixpkgs.
8787
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
88-
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib buildPackages evalPackages compiler;
88+
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib pkgsBuildBuild evalPackages compiler;
8989
inherit (buildPackages) glibcLocales;
9090
};
9191

builder/hspkg-builder.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ let
3131

3232
cabalFile = if package-description-override == null || bundledSrc != null then null else package-description-override;
3333

34-
defaultSetupSrc = if stdenv.hostPlatform.isGhcjs then ./Setup.ghcjs.hs else ./Setup.hs;
34+
# New GHC JS backend run emcc itself without the need for custom Setup.hs
35+
oldGhcjs = stdenv.hostPlatform.isGhcjs && builtins.compareVersions ghc.version "9.10" < 0;
36+
defaultSetupSrc = if oldGhcjs then ./Setup.ghcjs.hs else ./Setup.hs;
3537

3638
setup = if package.buildType == "Simple"
3739
then
38-
if stdenv.targetPlatform.isGhcjs # TODO probably should be hostPlatform, but only HsColour used to build ghc will change (updating will require rebuilding all the ghcjs versions)
40+
if oldGhcjs
3941
then
4042
buildPackages.haskell-nix.nix-tools-unchecked.exes.default-setup-ghcjs // { exeName = "default-setup-ghcjs"; }
4143
else

builder/make-config-files.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ let
160160
fi
161161
''}
162162
done
163-
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs')}; do
163+
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
164164
if [ -e $ghcDeps/envDeps/$p ]; then
165165
cat $ghcDeps/envDeps/$p >> $configFiles/ghc-environment
166166
fi

builder/shell-for.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, evalPackages, compiler }:
1+
{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler }:
22

33
{ # `packages` function selects packages that will be worked on in the shell itself.
44
# These packages will not be built by `shellFor`, but their
@@ -149,7 +149,7 @@ let
149149
# inherit (hsPkgs) hoogle;
150150
} // (
151151
lib.optionalAttrs (args ? tools && args.tools ? hoogle) {
152-
hoogle = buildPackages.haskell-nix.hackage-tool (
152+
hoogle = pkgsBuildBuild.haskell-nix.hackage-tool (
153153
haskellLib.versionOrModToMods args.tools.hoogle ++ [{
154154
name = "hoogle";
155155
compiler-nix-name = compiler.nix-name;
@@ -168,12 +168,12 @@ in
168168
nativeBuildInputs = [ ghcEnv.drv ]
169169
++ nativeBuildInputs
170170
++ mkDrvArgs.nativeBuildInputs or []
171-
++ lib.attrValues (buildPackages.haskell-nix.tools' evalPackages compiler.nix-name tools)
171+
++ lib.attrValues (pkgsBuildBuild.haskell-nix.tools' evalPackages compiler.nix-name tools)
172172
# If this shell is a cross compilation shell include
173173
# wrapper script for running cabal build with appropriate args.
174174
# Includes `--with-compiler` in case the `cabal.project` file has `with-compiler:` in it.
175175
++ lib.optional (ghcEnv.targetPrefix != "") (
176-
buildPackages.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" ''
176+
pkgsBuildBuild.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" ''
177177
exec cabal \
178178
--with-ghc=${ghcEnv.targetPrefix}ghc \
179179
--with-compiler=${ghcEnv.targetPrefix}ghc \

changelog.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
This file contains a summary of changes to Haskell.nix and `nix-tools`
22
that will impact users.
33

4+
## Jun 5, 2024
5+
6+
Haskell.nix now respects the `pre-existing` packages selected
7+
by the cabal planner. The selection made by the planner
8+
is used to set `nonReinstallablePkgs`.
9+
10+
Instead setting `nonReinstallablePkgs` and `reinstallableLibGhc`
11+
haskell.nix projects should add `constraints` to the cabal project.
12+
13+
For instance to force the use of the `pre-exising` `text`
14+
package add:
15+
16+
```
17+
constraints: text installed
18+
```
19+
20+
To make sure `text` is reinstalled use:
21+
22+
```
23+
constraints: text source
24+
```
25+
26+
The `pre-existing` `ghc` will now be used by default as
27+
that is what `cabal` will choose (haskell.nix used to choose
28+
`reinstallableLibGhc=true` by default).
29+
30+
To allow cabal to choose reinstalling `ghc` add:
31+
32+
```
33+
allow-boot-library-installs: True
34+
```
35+
36+
To force cabal to choose reinstalling:
37+
38+
```
39+
constraints: ghc source
40+
allow-boot-library-installs: True
41+
```
42+
43+
It may also need `allow-newer: ghc:Cabal`
44+
445
## Mar 27, 2023
546

647
Haskell.nix will no longer parse the `cabal.project` file to

ci.nix

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluating
22
# on a machine with e.g. no way to build the Darwin IFDs you need!
3-
{ ifdLevel ? 3
3+
{ ifdLevel # This is passed in from flake.nix
44
, checkMaterialization ? false
55
, system ? builtins.currentSystem
66
, evalSystem ? builtins.currentSystem or "x86_64-linux"
@@ -22,17 +22,22 @@
2222
"R2211" = inputs.nixpkgs-2211;
2323
"R2305" = inputs.nixpkgs-2305;
2424
"R2311" = inputs.nixpkgs-2311;
25+
"R2405" = inputs.nixpkgs-2405;
2526
"unstable" = inputs.nixpkgs-unstable;
2627
};
2728

2829
nixpkgsArgs = {
2930
# set checkMaterialization as per top-level argument
3031
overlays = [
3132
haskellNix.overlay
32-
(_final: prev: {
33+
(final: prev: {
3334
haskell-nix = prev.haskell-nix // {
3435
inherit checkMaterialization;
36+
extraPkgconfigMappings = prev.haskell-nix.extraPkgconfigMappings or {} // {
37+
"libsodium" = [ "libsodium-18" ];
38+
};
3539
};
40+
libsodium-18 = (final.callPackage (inputs.nixpkgs-2311 + "/pkgs/development/libraries/libsodium") {}).overrideAttrs (_: { dontDisableStatic = true; });
3641
})
3742
];
3843
# Needed for dwarf tests
@@ -56,11 +61,7 @@
5661
# cabal-install and nix-tools plans. When removing a ghc version
5762
# from here (so that is no longer cached) also remove ./materialized/ghcXXX.
5863
# Update supported-ghc-versions.md to reflect any changes made here.
59-
nixpkgs.lib.optionalAttrs (nixpkgsName == "R2305") {
60-
ghc810 = false;
61-
ghc90 = false;
62-
ghc92 = false;
63-
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "R2311") {
64+
nixpkgs.lib.optionalAttrs (nixpkgsName == "R2405") {
6465
ghc94 = false;
6566
ghc96 = false;
6667
ghc98 = false;
@@ -73,7 +74,7 @@
7374
ghc96llvm = true;
7475
ghc98 = true;
7576
ghc98llvm = true;
76-
ghc910X = true;
77+
ghc910 = true;
7778
ghc911 = true;
7879
})));
7980
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
@@ -88,9 +89,9 @@
8889
|| (system == "aarch64-darwin" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"])
8990
)) {
9091
inherit (lib.systems.examples) ghcjs;
91-
} // lib.optionalAttrs (nixpkgsName != "unstable"
92-
&& (__match ".*llvm" compiler-nix-name == null)
93-
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884"])
92+
} // lib.optionalAttrs (
93+
(__match ".*llvm" compiler-nix-name == null)
94+
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc91120240620"]) # Including GHC HEAD here because the patches for rts/RtsSymbols.c no longer apply and mingwW64 GHC build fails without them
9495
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
9596
inherit (lib.systems.examples) mingwW64;
9697
} // lib.optionalAttrs (nixpkgsName == "unstable"
@@ -124,8 +125,6 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
124125
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
125126
} // pkgs.lib.optionalAttrs runTests {
126127
inherit (build) tests tools maintainer-scripts maintainer-script-cache;
127-
} // pkgs.lib.optionalAttrs (ifdLevel >= 2) {
128-
inherit (pkgs.haskell-nix.iserv-proxy-exes.${compiler-nix-name}) iserv-proxy;
129128
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
130129
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }).getComponent "exe:hello";
131130
});
@@ -149,7 +148,7 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
149148
// pkgs.lib.optionalAttrs (ifdLevel >= 2 && crossSystemName != "ghcjs")
150149
pkgs.haskell-nix.iserv-proxy-exes.${compiler-nix-name}
151150
// pkgs.lib.optionalAttrs (ifdLevel >= 3) {
152-
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit compiler-nix-name; }).getComponent "exe:hello";
151+
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }).getComponent "exe:hello";
153152
})
154153
))
155154
)

0 commit comments

Comments
 (0)