Skip to content

Commit 9152618

Browse files
authored
Fix support for pkgsStatic (#2424)
* Fix support for pkgsStatic This should fix using both the haskell.nix GHC and nixpkgs GHC with pkgsStatic: ``` nix-build -E '((import ./. {}).pkgs.pkgsStatic.haskell-nix.tool "ghc9122" "hello" {})' nix-build -E '((import ./. {}).pkgs.pkgsStatic.haskell-nix.tool "ghc9122" "hello" { compilerSelection = p: p.haskell.compiler; })' ``` * Add comment * Fix for building with nixpkgs GHC * Fix for `double-conversion` when using `pkgsStatic` * Disable failing tests * Disable tests broken because haddock fails for pkgsStatic builds * Fix for pkgsStatic code coverage file locations * Fix crossSuffix' * Bump head.hackage
1 parent 75bffff commit 9152618

File tree

12 files changed

+118
-56
lines changed

12 files changed

+118
-56
lines changed

builder/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let
2626
};
2727

2828
setup-builder = haskellLib.weakCallPackage pkgs ./setup-builder.nix {
29-
ghc = (ghc.passthru.buildGHC or ghc);
29+
ghc = (ghc.buildGHC or ghc);
3030
hsPkgs = hsPkgs.buildPackages;
3131
# We need to use the buildPackages stdenv to build the setup-builder.
3232
# in the native case, it would be the same in the cross case however
@@ -54,7 +54,7 @@ let
5454
# When building setup depends we need to use the build systems GHC and Packages
5555
makeSetupConfigFiles = haskellLib.weakCallPackage buildPackages ./make-config-files.nix {
5656
inherit haskellLib nonReinstallablePkgs;
57-
ghc = (ghc.passthru.buildGHC or ghc);
57+
ghc = (ghc.buildGHC or ghc);
5858
};
5959

6060

builder/ghc-for-component-wrapper.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ let
2525
docDir = "$wrappedGhc/share/doc/ghc/html";
2626
# For musl we can use haddock from the buildGHC
2727
haddock = if stdenv.hostPlatform.isMusl
28-
then ghc.buildGHC
28+
then ghc.buildGHC or ghc # `or ghc` is here because nixpkgs GHC does not have `buildGHC`
29+
# TODO find a way to get suitable GHC and/or respect `ghc.hasHaddock`.
2930
else ghc;
3031

3132
script = ''

ci.nix

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,40 @@
8282
# of 'lib.systems.examples' are not understood between all versions
8383
let lib = nixpkgs.lib;
8484
in lib.optionalAttrs (nixpkgsName == "unstable"
85-
&& (__match ".*llvm" compiler-nix-name == null)
86-
&& !builtins.elem compiler-nix-name ["ghc9102"]) {
87-
inherit (lib.systems.examples) ghcjs;
88-
} // lib.optionalAttrs (nixpkgsName == "unstable"
89-
&& (__match ".*llvm" compiler-nix-name == null)
90-
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928"])
91-
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
92-
inherit (lib.systems.examples) mingwW64;
93-
} // lib.optionalAttrs (nixpkgsName == "unstable"
94-
&& (__match ".*llvm" compiler-nix-name == null)
95-
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc928" "ghc948"])
96-
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
97-
inherit (lib.systems.examples) ucrt64;
98-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
99-
# Musl cross only works on linux
100-
# aarch64 cross only works on linux
101-
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
102-
} // lib.optionalAttrs (__match ".*llvm" compiler-nix-name == null && system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
103-
# Out llvm versions of GHC seem to break for musl32
104-
inherit (lib.systems.examples) musl32;
105-
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
106-
inherit (lib.systems.examples) aarch64-android-prebuilt;
107-
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc91320250523"]) {
108-
inherit (lib.systems.examples) armv7a-android-prebuilt;
109-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
110-
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
111-
inherit (lib.systems.examples) aarch64-multiplatform-musl;
112-
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
113-
inherit (lib.systems.examples) aarch64-multiplatform-musl;
114-
};
85+
&& __match ".*llvm" compiler-nix-name == null
86+
&& builtins.elem system ["aarch64-linux" "x86_64-linux"]) {
87+
static = p: p.pkgsStatic;
88+
} // lib.optionalAttrs (nixpkgsName == "unstable"
89+
&& (__match ".*llvm" compiler-nix-name == null)
90+
&& !builtins.elem compiler-nix-name ["ghc9102"]) {
91+
inherit (lib.systems.examples) ghcjs;
92+
} // lib.optionalAttrs (nixpkgsName == "unstable"
93+
&& (__match ".*llvm" compiler-nix-name == null)
94+
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928"])
95+
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
96+
inherit (lib.systems.examples) mingwW64;
97+
} // lib.optionalAttrs (nixpkgsName == "unstable"
98+
&& (__match ".*llvm" compiler-nix-name == null)
99+
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc928" "ghc948"])
100+
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
101+
inherit (lib.systems.examples) ucrt64;
102+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
103+
# Musl cross only works on linux
104+
# aarch64 cross only works on linux
105+
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
106+
} // lib.optionalAttrs (__match ".*llvm" compiler-nix-name == null && system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
107+
# Out llvm versions of GHC seem to break for musl32
108+
inherit (lib.systems.examples) musl32;
109+
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
110+
inherit (lib.systems.examples) aarch64-android-prebuilt;
111+
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc91320250523"]) {
112+
inherit (lib.systems.examples) armv7a-android-prebuilt;
113+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
114+
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
115+
inherit (lib.systems.examples) aarch64-multiplatform-musl;
116+
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
117+
inherit (lib.systems.examples) aarch64-multiplatform-musl;
118+
};
115119
isDisabled = d: d.meta.disabled or false;
116120
in
117121
dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
@@ -140,8 +144,10 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
140144
}
141145
//
142146
dimension "Cross system" (crossSystems nixpkgsName evalPackages compiler-nix-name) (crossSystemName: crossSystem:
143-
# Cross builds
144-
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
147+
let pkgs =
148+
if builtins.isAttrs crossSystem
149+
then import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; })
150+
else crossSystem (import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; }));
145151
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name haskellNix; };
146152
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
147153
roots = pkgs.haskell-nix.roots' { inherit compiler-nix-name evalPackages; } ifdLevel // {

