Skip to content

Commit

Permalink
Fixes for aarch64 cross compile tests (#2105)
Browse files Browse the repository at this point in the history
* Fixes for aarch64 cross compile tests

* More fixes

* More fixes

* More fixes

* More fixes

* Skip broken tests

* Remove trailing space
  • Loading branch information
hamishmack authored Nov 10, 2023
1 parent a125c5b commit 377a426
Showing 14 changed files with 54 additions and 22 deletions.
2 changes: 1 addition & 1 deletion modules/cabal-project.nix
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ in {
ghc99FullName = pkgs.haskell-nix.resolve-compiler-name "ghc99";
in
# cabal-install from hackage (3.10.1.0) does not build with GHC HEAD
if fullName == ghc99FullName && config.name == "cabal-install" && (builtins.elem config.version ["3.10.1.0" "3.10.2.0"])
if fullName == ghc99FullName && config.name == "cabal-install" && (builtins.elem config.version ["3.10.1.0" "3.10.2.0" "3.10.2.1"])
then "ghc963"
else pkgs.haskell-nix.resolve-compiler-name name;
};
3 changes: 2 additions & 1 deletion overlays/armv6l-linux.nix
Original file line number Diff line number Diff line change
@@ -6,7 +6,8 @@ final: prev:
let
withTH = import ./linux-cross.nix {
inherit (pkgs.stdenv) hostPlatform buildPlatform;
inherit (pkgs) stdenv lib writeScriptBin;
inherit (pkgs) stdenv lib;
inherit (pkgs.pkgsBuildBuild) writeShellScriptBin symlinkJoin;
inherit (pkgs.haskell-nix) haskellLib;
# qemu for linux
# Using `buildPackages.buildPackages` here fixes `python3Packages.pygobject3` issue.
25 changes: 16 additions & 9 deletions overlays/linux-cross.nix
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
{ stdenv
, lib
, haskellLib
, writeScriptBin
, writeShellScriptBin
, qemu
, qemuSuffix ? (haskellLib.qemuByHostPlatform hostPlatform)
, iserv-proxy
, iserv-proxy-interpreter
, gmp
, buildPlatform
, hostPlatform
, symlinkJoin
, ...
}:
let

# we want this to hold only for arm (32 and 64bit) for now.
isLinuxCross = haskellLib.isCrossHost && hostPlatform.isLinux && (hostPlatform.isAarch32 || hostPlatform.isAarch64);
qemuIservWrapper = writeScriptBin "iserv-wrapper" ''
#!${stdenv.shell}
qemuIservWrapperScript = enableProfiling:
let
interpreter =
if enableProfiling
then iserv-proxy-interpreter.override { inherit enableProfiling; }
else iserv-proxy-interpreter;
in
writeShellScriptBin ("iserv-wrapper" + lib.optionalString enableProfiling "-prof") ''
set -euo pipefail
# Unset configure flags as configure should have run already
unset configureFlags
PORT=$((5000 + $RANDOM % 5000))
(>&2 echo "---> Starting ${iserv-proxy-interpreter.exeName} on port $PORT")
${qemu}/bin/qemu-${qemuSuffix} ${iserv-proxy-interpreter.override (lib.optionalAttrs hostPlatform.isAndroid { setupBuildFlags = ["--ghc-option=-optl-static" ];})}/bin/${iserv-proxy-interpreter.exeName} tmp $PORT &
(>&2 echo "---| ${iserv-proxy-interpreter.exeName} should have started on $PORT")
(>&2 echo "---> Starting ${interpreter.exeName} on port $PORT")
${qemu}/bin/qemu-${qemuSuffix} ${interpreter.override (lib.optionalAttrs hostPlatform.isAndroid { setupBuildFlags = ["--ghc-option=-optl-static" ];})}/bin/${interpreter.exeName} tmp $PORT &
(>&2 echo "---| ${interpreter.exeName} should have started on $PORT")
RISERV_PID="$!"
${iserv-proxy}/bin/iserv-proxy $@ 127.0.0.1 "$PORT"
(>&2 echo "---> killing ${iserv-proxy-interpreter.exeName}...")
(>&2 echo "---> killing ${interpreter.exeName}...")
kill $RISERV_PID
'';
qemuIservWrapper = symlinkJoin { name = "iserv-wrapper"; paths = [ (qemuIservWrapperScript false) (qemuIservWrapperScript true) ]; };
configureFlags = lib.optional hostPlatform.isAarch32 "--disable-split-sections";
setupBuildFlags = map (opt: "--ghc-option=" + opt) ((lib.optionals isLinuxCross
[ "-fexternal-interpreter"
@@ -39,8 +47,7 @@ let
++ lib.optionals hostPlatform.isAarch32 (map (opt: "--gcc-option=" + opt) [ "-fno-pic" "-fno-plt" ])
# Also for GHC #15275
++ lib.optionals hostPlatform.isAarch64 ["--gcc-option=-fPIC"];
qemuTestWrapper = writeScriptBin "test-wrapper" ''
#!${stdenv.shell}
qemuTestWrapper = writeShellScriptBin "test-wrapper" ''
set -euo pipefail
${qemu}/bin/qemu-${qemuSuffix} $@*
'';
5 changes: 4 additions & 1 deletion test/cabal-simple-prof/default.nix
Original file line number Diff line number Diff line change
@@ -18,7 +18,10 @@ let
project = cabalProject' {
inherit compiler-nix-name evalPackages;
src = testSrc "cabal-simple-prof";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
inherit modules;
};

5 changes: 4 additions & 1 deletion test/cabal-simple/default.nix
Original file line number Diff line number Diff line change
@@ -15,7 +15,10 @@ let
project = project' {
inherit compiler-nix-name evalPackages;
src = testSrc "cabal-simple";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
inherit modules;
};

5 changes: 4 additions & 1 deletion test/cabal-source-repo-comments/default.nix
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@ let
project = cabalProject' {
inherit compiler-nix-name evalPackages;
src = testSrc "cabal-source-repo-comments";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
};
packages = project.hsPkgs;
in recurseIntoAttrs {
5 changes: 4 additions & 1 deletion test/cabal-source-repo/default.nix
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@ let
project = cabalProject' {
inherit compiler-nix-name evalPackages;
src = testSrc "cabal-source-repo";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
};
packages = project.hsPkgs;
in recurseIntoAttrs {
5 changes: 4 additions & 1 deletion test/cabal-sublib/default.nix
Original file line number Diff line number Diff line change
@@ -16,7 +16,10 @@ let
project = cabalProject' {
inherit compiler-nix-name evalPackages;
src = testSrc "cabal-sublib";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
inherit modules;
};

5 changes: 4 additions & 1 deletion test/call-cabal-project-to-nix/default.nix
Original file line number Diff line number Diff line change
@@ -9,7 +9,10 @@ let
inherit compiler-nix-name evalPackages;
# reuse the cabal-simple test project
src = testSrc "cabal-simple";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
};
pkgSet = mkCabalProjectPkgSet {
plan-pkgs = importAndFilterProject {
5 changes: 4 additions & 1 deletion test/exe-only/default.nix
Original file line number Diff line number Diff line change
@@ -7,7 +7,10 @@ let
project = haskell-nix.cabalProject' {
inherit compiler-nix-name evalPackages;
src = testSrc "exe-only";
cabalProjectLocal = builtins.readFile ../cabal.project.local;
cabalProjectLocal = builtins.readFile ../cabal.project.local
+ lib.optionalString (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64) ''
constraints: text -simdutf, text source
'';
};

packages = project.hsPkgs;
1 change: 1 addition & 0 deletions test/ghcjs-overlay/default.nix
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ in recurseIntoAttrs {
touch $out
'';
meta.platforms = platforms.all;
meta.disabled = haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64;
passthru = {
inherit project;
};
4 changes: 2 additions & 2 deletions test/shell-for/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name, evalPackages }:
{ stdenv, lib, haskellLib, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name, evalPackages }:

with lib;

@@ -54,7 +54,7 @@ let
in recurseIntoAttrs {
# Does not work on ghcjs because it needs zlib.
# Does not work on windows because it needs mintty.
meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isGhcjs || stdenv.hostPlatform.isWindows
meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isGhcjs || stdenv.hostPlatform.isWindows || (haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64)
|| compiler-nix-name != ((import ./pkgs.nix).pkgs null).compiler.nix-name;
inherit env envPkga envDefault;
run = stdenv.mkDerivation {
2 changes: 2 additions & 0 deletions test/th-dlls/default.nix
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ in recurseIntoAttrs {
meta.disabled = stdenv.hostPlatform.isGhcjs
# On aarch64 this test also breaks form musl builds (including cross compiles on x86_64-linux)
|| (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isMusl)
# Failed to lookup symbol: __aarch64_swp8_acq_rel
|| (compiler-nix-name == "ghc947" && haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64)
;

ifdInputs = {
4 changes: 2 additions & 2 deletions test/with-packages/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, util, cabalProject', recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages, buildPackages }:
{ stdenv, lib, haskellLib, util, cabalProject', recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages, buildPackages }:

with lib;
with util;
@@ -76,7 +76,7 @@ in recurseIntoAttrs {
printf "checking that the 'library' with doExactConfig works... " >& 2
echo ${decLibrary} >& 2
'' + (if stdenv.hostPlatform.isWindows || stdenv.hostPlatform.isGhcjs
'' + (if haskellLib.isCrossHost
then ''
printf "runghc tests are not working yet for windows or ghcjs. skipping. " >& 2
''

0 comments on commit 377a426

Please sign in to comment.