atf: fix cross build on Darwin

Three issues prevented correct cross-compilation of atf on Darwin:

1. ATF_SHELL was not set, so configure's AC_PATH_PROGS found the
   build-platform bash in PATH. On Darwin, atf uses
   darwin.bootstrapStdenv whose initialPath includes the native bash;
   set ATF_SHELL to darwin.bootstrapStdenv.shell to pin it explicitly.
   Using the shell string from bootstrapStdenv avoids introducing a
   new derivation argument, which would force evaluation of
   pkgsStatic.bashNonInteractive and recreate the infinite recursion
   that the existing darwin.bootstrapStdenv override prevents.

2. configure's AC_RUN_IFELSE checks (kyua_cv_getopt_plus,
   kyua_cv_attribute_noreturn, kyua_cv_getcwd_works) try to execute
   compiled test programs on the build host, which fails when cross-
   compiling. Pre-set these cache variables so configure skips the
   run tests.

3. atf-sh and atf-check shebangs referenced the build-platform bash.
   Add patchShebangs --host to postInstall to rewrite them to the
   host-platform bash.

Fixes #413910
This commit is contained in:
Andrew Plaza
2026-04-15 21:07:46 -04:00
parent 1d7cc76628
commit 6809a773a3
+12
View File
@@ -45,6 +45,18 @@ stdenv'.mkDerivation (finalAttrs: {
nativeBuildInputs = [ autoreconfHook ];
configureFlags =
lib.optionals stdenv.hostPlatform.isDarwin [
"ATF_SHELL=${darwin.bootstrapStdenv.shell}"
]
# When cross-compiling, autoconf cannot run test programs on the build host.
# Pre-set cache variables so configure skips those AC_RUN_IFELSE checks.
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"kyua_cv_getopt_plus=yes"
"kyua_cv_attribute_noreturn=yes"
"kyua_cv_getcwd_works=yes"
];
enableParallelBuilding = true;
makeFlags = [