compiler/ghc/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let self =
3939

4040
, # Whether to build dynamic libs for the standard library (on the target
4141
# platform). Static libs are always built.
42-
enableShared ? !haskell-nix.haskellLib.isCrossTarget
42+
enableShared ? !haskell-nix.haskellLib.isCrossTarget && !stdenv.targetPlatform.isStatic
4343

4444
, enableLibraryProfiling ? true
4545

@@ -328,7 +328,7 @@ let
328328
# see https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md
329329
hadrianArgs = "--flavour=${
330330
(if targetPlatform.isGhcjs then "quick" else "default")
331-
+ lib.optionalString (!enableShared) "+no_dynamic_ghc"
331+
+ lib.optionalString (!enableShared) "+no_dynamic_libs+no_dynamic_ghc"
332332
+ lib.optionalString useLLVM "+llvm"
333333
+ lib.optionalString enableDWARF "+debug_info"
334334
+ lib.optionalString ((enableNativeBignum && hadrianHasNativeBignumFlavour) || targetPlatform.isGhcjs) "+native_bignum"

test/cabal-simple/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in recurseIntoAttrs {
3535
cabal = { cabalProjectLocal = builtins.readFile ../cabal.project.local; };
3636
hoogle = { cabalProjectLocal = builtins.readFile ../cabal.project.local; };
3737
};
38-
withHoogle = true;
38+
withHoogle = !stdenv.hostPlatform.isStatic;
3939
}).overrideAttrs (_: _: {
4040
meta = rec {
4141
platforms = lib.platforms.all;

test/cabal.project.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repository head.hackage.ghc.haskell.org
2929
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
3030
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
3131
7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
32-
--sha256: sha256-0cuvKmWGj5xuN3kJ6W9mv09bn6PAH4nTBK0QyEPc7Hg=
32+
--sha256: sha256-6w1dAY7syB11aqT7T3mi/vOupdwL9GT2ztRZJBBG/u8=
3333

3434
repository ghcjs-overlay
3535
url: https://raw.githubusercontent.com/input-output-hk/hackage-overlay-ghcjs/ffb32dce467b9a4d27be759fdd2740a6edd09d0b

test/coverage/default.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ let
2323

2424
exeExt = stdenv.hostPlatform.extensions.executable;
2525
crossSuffix = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-${stdenv.hostPlatform.config}";
26+
crossSuffix' = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isStatic) "-static" + crossSuffix;
2627

2728
in recurseIntoAttrs ({
2829
# Does not work on ghcjs because it needs zlib.
@@ -91,7 +92,7 @@ in recurseIntoAttrs ({
9192
dirExists "$pkga_basedir/html/pkga-0.1.0.0"
9293
9394
pkgb_basedir="${project.hsPkgs.pkgb.coverageReport}/share/hpc/vanilla"
94-
testTix="$pkgb_basedir/tix/pkgb-test-tests${crossSuffix}-0.1.0.0-check${crossSuffix}/tests${exeExt}.tix"
95+
testTix="$pkgb_basedir/tix/pkgb-test-tests${crossSuffix'}-0.1.0.0-check${crossSuffix}/tests${exeExt}.tix"
9596
libTix="$pkgb_basedir/tix/pkgb-0.1.0.0/pkgb-0.1.0.0.tix"
9697
fileExistsNonEmpty "$testTix"
9798
fileExistsNonEmpty "$libTix"
@@ -118,8 +119,8 @@ in recurseIntoAttrs ({
118119
dirExists "$project_basedir/tix/pkga-0.1.0.0${inplaceSuffix}"
119120
dirExists "$project_basedir/tix/pkgb-0.1.0.0${inplaceSuffix}"
120121
fileExistsNonEmpty "$project_basedir/tix/pkgb-0.1.0.0${inplaceSuffix}/pkgb-0.1.0.0${inplaceSuffix}.tix"
121-
dirExists "$project_basedir/tix/pkgb-test-tests${crossSuffix}-0.1.0.0-check${crossSuffix}"
122-
fileExistsNonEmpty "$project_basedir/tix/pkgb-test-tests${crossSuffix}-0.1.0.0-check${crossSuffix}/tests${exeExt}.tix"
122+
dirExists "$project_basedir/tix/pkgb-test-tests${crossSuffix'}-0.1.0.0-check${crossSuffix}"
123+
fileExistsNonEmpty "$project_basedir/tix/pkgb-test-tests${crossSuffix'}-0.1.0.0-check${crossSuffix}/tests${exeExt}.tix"
123124
'';
124125
in ''
125126
${check cabalProj "-inplace"}

test/modules.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[{
2+
package-keys = ["HsOpenSSL" "libsodium" "double-conversion"];
23
# See https://github.com/haskell-cryptography/HsOpenSSL/issues/95
34
packages.HsOpenSSL.ghcOptions = ["-optc=-Wno-incompatible-pointer-types"];
45
}
@@ -7,4 +8,15 @@
78
packages.libsodium.configureFlags = [ "--c2hs-option=--cppopts=-D_Null_unspecified=" ];
89
packages.libsodium.components.library.hardeningDisable = ["fortify"];
910
})
11+
12+
({pkgs, lib, ...}: lib.mkIf pkgs.stdenv.hostPlatform.isStatic {
13+
packages.double-conversion.ghcOptions = [
14+
# stop putting U __gxx_personality_v0 into the library!
15+
"-optcxx-fno-rtti"
16+
"-optcxx-fno-exceptions"
17+
# stop putting U __cxa_guard_release into the library!
18+
"-optcxx-std=gnu++98"
19+
"-optcxx-fno-threadsafe-statics"
20+
];
21+
})
1022
]

test/sublib-docs/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let
1414

1515
in recurseIntoAttrs {
1616
# Haddock is not included with cross compilers currently
17-
meta.disabled = haskellLib.isCrossHost;
17+
meta.disabled = haskellLib.isCrossHost || stdenv.hostPlatform.isStatic;
1818
ifdInputs = {
1919
inherit (project) plan-nix;
2020
};

test/th-dlls/default.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ let
77
project = externalInterpreter: project' {
88
inherit compiler-nix-name evalPackages;
99
src = testSrc "th-dlls";
10+
# TODO figure out why TH breaks with pkgsStatic for `libsodium` and `HsOpenSSL`
11+
# `libsodium` fails with the unhandled ELF relocation(RelA) type 23
12+
# `HsOpenSSL` segfaults in ghcizm9zi12zi2zminplace_GHCiziObjLink_resolveObjs1_info
13+
cabalProjectLocal = lib.optionalString stdenv.hostPlatform.isStatic ''
14+
package th-dlls
15+
flags: -libsodium -openssl
16+
'';
1017
modules = import ../modules.nix ++ [({pkgs, ...}: lib.optionalAttrs externalInterpreter {
1118
packages.th-dlls.components.library.ghcOptions = [ "-fexternal-interpreter" ];
1219
# Static openssl seems to fail to load in iserv for musl

0 commit comments

Comments
 (0)