Fix nativeBuildInputs and add cross compilation target #10

Manually merged
abonerib merged 17 commits from abonerib/bscpkgs:CIstrictDeps into master 2025-10-01 15:57:34 +02:00
Showing only changes of commit f338ef47d5 - Show all commits

View File

@ -13,8 +13,6 @@
, useMpi ? (stdenv.buildPlatform.canExecute stdenv.hostPlatform)
}:
with lib;
let
release = rec {
version = "1.12.0";
@ -45,7 +43,7 @@ in
postPatch = ''
patchShebangs --build test/
'';
nativeBuildInputs = [ cmake ];
nativeBuildInputs = [ cmake ] ++ lib.optionals (useMpi) [ mpi ];
rarias marked this conversation as resolved Outdated

Wouldn't we need mpi in buildInputs as well? I'm not sure how it works under the hood but it needs to pick the mpi libraries for the host architecture as if mpi were in buildInputs. I'm building .#pkgsCross.riscv64.ovni with useMPI to true to see what happens.

Wouldn't we need mpi in buildInputs as well? I'm not sure how it works under the hood but it needs to pick the mpi libraries for the host architecture as if mpi were in buildInputs. I'm building `.#pkgsCross.riscv64.ovni` with useMPI to true to see what happens.

I don't know either. We have useMpi ? (stdenv.buildPlatform.canExecute stdenv.hostPlatform) so by default we won't have mpi when cross compiling between architectures (not sure how binfmt emulation works with canExecute)

I don't know either. We have `useMpi ? (stdenv.buildPlatform.canExecute stdenv.hostPlatform)` so by default we won't have mpi when cross compiling between architectures (not sure how binfmt emulation works with canExecute)

It doesn't seem to be able to find MPI:

hut% nix log /nix/store/3il3bv2igpfzccfrd8zjwxd30s0lq2w9-ovni-riscv64-unknown-linux-gnu-1.12.0.drv | tail
-- Could NOT find MPI_C (missing: MPI_C_WORKS)
CMake Error at /nix/store/29ax4k0a83zhz43lb73cv610d95wdsx1-cmake-3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find MPI (missing: MPI_C_FOUND)
Call Stack (most recent call first):
  /nix/store/29ax4k0a83zhz43lb73cv610d95wdsx1-cmake-3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /nix/store/29ax4k0a83zhz43lb73cv610d95wdsx1-cmake-3.31.6/share/cmake-3.31/Modules/FindMPI.cmake:1842 (find_package_handle_standard_args)
  src/emu/CMakeLists.txt:107 (find_package)


-- Configuring incomplete, errors occurred!

I'll test adding it in buildInputs only, as I think cmake only looks for the libmpi.so library, it doesn't use the mpicc wrapper.

not sure how binfmt emulation works with canExecute

It doesn't rely on that, is done in evaluation time based on the architeture tuples:

a19a8e52c3/lib/systems/default.nix (L95)

a19a8e52c3/lib/systems/parse.nix (L436)

It doesn't seem to be able to find MPI: ``` hut% nix log /nix/store/3il3bv2igpfzccfrd8zjwxd30s0lq2w9-ovni-riscv64-unknown-linux-gnu-1.12.0.drv | tail -- Could NOT find MPI_C (missing: MPI_C_WORKS) CMake Error at /nix/store/29ax4k0a83zhz43lb73cv610d95wdsx1-cmake-3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message): Could NOT find MPI (missing: MPI_C_FOUND) Call Stack (most recent call first): /nix/store/29ax4k0a83zhz43lb73cv610d95wdsx1-cmake-3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE) /nix/store/29ax4k0a83zhz43lb73cv610d95wdsx1-cmake-3.31.6/share/cmake-3.31/Modules/FindMPI.cmake:1842 (find_package_handle_standard_args) src/emu/CMakeLists.txt:107 (find_package) -- Configuring incomplete, errors occurred! ``` I'll test adding it in buildInputs only, as I think cmake only looks for the libmpi.so library, it doesn't use the mpicc wrapper. > not sure how binfmt emulation works with canExecute It doesn't rely on that, is done in evaluation time based on the architeture tuples: https://github.com/NixOS/nixpkgs/blob/a19a8e52c326b80a2c203724ed68c7e16b365683/lib/systems/default.nix#L95 https://github.com/NixOS/nixpkgs/blob/a19a8e52c326b80a2c203724ed68c7e16b365683/lib/systems/parse.nix#L436
buildInputs = lib.optionals (useMpi) [ mpi ];
cmakeBuildType = if (enableDebug) then "Debug" else "Release";
cmakeFlags = [