From 410040a4a00d21cd824c909e75628a736c61730a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Fri, 10 Oct 2025 10:45:41 +0200 Subject: [PATCH 1/7] Fix mpich cross compilation (disable fortran) Reviewed-by: Rodrigo Arias Mallo --- pkgs/mpich/default.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkgs/mpich/default.nix b/pkgs/mpich/default.nix index 1afa9b71..c580c717 100644 --- a/pkgs/mpich/default.nix +++ b/pkgs/mpich/default.nix @@ -6,6 +6,12 @@ , pmix , gfortran , symlinkJoin +# Disabled when cross-compiling +# To fix cross compilation, we should fill the values in: +# https://github.com/pmodels/mpich/blob/main/maint/fcrosscompile/cross_values.txt.in +# For each arch +, enableFortran ? stdenv.hostPlatform == stdenv.buildPlatform +, perl }: let @@ -15,10 +21,13 @@ let paths = [ pmix.dev pmix.out ]; }; in mpich.overrideAttrs (old: { - buildInput = old.buildInputs ++ [ + buildInputs = old.buildInputs ++ [ libfabric pmixAll ]; + nativeBuildInputs = old.nativeBuildInputs ++ [ + perl + ]; configureFlags = [ "--enable-shared" "--enable-sharedlib" @@ -31,7 +40,17 @@ in mpich.overrideAttrs (old: { ] ++ lib.optionals (lib.versionAtLeast gfortran.version "10") [ "FFLAGS=-fallow-argument-mismatch" # https://github.com/pmodels/mpich/issues/4300 "FCFLAGS=-fallow-argument-mismatch" + ] ++ lib.optionals (!enableFortran) [ + "--disable-fortran" ]; + + preFixup = '' + sed -i 's:^CC=.*:CC=gcc:' $out/bin/mpicc + sed -i 's:^CXX=.*:CXX=g++:' $out/bin/mpicxx + '' + lib.optionalString enableFortran '' + sed -i 's:^FC=.*:FC=gfortran:' $out/bin/mpifort + ''; + hardeningDisable = [ "all" ]; meta = old.meta // { -- 2.49.0 From 39d64456a4c720bea198fa6f104bbfa13e6a1eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Fri, 10 Oct 2025 11:56:18 +0200 Subject: [PATCH 2/7] Fix nativeBuildInputs for gpi-2 Reviewed-by: Rodrigo Arias Mallo --- pkgs/gpi-2/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/gpi-2/default.nix b/pkgs/gpi-2/default.nix index a341f369..74bf196e 100644 --- a/pkgs/gpi-2/default.nix +++ b/pkgs/gpi-2/default.nix @@ -9,7 +9,6 @@ , automake , libtool , mpi -, rsync , gfortran }: @@ -44,13 +43,24 @@ stdenv.mkDerivation rec { configureFlags = [ "--with-infiniband=${rdma-core-all}" - "--with-mpi=${mpiAll}" + "--with-mpi=yes" # fixes mpi detection when cross-compiling "--with-slurm" "CFLAGS=-fPIC" "CXXFLAGS=-fPIC" ]; - buildInputs = [ slurm mpiAll rdma-core-all autoconf automake libtool rsync gfortran ]; + nativeBuildInputs = [ + autoconf + automake + gfortran + libtool + ]; + + buildInputs = [ + slurm + mpiAll + rdma-core-all + ]; hardeningDisable = [ "all" ]; -- 2.49.0 From 08633435cf9fed795967e0b0954f9f368c2d5418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Thu, 30 Oct 2025 15:09:49 +0100 Subject: [PATCH 3/7] Fix nativeBuildInputs for tagaspi Reviewed-by: Rodrigo Arias Mallo --- pkgs/tagaspi/default.nix | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pkgs/tagaspi/default.nix b/pkgs/tagaspi/default.nix index 5f1d7340..9e9ce813 100644 --- a/pkgs/tagaspi/default.nix +++ b/pkgs/tagaspi/default.nix @@ -5,23 +5,14 @@ , automake , autoconf , libtool -, mpi , autoreconfHook , gpi-2 , boost , numactl , rdma-core , gfortran -, symlinkJoin }: -let - mpiAll = symlinkJoin { - name = "mpi-all"; - paths = [ mpi.all ]; - }; -in - stdenv.mkDerivation rec { pname = "tagaspi"; enableParallelBuilding = true; @@ -35,16 +26,18 @@ stdenv.mkDerivation rec { hash = "sha256-RGG/Re2uM293HduZfGzKUWioDtwnSYYdfeG9pVrX9EM="; }; - buildInputs = [ + nativeBuildInputs = [ autoreconfHook automake autoconf libtool + gfortran + ]; + + buildInputs = [ boost numactl rdma-core - gfortran - mpiAll ]; dontDisableStatic = true; -- 2.49.0 From 86eb7967716d45f81d46d1285d9131e23242fde3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Thu, 30 Oct 2025 15:32:09 +0100 Subject: [PATCH 4/7] Disable meta.cross for gpi-2 and tagaspi Reviewed-by: Rodrigo Arias Mallo --- pkgs/gpi-2/default.nix | 1 + pkgs/tagaspi/default.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/pkgs/gpi-2/default.nix b/pkgs/gpi-2/default.nix index 74bf196e..428a270b 100644 --- a/pkgs/gpi-2/default.nix +++ b/pkgs/gpi-2/default.nix @@ -70,5 +70,6 @@ stdenv.mkDerivation rec { maintainers = with lib.maintainers.bsc; [ rarias ]; platforms = lib.platforms.linux; license = lib.licenses.gpl3Plus; + cross = false; # infiniband detection does not work }; } diff --git a/pkgs/tagaspi/default.nix b/pkgs/tagaspi/default.nix index 9e9ce813..94c28e37 100644 --- a/pkgs/tagaspi/default.nix +++ b/pkgs/tagaspi/default.nix @@ -56,5 +56,6 @@ stdenv.mkDerivation rec { maintainers = with lib.maintainers.bsc; [ rarias ]; platforms = lib.platforms.linux; license = lib.licenses.gpl3Plus; + cross = false; # gpi-2 cannot cross }; } -- 2.49.0 From a761b7333622a90b0224eed974242480093183e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Thu, 30 Oct 2025 15:34:14 +0100 Subject: [PATCH 5/7] Enable meta.cross for mpich related packages Reviewed-by: Rodrigo Arias Mallo --- pkgs/mpich/default.nix | 1 + pkgs/osu/default.nix | 1 + pkgs/sonar/default.nix | 1 + pkgs/tampi/default.nix | 1 + 4 files changed, 4 insertions(+) diff --git a/pkgs/mpich/default.nix b/pkgs/mpich/default.nix index c580c717..595e6ad2 100644 --- a/pkgs/mpich/default.nix +++ b/pkgs/mpich/default.nix @@ -55,5 +55,6 @@ in mpich.overrideAttrs (old: { meta = old.meta // { maintainers = old.meta.maintainers ++ (with lib.maintainers.bsc; [ rarias ]); + cross = true; }; }) diff --git a/pkgs/osu/default.nix b/pkgs/osu/default.nix index a1aa6450..12da65bf 100644 --- a/pkgs/osu/default.nix +++ b/pkgs/osu/default.nix @@ -44,5 +44,6 @@ stdenv.mkDerivation rec { homepage = "http://mvapich.cse.ohio-state.edu/benchmarks/"; maintainers = [ ]; platforms = lib.platforms.all; + cross = true; }; } diff --git a/pkgs/sonar/default.nix b/pkgs/sonar/default.nix index 36a5ef8a..ac062a60 100644 --- a/pkgs/sonar/default.nix +++ b/pkgs/sonar/default.nix @@ -35,5 +35,6 @@ stdenv.mkDerivation rec { maintainers = with lib.maintainers.bsc; [ rarias ]; platforms = lib.platforms.linux; license = lib.licenses.mit; + cross = true; }; } diff --git a/pkgs/tampi/default.nix b/pkgs/tampi/default.nix index 15e48dee..16b2e4b6 100644 --- a/pkgs/tampi/default.nix +++ b/pkgs/tampi/default.nix @@ -68,5 +68,6 @@ in stdenv.mkDerivation { maintainers = with lib.maintainers.bsc; [ rarias ]; platforms = lib.platforms.linux; license = lib.licenses.gpl3Plus; + cross = true; }; } -- 2.49.0 From 2fff7e4a7b231c322d83e4429812b4b26504e83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Fri, 31 Oct 2025 11:05:35 +0100 Subject: [PATCH 6/7] Set mpich default compilers from targetPackages Reviewed-by: Rodrigo Arias Mallo --- pkgs/mpich/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/mpich/default.nix b/pkgs/mpich/default.nix index 595e6ad2..ec2eede4 100644 --- a/pkgs/mpich/default.nix +++ b/pkgs/mpich/default.nix @@ -12,6 +12,7 @@ # For each arch , enableFortran ? stdenv.hostPlatform == stdenv.buildPlatform , perl +, targetPackages }: let @@ -45,10 +46,10 @@ in mpich.overrideAttrs (old: { ]; preFixup = '' - sed -i 's:^CC=.*:CC=gcc:' $out/bin/mpicc - sed -i 's:^CXX=.*:CXX=g++:' $out/bin/mpicxx + sed -i 's:^CC=.*:CC=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' $out/bin/mpicc + sed -i 's:^CXX=.*:CXX=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}c++:' $out/bin/mpicxx '' + lib.optionalString enableFortran '' - sed -i 's:^FC=.*:FC=gfortran:' $out/bin/mpifort + sed -i 's:^FC=.*:FC=${targetPackages.gfortran or gfortran}/bin/${targetPackages.gfortran.targetPrefix or gfortran.targetPrefix}gfortran:' $out/bin/mpifort ''; hardeningDisable = [ "all" ]; -- 2.49.0 From a173af654f6290c48f1a2fd128c9d008283b157d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Fri, 31 Oct 2025 10:52:47 +0100 Subject: [PATCH 7/7] Fix osu cross-compilation Reviewed-by: Rodrigo Arias Mallo --- pkgs/osu/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/osu/default.nix b/pkgs/osu/default.nix index 12da65bf..b35fad9b 100644 --- a/pkgs/osu/default.nix +++ b/pkgs/osu/default.nix @@ -32,6 +32,11 @@ stdenv.mkDerivation rec { "CXX=mpicxx" ]; + env = { + MPICH_CC="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; + MPICH_CXX="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; + }; + postInstall = '' mkdir -p $out/bin for f in $(find $out -executable -type f); do -- 2.49.0