Skip to content

Commit c590cae

Browse files
committed
ghc: 9.6.6-debian-binary for powerpc64le, too
Build on NixOS#439258 to bootstrap GHC on powerpc64le in the same way: using the Debian package. Move the conditionals in top-level/haskell-packages.nix to probe for support from the 9.6.6-debian-binary.nix package so it's easier to do the same thing for other architectures, too, should anyone else need it.
1 parent 92d40f8 commit c590cae

2 files changed

Lines changed: 73 additions & 52 deletions

File tree

pkgs/development/compilers/ghc/9.6.6-debian-binary.nix

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,33 @@ let
2323
# GHC upstream doesn't release bindist tarballs for some platforms.
2424
# We're using Debian's binary package, and patching it into a usable-in-Nixpkgs state.
2525
ghcDebs = {
26+
powerpc64le-linux = {
27+
src = {
28+
urls = [
29+
"http://ftp.debian.org/debian/pool/main/g/ghc/ghc_9.6.6-4_ppc64el.deb"
30+
];
31+
sha256 = "6dd14937485831c72aef62851c4251f2afa2c7a06a2d4956e25a1f82ab195a01";
32+
};
33+
exePathForLibraryCheck = null;
34+
archSpecificLibraries = [
35+
{
36+
nixPackage = gmp;
37+
fileToCheckFor = null;
38+
}
39+
{
40+
nixPackage = ncurses6;
41+
fileToCheckFor = "libtinfo.so.6";
42+
}
43+
{
44+
nixPackage = numactl;
45+
fileToCheckFor = null;
46+
}
47+
{
48+
nixPackage = libffi;
49+
fileToCheckFor = null;
50+
}
51+
];
52+
};
2653
powerpc64-linux = {
2754
src = {
2855
urls = [
@@ -50,6 +77,8 @@ let
5077
fileToCheckFor = null;
5178
}
5279
];
80+
81+
platforms = lib.systems.inspect.patterns.isAbiElfv1;
5382
};
5483
};
5584

