Skip to content

Commit e5eab9e

Browse files
authored
Support aarch64-multiplatform-musl (#1911)
1 parent cb9cfa0 commit e5eab9e

File tree

46 files changed

+9328
-53
lines changed

Some content is hidden

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

46 files changed

+9328
-53
lines changed

builder/comp-builder.nix

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let self =
1414

1515
, preUnpack ? component.preUnpack, postUnpack ? component.postUnpack
1616
, configureFlags ? component.configureFlags
17+
, prePatch ? component.prePatch, postPatch ? component.postPatch
1718
, preConfigure ? component.preConfigure, postConfigure ? component.postConfigure
1819
, setupBuildFlags ? component.setupBuildFlags
1920
, preBuild ? component.preBuild , postBuild ? component.postBuild
@@ -42,9 +43,6 @@ let self =
4243

4344
, enableStatic ? component.enableStatic
4445
, enableShared ? ghc.enableShared && component.enableShared && !haskellLib.isCrossHost
45-
# on x86 we'll use shared libraries, even with musl m(
46-
# ghc's internal linker seems to be broken on x86.
47-
&& !(stdenv.hostPlatform.isMusl && !stdenv.hostPlatform.isx86)
4846
, enableDeadCodeElimination ? component.enableDeadCodeElimination
4947
, writeHieFiles ? component.writeHieFiles
5048

@@ -289,7 +287,7 @@ let
289287
lib.optionalString (cabal-generator == "hpack") ''
290288
${buildPackages.haskell-nix.internal-nix-tools}/bin/hpack
291289
''
292-
);
290+
) + lib.optionalString (prePatch != null) "\n${prePatch}";
293291
}
294292
# patches can (if they like) depend on the version of the package.
295293
// lib.optionalAttrs (patches != []) {
@@ -301,7 +299,7 @@ let
301299
}
302300
// haskellLib.optionalHooks {
303301
# These are hooks are needed to set up the source for building and running haddock
304-
inherit preUnpack postUnpack preConfigure postConfigure;
302+
inherit preUnpack postUnpack postPatch preConfigure postConfigure;
305303
}
306304
// lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") {
307305
LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive";

ci.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
# Musl cross only works on linux
8080
# aarch64 cross only works on linux
8181
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
82+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927"]) {
83+
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
84+
inherit (lib.systems.examples) aarch64-multiplatform-musl;
85+
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927" "ghc944" "ghc961"]) {
86+
inherit (lib.systems.examples) aarch64-multiplatform-musl;
8287
};
8388
isDisabled = d: d.meta.disabled or false;
8489
in

compiler/ghc/default.nix

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ let
231231
# value for us.
232232
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || stdenv.targetPlatform.isMusl);
233233

234-
inherit ((buildPackages.haskell-nix.cabalProject {
235-
compiler-nix-name = "ghc8107";
234+
hadrian = buildPackages.haskell-nix.tool "ghc8107" "hadrian" {
236235
compilerSelection = p: p.haskell.compiler;
237236
index-state = buildPackages.haskell-nix.internalHackageIndexState;
238237
# Verions of hadrian that comes with 9.6 depends on `time`
@@ -242,15 +241,23 @@ let
242241
else if builtins.compareVersions ghc-version "9.6" < 0
243242
then ../../materialized/ghc8107/hadrian-ghc94
244243
else ../../materialized/ghc8107/hadrian-ghc96;
244+
modules = [{
245+
# Apply the patches in a way that does not require using somethin
246+
# like `srcOnly`. The problem with `pkgs.srcOnly` was that it had to run
247+
# on a platform at eval time.
248+
packages.hadrian.prePatch = ''
249+
cd ..
250+
'';
251+
packages.hadrian.patches = ghc-patches;
252+
packages.hadrian.postPatch = ''
253+
cd hadrian
254+
'';
255+
}];
245256
src = haskell-nix.haskellLib.cleanSourceWith {
246-
src = buildPackages.srcOnly {
247-
name = "hadrian";
248-
inherit src;
249-
patches = ghc-patches;
250-
};
257+
inherit src;
251258
subDir = "hadrian";
252259
};
253-
}).hsPkgs.hadrian.components.exes) hadrian;
260+
};
254261

255262
# For a discription of hadrian command line args
256263
# see https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/README.md

lib/default.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,19 @@ in {
573573
inherit pkgs;
574574
inherit (pkgs.buildPackages.buildPackages) runCommand;
575575
};
576+
577+
# Here we try to figure out which qemu to use based on the host platform.
578+
# This guess can be overridden by passing qemuSuffix
579+
qemuByHostPlatform = hostPlatform:
580+
# I'd prefer this was a dictionary lookup, with a fall through into abort,
581+
# that would make this more readable I guess. I think there is some similar
582+
# mapping somewhere in haskell.nix
583+
if hostPlatform.isAarch32
584+
then "arm"
585+
else if hostPlatform.isAarch64
586+
then "aarch64"
587+
else abort "Don't know which QEMU to use for hostPlatform ${hostPlatform.config}. Please provide qemuSuffix";
588+
589+
# How to run ldd when checking for static linking
590+
lddForTests = "${pkgs.pkgsBuildBuild.glibc.bin}/bin/ldd";
576591
}

0 commit comments

Comments
 (0)