Skip to content

Commit 2f04bf4

Browse files
native aarch64 support
1 parent 7d4751b commit 2f04bf4

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

compiler/ghc/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# build-tools
99
, bootPkgs
10-
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx
10+
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx, numactl
1111
, autoreconfHook
1212
, bash
1313

@@ -102,7 +102,8 @@ let
102102
GhcRtsHcOpts += -fPIC
103103
'' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
104104
EXTRA_CC_OPTS += -std=gnu99
105-
'' + stdenv.lib.optionalString useLLVM ''
105+
# -fast-llvm causes incorrect code to be emitted (at least on aarch64)
106+
'' + stdenv.lib.optionalString (false) ''
106107
GhcStage2HcOpts += -fast-llvm
107108
GhcLibHcOpts += -fast-llvm
108109
'' + stdenv.lib.optionalString (!enableTerminfo) ''
@@ -146,7 +147,7 @@ in let configured-src = stdenv.mkDerivation (rec {
146147
# For building runtime libs
147148
depsBuildTarget = toolsForTarget;
148149

149-
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
150+
buildInputs = [ perl bash numactl ] ++ (libDeps hostPlatform);
150151

151152
propagatedBuildInputs = [ targetPackages.stdenv.cc ]
152153
++ stdenv.lib.optional useLLVM llvmPackages.llvm;
@@ -224,7 +225,7 @@ in let configured-src = stdenv.mkDerivation (rec {
224225

225226
outputs = [ "out" ];
226227
phases = [ "unpackPhase" "patchPhase" ]
227-
++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
228+
# ++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
228229
++ [ "configurePhase" "installPhase" ];
229230
installPhase = "cp -r . $out";
230231
});
@@ -286,12 +287,14 @@ in let configured-src = stdenv.mkDerivation (rec {
286287
nativeBuildInputs = [
287288
perl autoconf automake m4 python3 sphinx
288289
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
290+
# Bootstrapper will require this if it comes from Debian.
291+
numactl
289292
] ++ stdenv.lib.optional (patches != []) autoreconfHook;
290293

291294
# For building runtime libs
292295
depsBuildTarget = toolsForTarget;
293296

294-
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
297+
buildInputs = [ perl bash numactl ] ++ (libDeps hostPlatform);
295298

296299
propagatedBuildInputs = [ targetPackages.stdenv.cc ]
297300
++ stdenv.lib.optional useLLVM llvmPackages.llvm;

compiler/old-ghc-nix/old-ghc-nix.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"url": "https://github.com/angerman/old-ghc-nix",
3-
"rev": "bf640c1a3f55203bb7492a366c6492ff3c211332",
4-
"date": "2020-02-27T19:53:36+08:00",
5-
"sha256": "050g06911rpmvn66y5lmnszswz17flw3b979imdchc2apji6a1sm",
2+
"url": "https://github.com/TravisWhitaker/old-ghc-nix",
3+
"rev": "33b9b1f03c0e31d6a709237ec2940b26d4e084fb",
4+
"sha256": "1aaaaaav2r54hcp3gzw8dmi0c4rk59kwiv0jwwa3jny8llfr4ipd",
65
"fetchSubmodules": false
76
}

nix-tools/regenerate.nix

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ in
3939
# "stm" "terminfo"
4040
];
4141
}];
42-
}).nix-tools.components.exes.plan-to-nix; in
42+
}).nix-tools.components.exes.plan-to-nix;
43+
bootstrap = if pkgs.targetPlatform.isAarch64
44+
then haskell-nix.bootstrap.compiler.ghc882
45+
else haskell-nix.bootstrap.compiler.ghc844;
46+
in
4347
with builtins;
4448
with stdenv.lib;
4549
writeShellScriptBin "update-nix-tools" ''
@@ -53,12 +57,12 @@ writeShellScriptBin "update-nix-tools" ''
5357
cp ${src}/cabal.project .
5458
cp ${specJSON} ./nix-tools-src.json
5559
56-
# Build for ghc-8.4.4
60+
# Build for ${bootstrap.name}
5761
echo "--> Updating cabal index..."
5862
cabal v2-update -v0
59-
echo "--> Configuring nix-tools for ${haskell-nix.bootstrap.compiler.ghc844.name}..."
60-
cabal v2-configure -w ${getBin haskell-nix.bootstrap.compiler.ghc844}/bin/ghc -v0
61-
echo "--> Running plan-to-nix for ${haskell-nix.bootstrap.compiler.ghc844.name}..."
63+
echo "--> Configuring nix-tools for ${bootstrap.name}..."
64+
cabal v2-configure -w ${getBin bootstrap}/bin/ghc -v0
65+
echo "--> Running plan-to-nix for ${bootstrap.name}..."
6266
plan-to-nix -o . --plan-json=$(find . -name "plan.json")
6367
6468
rm cabal.project.local

overlays/bootstrap.nix

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ let
2828
fi
2929
done
3030
'';
31+
buildBootstrapper =
32+
if final.targetPlatform.isAarch64
33+
then final.buildPackages.haskell-nix.bootstrap.compiler.ghc882
34+
else final.buildPackages.haskell-nix.bootstrap.compiler.ghc844;
35+
buildBuildBootstrapper =
36+
if final.targetPlatform.isAarch64
37+
then final.buildPackages.buildPackages.haskell-nix.bootstrap.compiler.ghc882
38+
else final.buildPackages.buildPackages.haskell-nix.bootstrap.compiler.ghc844;
3139
in {
3240
haskell-nix = prev.haskell-nix // {
3341
# Use this to disable the existing haskell infra structure for testing purposes
3442
compiler =
3543
let bootPkgs = with final.buildPackages; {
36-
ghc = buildPackages.haskell-nix.bootstrap.compiler.ghc844;
44+
ghc = buildBuildBootstrapper;
3745
inherit (final.haskell-nix.bootstrap.packages) alex happy hscolour;
3846
};
3947
sphinx = with final.buildPackages; (python3Packages.sphinx_1_7_9 or python3Packages.sphinx);
@@ -341,7 +349,7 @@ in {
341349

342350

343351
# the bootstrap infra structure (pre-compiled ghc; bootstrapped cabal-install, ...)
344-
bootstrap = with final.haskell-nix; let ghc = final.buildPackages.haskell-nix.bootstrap.compiler.ghc844; in {
352+
bootstrap = with final.haskell-nix; let ghc = buildBootstrapper; in {
345353
# XXX: import ../. will throw away all other overlays, config values, ...
346354
# this is not ideal!
347355
# get binary compilers for bootstrapping. We'll put the eventual proper
@@ -395,7 +403,7 @@ in {
395403
# Only a boot compiler is suitable here
396404
ghcOverride = ghc // { isHaskellNixCompiler = ghc.isHaskellNixBootCompiler; };
397405
inherit (bootstrap.packages) cabal-install nix-tools hpack;
398-
name = "happy"; version = "1.19.11";
406+
name = "happy"; version = "1.19.12";
399407
index-state = final.haskell-nix.internalHackageIndexState;
400408
materialized = ../materialized/happy;
401409
};

0 commit comments

Comments
 (0)