@@ -191,11 +220,11 @@ stdenv.mkDerivation (finalAttrs: {
191220
# Patch ghc settings
192221
+ ''
193222
substituteInPlace $out/lib/ghc/lib/settings \
194-
--replace-fail powerpc64-linux-gnu-gcc gcc \
195-
--replace-fail powerpc64-linux-gnu-g++ g++ \
196-
--replace-fail powerpc64-linux-gnu-ld ld \
197-
--replace-fail powerpc64-linux-gnu-ar ar \
198-
--replace-fail powerpc64-linux-gnu-ranlib ranlib \
223+
--replace-fail ${stdenv.hostPlatform.system}-gnu-gcc gcc \
224+
--replace-fail ${stdenv.hostPlatform.system}-gnu-g++ g++ \
225+
--replace-fail ${stdenv.hostPlatform.system}-gnu-ld ld \
226+
--replace-fail ${stdenv.hostPlatform.system}-gnu-ar ar \
227+
--replace-fail ${stdenv.hostPlatform.system}-gnu-ranlib ranlib \
199228
--replace-fail llc-18 llc \
200229
--replace-fail opt-18 opt
201230
'';
@@ -262,7 +291,26 @@ stdenv.mkDerivation (finalAttrs: {
262291
homepage = "http://haskell.org/ghc";
263292
description = "Glasgow Haskell Compiler";
264293
license = lib.licenses.bsd3;
265-
platforms = builtins.attrNames ghcDebs;
294+
295+
# ghcDebs is keyed on the system double (cpu-kernel), and each entry may
296+
# additionally constrain the choice of platforms with a system inspection
297+
# pattern.
298+
platforms = builtins.map (
299+
system:
300+
let
301+
isThis = lib.attrsets.filterAttrs (
302+
n: v:
303+
builtins.elem n [
304+
"cpu"
305+
"kernel"
306+
]
307+
) (lib.systems.parse.mkSystemFromString system);
308+
in
309+
if ghcDebs.${system} ? platforms then
310+
lib.systems.inspect.patternLogicalAnd isThis ghcDebs.${system}.platforms
311+
else
312+
isThis
313+
) (builtins.attrNames ghcDebs);
266314
maintainers = [ lib.maintainers.OPNA2608 ];
267315
teams = [ lib.teams.haskell ];
268316
};

pkgs/top-level/haskell-packages.nix

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
newScope,
77
stdenv,
88
config,
9+
lib,
910
}:
1011

1112
let
@@ -89,6 +90,14 @@ in
8990
compiler = pkgs.lib.recurseIntoAttrs (
9091
let
9192
bb = pkgsBuildBuild.haskell;
93+
94+
# No bindist, "borrowing" the GHC from Debian
95+
useDebianBinaryOr =
96+
pkg:
97+
if lib.meta.availableOn stdenv.hostPlatform bb.packages.ghc966DebianBinary.ghc then
98+
bb.packages.ghc966DebianBinary
99+
else
100+
pkg;
92101
in
93102
{
94103
# Required to bootstrap 9.4.8.
@@ -110,67 +119,31 @@ in
110119
inherit buildTargetLlvmPackages llvmPackages;
111120
};
112121
ghc967 = callPackage ../development/compilers/ghc/9.6.7.nix {
113-
bootPkgs =
114-
if
115-
stdenv.buildPlatform.isPower64
116-
&& stdenv.buildPlatform.isBigEndian
117-
&& pkgs.stdenv.hostPlatform.isAbiElfv1
118-
then
119-
# No bindist, "borrowing" the GHC from Debian
120-
bb.packages.ghc966DebianBinary
121-
else
122-
bb.packages.ghc948;
122+
bootPkgs = useDebianBinaryOr bb.packages.ghc948;
123123
inherit (buildPackages.python3Packages) sphinx;
124124
inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook;
125125
inherit buildTargetLlvmPackages llvmPackages;
126126
};
127127
ghc984 = callPackage ../development/compilers/ghc/9.8.4.nix {
128-
bootPkgs =
129-
if
130-
stdenv.buildPlatform.isPower64
131-
&& stdenv.buildPlatform.isBigEndian
132-
&& pkgs.stdenv.hostPlatform.isAbiElfv1
133-
then
134-
# No bindist, "borrowing" the GHC from Debian
135-
bb.packages.ghc966DebianBinary
136-
else if stdenv.buildPlatform.isi686 then
137-
bb.packages.ghc948
138-
else
139-
bb.packages.ghc984Binary;
128+
bootPkgs = useDebianBinaryOr (
129+
if stdenv.buildPlatform.isi686 then bb.packages.ghc948 else bb.packages.ghc984Binary
130+
);
140131
inherit (buildPackages.python3Packages) sphinx;
141132
inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook;
142133
inherit buildTargetLlvmPackages llvmPackages;
143134
};
144135
ghc9102 = callPackage ../development/compilers/ghc/9.10.2.nix {
145-
bootPkgs =
146-
if
147-
stdenv.buildPlatform.isPower64
148-
&& stdenv.buildPlatform.isBigEndian
149-
&& pkgs.stdenv.hostPlatform.isAbiElfv1
150-
then
151-
# No bindist, "borrowing" the GHC from Debian
152-
bb.packages.ghc966DebianBinary
153-
else if stdenv.buildPlatform.isi686 then
154-
bb.packages.ghc967
155-
else
156-
bb.packages.ghc984Binary;
136+
bootPkgs = useDebianBinaryOr (
137+
if stdenv.buildPlatform.isi686 then bb.packages.ghc967 else bb.packages.ghc984Binary
138+
);
157139
inherit (buildPackages.python3Packages) sphinx;
158140
inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook;
159141
inherit buildTargetLlvmPackages llvmPackages;
160142
};
161143
ghc9103 = callPackage ../development/compilers/ghc/9.10.3.nix {
162-
bootPkgs =
163-
if
164-
stdenv.buildPlatform.isPower64
165-
&& stdenv.buildPlatform.isBigEndian
166-
&& pkgs.stdenv.hostPlatform.isAbiElfv1
167-
then
168-
# No bindist, "borrowing" the GHC from Debian
169-
bb.packages.ghc966DebianBinary
170-
else if stdenv.buildPlatform.isi686 then
171-
bb.packages.ghc967
172-
else
173-
bb.packages.ghc984Binary;
144+
bootPkgs = useDebianBinaryOr (
145+
if stdenv.buildPlatform.isi686 then bb.packages.ghc967 else bb.packages.ghc984Binary
146+
);
174147
inherit (buildPackages.python3Packages) sphinx;
175148
inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook;
176149
inherit buildTargetLlvmPackages llvmPackages;

0 commit comments

Comments
 (0)