Can not cross-compile coreutils for armv6l on x86_64

Hi,
I’m currently having problems trying to build the initial system configuration (first nixos-rebuild switch) on a freshly booted Raspberry Pi 0WH (armv6l).

Context:
I successfully built an SD-image for armv6l following the advice on how to build custom images from the NixOS on Arm guide in the wiki. I kept my custom additions to a minimum:

  • activated flakes support
  • activated ssh-server
  • added my user account + ssh keys
  • registered an x86_64-machine as a remote builder for nix

The SD-image builds and boots up just fine, I can login and interact with my rpi0 without any problems.

My next step would be to do an initial nixos-rebuild switch with the very same configuration (flakes, ssh-server, user account, remote builder) and then subsequently add more and more configuration options that I’d need.

The remote building (and cross-compilation) works perfectly, when setting:

nixpkgs.localSystem = { config = "x86_64-linux"; };
nixpkgs.crossSystem = lib.systems.examples.raspberryPi;

in my configuration.nix.

rpi0:

<not available unfortunately, would need to rebuild SD-image with nix-info>

remot builder:

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.9.0, Debian GNU/Linux, 11 (bullseye), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.10.3`
 - channels(m00wl): `"home-manager, nixpkgs"`
 - nixpkgs: `/home/m00wl/.nix-defexpr/channels/nixpkgs`

Problem:
Unfortunately, the package coreutils always throws an error during nixos-rebuild switch.

Error log:

error: build of '/nix/store/ivqgmw2067x2vbb4bzifgj7nxfvy5hcc-coreutils-9.0.drv' on 'ssh://user@remote.builder' failed: builder for '/nix/store/ivqgmw2067x2vbb4bzifgj7nxfvy5hcc-coreutils-9.0.drv' failed with exit code 2
error: builder for '/nix/store/ivqgmw2067x2vbb4bzifgj7nxfvy5hcc-coreutils-9.0.drv' failed with exit code 1;
       last 10 log lines:
       > make[5]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
       > make[4]: *** [Makefile:9952: check-am] Error 2
       > make[4]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
       > make[3]: *** [Makefile:7090: check-recursive] Error 1
       > make[3]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
       > make[2]: *** [Makefile:9954: check] Error 2
       > make[2]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
       > make[1]: *** [Makefile:13465: check-recursive] Error 1
       > make[1]: Leaving directory '/build/coreutils-9.0'
       > make: *** [Makefile:13950: check] Error 2
       For full logs, run 'nix log /nix/store/ivqgmw2067x2vbb4bzifgj7nxfvy5hcc-coreutils-9.0.drv'.
error: 1 dependencies of derivation '/nix/store/ry8wbpx800lidjg1gqwl0anh45s07pys-armv6l-unknown-linux-gnueabihf-binutils-wrapper-2.38.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kfja25iqcg7ga54z992a5mqxzilrdg40-coreutils-armv6l-unknown-linux-gnueabihf-9.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/hfg70xf6q7hk13c7dv8dwmw1l5bsplb2-findutils-4.9.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/zr9ss6l3ld0dmwbf5q3fnf24gsi75nn7-gcc-wrapper-11.3.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ay5sxw7knpgfa3nc5wdsih6lr9j778zl-openssl-1.1.1q.drv' failed to build
error: 1 dependencies of derivation '/nix/store/66lfwjs06xg22bi1k14jjrcani2ylr7a-openssl-armv6l-unknown-linux-gnueabihf-1.1.1q.drv' failed to build
error: 1 dependencies of derivation '/nix/store/z6cdchqpaa76y4l2d7llv94lq0ww8rw0-sharutils-4.15.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/12sc5xslis6wvzzr36704l6l0azwsaqj-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/7bl4453sx4r9jrginm60dw1vdka9wjg4-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/cx9pg36a03i6gvh5sgnki7b877448mv5-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f8dlwxghxsm5ri806sqsxy4vrxjq28lj-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/k4ky3rgw8mnhwpky81dr42z2cdlh8afg-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ss9y8yx79k44w2m83zqgk2rl5v37pzgl-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xxhf18sv572g8crzf8ld2b6spkj7wjk5-nixos-rebuild.drv' failed to build

nix log /nix/store/ivqgmw2067x2vbb4bzifgj7nxfvy5hcc-coreutils-9.0.drv:

[...]

FAIL: test-fdatasync
====================

test-fdatasync.c:50: assertion 'fdatasync (-1) == -1' failed
FAIL test-fdatasync (exit status: 134)

FAIL: test-fsync
================

test-fsync.c:50: assertion 'fsync (-1) == -1' failed
FAIL test-fsync (exit status: 134)

[...]

============================================================================
Testsuite summary for GNU coreutils 9.0
============================================================================
# TOTAL: 365
# PASS:  320
# SKIP:  43
# XFAIL: 0
# FAIL:  2
# XPASS: 0
# ERROR: 0
============================================================================
See gnulib-tests/test-suite.log
Please report to bug-coreutils@gnu.org
============================================================================
make[6]: *** [Makefile:7198: test-suite.log] Error 1
make[6]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
make[5]: *** [Makefile:7306: check-TESTS] Error 2
make[5]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
make[4]: *** [Makefile:9952: check-am] Error 2
make[4]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
make[3]: *** [Makefile:7090: check-recursive] Error 1
make[3]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
make[2]: *** [Makefile:9954: check] Error 2
make[2]: Leaving directory '/build/coreutils-9.0/gnulib-tests'
make[1]: *** [Makefile:13465: check-recursive] Error 1
make[1]: Leaving directory '/build/coreutils-9.0'
make: *** [Makefile:13950: check] Error 2

I’m not sure why these two tests (fsync and fdatasync) fail or how to fix this.
I already tried building the configuration with different versions of the coreutils package, namely version 9.1 (current, at the time of writing), 9.0 and 8.32. For all three of these versions, the build fails because of the aforementioned tests. This fact leads me to believe that the problem is rather on my end than in the coreutils package itself, but I’m not sure.
Furthermore, I also tried to build coreutils locally on the rpi0, but the tests fail here as well and it takes way longer which is why I did not investigated any further into the local build.
@das_j: Should I open an issure for this (which I did not do so far, because armv6l is not really in scope afaik), or am I doing something wrong?

Any help is appreciated, thank you!

EDIT:
I found out that the tests are part of the second test suite: gnulib-tests.
I tried to temporarily disable them with this patch but I can’t seem to write it in a way that it can get applied successfully.