Skip to content

Commit

Permalink
WIP: native aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisWhitaker committed May 20, 2020
1 parent 7d4751b commit d3ac22a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
13 changes: 8 additions & 5 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# build-tools
, bootPkgs
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx, numactl
, autoreconfHook
, bash

Expand Down Expand Up @@ -102,7 +102,8 @@ let
GhcRtsHcOpts += -fPIC
'' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
EXTRA_CC_OPTS += -std=gnu99
'' + stdenv.lib.optionalString useLLVM ''
# -fast-llvm only works with -fno-plt; perhaps we should build GHC with that?
'' + stdenv.lib.optionalString (useLLVM && !targetPlatform.isAarch64) ''
GhcStage2HcOpts += -fast-llvm
GhcLibHcOpts += -fast-llvm
'' + stdenv.lib.optionalString (!enableTerminfo) ''
Expand Down Expand Up @@ -146,7 +147,7 @@ in let configured-src = stdenv.mkDerivation (rec {
# For building runtime libs
depsBuildTarget = toolsForTarget;

buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
buildInputs = [ perl bash numactl ] ++ (libDeps hostPlatform);

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

outputs = [ "out" ];
phases = [ "unpackPhase" "patchPhase" ]
++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
# ++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
++ [ "configurePhase" "installPhase" ];
installPhase = "cp -r . $out";
});
Expand Down Expand Up @@ -286,12 +287,14 @@ in let configured-src = stdenv.mkDerivation (rec {
nativeBuildInputs = [
perl autoconf automake m4 python3 sphinx
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
# Bootstrapper will require this if it comes from Debian.
numactl
] ++ stdenv.lib.optional (patches != []) autoreconfHook;

# For building runtime libs
depsBuildTarget = toolsForTarget;

buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
buildInputs = [ perl bash numactl ] ++ (libDeps hostPlatform);

propagatedBuildInputs = [ targetPackages.stdenv.cc ]
++ stdenv.lib.optional useLLVM llvmPackages.llvm;
Expand Down
7 changes: 3 additions & 4 deletions compiler/old-ghc-nix/old-ghc-nix.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"url": "https://github.com/angerman/old-ghc-nix",
"rev": "bf640c1a3f55203bb7492a366c6492ff3c211332",
"date": "2020-02-27T19:53:36+08:00",
"sha256": "050g06911rpmvn66y5lmnszswz17flw3b979imdchc2apji6a1sm",
"url": "https://github.com/TravisWhitaker/old-ghc-nix",
"rev": "59915b9dd1dc9c68c6fa4964cc38fa9124e59a75",
"sha256": "1qxbgzxv2r54hcp3gzw8dmi0c4rk59kwiv0jwwa3jny8llfr4ipd",
"fetchSubmodules": false
}
14 changes: 9 additions & 5 deletions nix-tools/regenerate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ in
# "stm" "terminfo"
];
}];
}).nix-tools.components.exes.plan-to-nix; in
}).nix-tools.components.exes.plan-to-nix;
bootstrap = if pkgs.targetPlatform.isAarch64
then haskell-nix.bootstrap.compiler.ghc882
else haskell-nix.bootstrap.compiler.ghc844;
in
with builtins;
with stdenv.lib;
writeShellScriptBin "update-nix-tools" ''
Expand All @@ -53,12 +57,12 @@ writeShellScriptBin "update-nix-tools" ''
cp ${src}/cabal.project .
cp ${specJSON} ./nix-tools-src.json
# Build for ghc-8.4.4
# Build for ${bootstrap.name}
echo "--> Updating cabal index..."
cabal v2-update -v0
echo "--> Configuring nix-tools for ${haskell-nix.bootstrap.compiler.ghc844.name}..."
cabal v2-configure -w ${getBin haskell-nix.bootstrap.compiler.ghc844}/bin/ghc -v0
echo "--> Running plan-to-nix for ${haskell-nix.bootstrap.compiler.ghc844.name}..."
echo "--> Configuring nix-tools for ${bootstrap.name}..."
cabal v2-configure -w ${getBin bootstrap}/bin/ghc -v0
echo "--> Running plan-to-nix for ${bootstrap.name}..."
plan-to-nix -o . --plan-json=$(find . -name "plan.json")
rm cabal.project.local
Expand Down
14 changes: 11 additions & 3 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ let
fi
done
'';
buildBootstrapper =
if final.targetPlatform.isAarch64
then final.buildPackages.haskell-nix.bootstrap.compiler.ghc882
else final.buildPackages.haskell-nix.bootstrap.compiler.ghc844;
buildBuildBootstrapper =
if final.targetPlatform.isAarch64
then final.buildPackages.buildPackages.haskell-nix.bootstrap.compiler.ghc882
else final.buildPackages.buildPackages.haskell-nix.bootstrap.compiler.ghc844;
in {
haskell-nix = prev.haskell-nix // {
# Use this to disable the existing haskell infra structure for testing purposes
compiler =
let bootPkgs = with final.buildPackages; {
ghc = buildPackages.haskell-nix.bootstrap.compiler.ghc844;
ghc = buildBuildBootstrapper;
inherit (final.haskell-nix.bootstrap.packages) alex happy hscolour;
};
sphinx = with final.buildPackages; (python3Packages.sphinx_1_7_9 or python3Packages.sphinx);
Expand Down Expand Up @@ -341,7 +349,7 @@ in {


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

0 comments on commit d3ac22a

Please sign in to comment.