From 7facba77704904c1fa53b793675bc895773d565c Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 23 Oct 2023 01:23:23 -0700 Subject: [PATCH 1/2] glibc: use (lib.getBin pkgsBuildBuild.glibc) to generate locales This is an alternative resolution of the problem identified in https://github.com/NixOS/nixpkgs/pull/259964 which stated that "glibc depends on buildPackages.glibc for locale things. buildPackages.glibc depended on buildPackages.libgcc, which, since it's GCC, depends on the target's bintools, which depend on the target's glibc, which, again, depends on buildPackages.glibc, causing an infinute recursion when evaluating buildPackages.glibc when glibc hasn't come from stdenv (e.g. on musl)." The fact that we use pkgsBuildHost.glibc instead of pkgsBuildBuild.glibc to generate the locales has always been a gross hack. If we simply remove the gross hack the circularity goes away. --- pkgs/development/libraries/glibc/default.nix | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix index 1c822bf1ed019d..32e9b04d229f77 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -3,7 +3,7 @@ , profilingLibraries ? false , withGd ? false , withLibcrypt? false -, buildPackages +, pkgsBuildBuild , libgcc }: @@ -98,14 +98,23 @@ in postInstall = previousAttrs.postInstall + (if stdenv.hostPlatform == stdenv.buildPlatform then '' echo SUPPORTED-LOCALES=C.UTF-8/UTF-8 > ../glibc-2*/localedata/SUPPORTED make -j''${NIX_BUILD_CORES:-1} localedata/install-locales - '' else lib.optionalString stdenv.buildPlatform.isLinux '' + '' else lib.optionalString stdenv.buildPlatform.isLinux # This is based on http://www.linuxfromscratch.org/lfs/view/development/chapter06/glibc.html # Instead of using their patch to build a build-native localedef, - # we simply use the one from buildPackages + # we simply use the one from pkgsBuildBuild. + # + # Note that we can't use pkgsBuildHost (aka buildPackages) here, because + # that will cause an eval-time infinite recursion: "buildPackages.glibc + # depended on buildPackages.libgcc, which, since it's GCC, depends on the + # target's bintools, which depend on the target's glibc, which, again, + # depends on buildPackages.glibc, causing an infinute recursion when + # evaluating buildPackages.glibc when glibc hasn't come from stdenv + # (e.g. on musl)." https://github.com/NixOS/nixpkgs/pull/259964 + '' pushd ../glibc-2*/localedata export I18NPATH=$PWD GCONV_PATH=$PWD/../iconvdata - mkdir -p $NIX_BUILD_TOP/${buildPackages.glibc}/lib/locale - ${lib.getBin buildPackages.glibc}/bin/localedef \ + mkdir -p $NIX_BUILD_TOP/${pkgsBuildBuild.glibc}/lib/locale + ${lib.getBin pkgsBuildBuild.glibc}/bin/localedef \ --alias-file=../intl/locale.alias \ -i locales/C \ -f charmaps/UTF-8 \ @@ -115,7 +124,7 @@ in else "--big-endian"} \ C.UTF-8 - cp -r $NIX_BUILD_TOP/${buildPackages.glibc}/lib/locale $out/lib + cp -r $NIX_BUILD_TOP/${pkgsBuildBuild.glibc}/lib/locale $out/lib popd '') + '' From 7acd36fbce267b11fec8edda2b9ba769d85666a0 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 23 Oct 2023 14:33:35 -0700 Subject: [PATCH 2/2] glibc: weaken host==build check to canExecute --- pkgs/development/libraries/glibc/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix index 32e9b04d229f77..11676560e80b10 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -95,7 +95,7 @@ in "user-defined-trusted-dirs=${libgcc}/lib" ]; - postInstall = previousAttrs.postInstall + (if stdenv.hostPlatform == stdenv.buildPlatform then '' + postInstall = previousAttrs.postInstall + (if stdenv.buildPlatform.canExecute stdenv.hostPlatform then '' echo SUPPORTED-LOCALES=C.UTF-8/UTF-8 > ../glibc-2*/localedata/SUPPORTED make -j''${NIX_BUILD_CORES:-1} localedata/install-locales '' else lib.optionalString stdenv.buildPlatform.isLinux