Skip to content

Commit c23f9c3

Browse files
native aarch64 support
1 parent 7d4751b commit c23f9c3

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

compiler/ghc/default.nix

Lines changed: 6 additions & 4 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) ''
@@ -119,7 +120,8 @@ let
119120
libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
120121
++ [targetLibffi]
121122
++ stdenv.lib.optional (!enableIntegerSimple) gmp
122-
++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
123+
++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
124+
++ stdenv.lib.optional platform.isLinux numactl;
123125

124126
toolsForTarget =
125127
if hostPlatform == buildPlatform then
@@ -224,7 +226,7 @@ in let configured-src = stdenv.mkDerivation (rec {
224226

225227
outputs = [ "out" ];
226228
phases = [ "unpackPhase" "patchPhase" ]
227-
++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
229+
# ++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
228230
++ [ "configurePhase" "installPhase" ];
229231
installPhase = "cp -r . $out";
230232
});

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": "0d136da6e48de6d1256c8aa2b281662e93f9e486",
4+
"sha256": "1cp6aksb6ldgjb5zyqikyjrjij79n9z7wd86migph0wp19vmszkf",
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)