Fix nativeBuildInputs and add cross compilation target #10
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "abonerib/bscpkgs:CIstrictDeps"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I tried to build our packages with strictDeps to fix some low-hanging fruit.
These are the initial steps towards #13
I think this is the same case I commented with @arocanon this week, the
clangOmpss2UnwrappedinsideclangOmpss2caches the previous value which has a x86 architecture. I proposed explicitly taking the package from buildPackages but maybe there is a cleaner solution:What does strictDeps do internally?, is it documented somewhere else apart from the scattered bash scripts that build stdenv? I'm not sure what are the implications of enabling it for all of our derivations.
If the objective is to make packages suitable for cross compilation, wouldn't it be more realistic to build them from
pkgsCross.riscv64for example? Notice we emulate riscv64 in hut, so to make sure they build without extra help we would need to test them in a machine with no emulation or choose a non emulated architecture.There are things that change outside the buildInputs/nativeBuildInputs that would cause the cross compilation to break, for example
ovniwill disable MPI if the build platform cannot execute in the host platform:Or internal checks, for example PAPI will refuse to cross compile unless ffsll is specified:
This could be tested by building:
I could not find where (if) it is documented, but there is a recent(ish) push in nixpkgs to enable
strictDepswherever possible:To my understanding, with strictDeps, nativeBuildInputs are added to PATH and buildInputs are added to PKG_CONFIG, CFLAGS, LD_... (found this explanation in discourse)
That is the end goal, but as you said, there are a lot of factors outside buildInputs/nativeBuildInputs that make this impractical. I don't expect
nix build .#pkgsCross.riscv64.bsc-ci.allto work for all our packages in the short term.With strictDeps we can be reasonably sure that our derivations are correct before attempting to cross-compile.
Consider this example when trying to cross compile some package with an incorrect derivation with
buildInputs = [ clangOmpss2 ];riscv64-clangOmpss2With
strictDepswe can catch this error in x86 without going through a whole LLVM compilation.08161bf291to4ba86c9ec0WIP: Enable strictDeps and fix nativeBuildInputsto Fix nativeBuildInputs@ -47,3 +45,2 @@'';nativeBuildInputs = [ cmake ];buildInputs = lib.optionals (useMpi) [ mpi ];nativeBuildInputs = [ cmake ] ++ lib.optionals (useMpi) [ mpi ];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.ovniwith 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)It doesn't seem to be able to find MPI:
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.
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)4ba86c9ec0to00716387010071638701to0cb908d0e50cb908d0e5to22e66259f422e66259f4tobed3d8ce31bed3d8ce31tod1e43dba344d631b7974to8871e10ceafb3661ec7cto8871e10cea@ -19,2 +19,4 @@hydraJobs = {inherit (self.legacyPackages.${system}.bsc-ci) test pkgs;cross = self.lib.genAttrs [ "riscv64" ] (target:@rarias do you want to add this to
bsc-ci.crossalso?It would be great to have some target that we can build by hand that includes bsc cross packages. Maybe something like this?
Cross-compilation results in weasel: http://weasel:3001/eval/24?compare=bsc-ci&full=0
Most derivations fail because of a dependency on
pprtewhich does not cross-compile. This PR in nixpkgs theoretically fixed the issue, https://github.com/NixOS/nixpkgs/commit/d9c222c81435b but it still fails.8871e10ceato32ecd3014d@ -96,0 +101,4 @@# TODO: papi_version is needed for configure:# ./configure: line 27378: papi_version: command not found# This probably breaks cross-compilationJust a comment so I don't forget, it may be doable to fix nanos6 so that it takes the PAPI version from the .pc file:
https://github.com/bsc-pm/nanos6/blob/master/m4/papi.m4#L25
https://github.com/icl-utk-edu/papi/blob/master/src/papi.pc.in#L8
Even if we fix this, papi does not cross-compile to risc-v.
I tried to fix it, adding the needed configuration flags for cross compilation, but it still fails because it misses some instructions:
It seems they recently added support for RISC-V, but we use 7.1.0 which is too old:
b464420f3aI'll prefer waiting until the next release of nixos, unless we need to backport it.
I would say to leave the rest of fixes for cross compilation to another PR, and here only focus on adding the target and splitting the dependencies as long as that doesn't break bsc-ci.all.
32ecd3014dto85d50f346cFix nativeBuildInputsto WIP: Fix nativeBuildInputsb3df6bb1betoad17dbc06e@ -103,2 +114,2 @@printf '%s\n' $deps > $out'';inherit pkgs pkgsList;inherit test tests;We could rename
test -> testsandtests -> testsListfor consistency.WIP: Fix nativeBuildInputsto Fix nativeBuildInputs and add cross compilation target52e275434fto65df99aac265df99aac2to92ee4a09d7