Skip to content

Commit

Permalink
Fix arm cross compilation with ghc 8.6.5 (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack authored Jun 6, 2020
1 parent c1b7b46 commit 80e0e61
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nix-tools/regenerate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ in
];
}];
}).nix-tools.components.exes.plan-to-nix;
bootstrap = if pkgs.targetPlatform.isAarch64
bootstrap = if pkgs.targetPlatform.isAarch64 && pkgs.buildPlatform.isAarch64

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 6, 2020

Contributor

@hamishmack Hmm, shouldn't this be || instead? The ghc 8.8.x branch is the first that produces good code for arm, and ghc 8.6.5 can with patches. I don't think any previous versions will at all.

This comment has been minimized.

Copy link
@angerman

angerman Jun 6, 2020

Collaborator

The issue with || is that this causes aarch64 cross compilers to be bootstrapped with 8.8.2, thus breaking all existing 8.6.5 aarch64 cross compilers in Haskell.nix.

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 7, 2020

Contributor

Without patched memory ordering, 8.6.5 won't produce usable code for aarch64 anyway.

This comment has been minimized.

Copy link
@angerman

angerman Jun 8, 2020

Collaborator

Yea, that's in our 8.6.5 branch (well, or better in the #628). I'm trying to find time to get this into a more principled setup, where we have to deal less with patches but with some form of LTS ghc releases.

then haskell-nix.bootstrap.compiler.ghc882
else haskell-nix.bootstrap.compiler.ghc844;
in
Expand Down
29 changes: 13 additions & 16 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,21 @@ let
# - What GHC version we should use for bootstrapping.
# - What Happy version we should use for bootstrapping.
buildBootstrapper =
if final.targetPlatform.isAarch64
if final.targetPlatform.isAarch64 && final.buildPlatform.isAarch64

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 6, 2020

Contributor

Same.

then {
ghc = final.buildPackages.haskell-nix.bootstrap.compiler.ghc882;
compilerNixName = "ghc882";
happyVersion = "1.19.12";
}
else {
ghc = final.buildPackages.haskell-nix.bootstrap.compiler.ghc844;
compilerNixName = "ghc844";
happyVersion = "1.19.11";
};
# For buildPackages.buildPackages, we just care about the GHC version:
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 = buildBuildBootstrapper;
ghc = final.buildPackages.buildPackages.haskell-nix.bootstrap.compiler."${buildBootstrapper.compilerNixName}";
alex = final.haskell-nix.bootstrap.packages.alex-tool {
checkMaterialization = false;
};
Expand Down Expand Up @@ -338,9 +333,9 @@ in {
'' + installDeps targetPrefix);
})));

# Need to use something from 8.8.x as the default on aarch64:
# Need to use something from 8.8.x as the default to build aarch64 native compiler:
defaultCompilerNixName =
if final.targetPlatform.isAarch64
if final.targetPlatform.isAarch64 && final.buildPlatform.isAarch64

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 6, 2020

Contributor

Same.

then "ghc883"
else "ghc865";
ghc = final.haskell-nix.compiler."${final.haskell-nix.defaultCompilerNixName}";
Expand Down Expand Up @@ -426,7 +421,7 @@ in {
} // args);
alex = final.buildPackages.haskell-nix.alex-tool {};
happy-tool = args: final.haskell-nix.tool "happy" ({
version = buildBootstrapper.happyVersion;
version = "1.19.12";

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 6, 2020

Contributor

@angerman mentioned that we need to use 1.19.11 for ghc 8.6.x and older.

This comment has been minimized.

Copy link
@angerman

angerman Jun 6, 2020

Collaborator

This one should be fine as long as the one in boostrap is correct as that’s the one we feed into ghc when building it.

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 7, 2020

Contributor

Ahh I see; we only need 1.19.11 for building GHC itself.

index-state = final.haskell-nix.internalHackageIndexState;
materialized = ../materialized + "/${
args.compiler-nix-name or final.haskell-nix.defaultCompilerNixName
Expand Down Expand Up @@ -460,7 +455,9 @@ in {


# the bootstrap infra structure (pre-compiled ghc; bootstrapped cabal-install, ...)
bootstrap = with final.haskell-nix; let ghc = buildBootstrapper.ghc; in {
bootstrap = with final.haskell-nix;
let ghc = final.buildPackages.haskell-nix.bootstrap.compiler."${buildBootstrapper.compilerNixName}";
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 @@ -492,7 +489,7 @@ in {
# Only a boot compiler is suitable here
ghcOverride = ghc // { isHaskellNixCompiler = ghc.isHaskellNixBootCompiler; };
index-state = final.haskell-nix.internalHackageIndexState;
materialized = ../materialized/bootstrap/alex;
materialized = ../materialized/bootstrap + "/${buildBootstrapper.compilerNixName}/alex";
} // args);
alex = bootstrap.packages.alex-tool {};
happy-tool = args: tool "happy" ({
Expand All @@ -501,7 +498,7 @@ in {
ghcOverride = ghc // { isHaskellNixCompiler = ghc.isHaskellNixBootCompiler; };
inherit (bootstrap.packages) cabal-install nix-tools hpack;
index-state = final.haskell-nix.internalHackageIndexState;
materialized = ../materialized/bootstrap/happy;
materialized = ../materialized/bootstrap + "/${buildBootstrapper.compilerNixName}/happy-${buildBootstrapper.happyVersion}";
} // args);
happy = bootstrap.packages.happy-tool {};
hscolour-tool = args: (hackage-package ({
Expand All @@ -510,7 +507,7 @@ in {
# Only a boot compiler is suitable here
ghcOverride = ghc // { isHaskellNixCompiler = ghc.isHaskellNixBootCompiler; };
index-state = final.haskell-nix.internalHackageIndexState;
materialized = ../materialized/bootstrap/hscolour;
materialized = ../materialized/bootstrap + "/${buildBootstrapper.compilerNixName}/hscolour";
} // args)).components.exes.HsColour;
hscolour = bootstrap.packages.hscolour-tool {};
};
Expand Down
2 changes: 1 addition & 1 deletion overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ final: prev: {
snapshots = import ../snapshots.nix { inherit (final) lib ghc-boot-packages; inherit mkPkgSet stackage excludeBootPackages; };
# Pick a recent LTS snapshot to be our "default" package set.
haskellPackages =
if final.targetPlatform.isAarch64
if final.targetPlatform.isAarch64 && final.buildPlatform.isAarch64

This comment has been minimized.

Copy link
@TravisWhitaker

TravisWhitaker Jun 6, 2020

Contributor

Same.

then snapshots."lts-15.13"
else snapshots."lts-14.13";

Expand Down

0 comments on commit 80e0e61

Please sign in to comment.