Open yu-re-ka opened 1 year ago
For context, this affects all users running NixOS on Apple hardware by way of https://github.com/tpwrules/nixos-apple-silicon's Asahi Linux kernel and other packages.
From Asahi Linux's initial alpha release notes:
The Asahi Linux kernel is compiled to use 16K pages. This both performs better, and is required with our kernel branch right now in order to work properly with the M1’s IOMMUs. Unfortunately, some Linux software has problems running with 16K pages.
As suggested in https://github.com/sharkdp/fd/issues/1085, passing the JEMALLOC_SYS_WITH_LG_PAGE=16
environment variable definition to the build process works to resolve the issue.
So, at least in the case of fd
, that patch could be simplified to the following (tested locally):
diff --git a/pkgs/tools/misc/fd/default.nix b/pkgs/tools/misc/fd/default.nix
index b1845451491..ff603112a6a 100644
--- a/pkgs/tools/misc/fd/default.nix
+++ b/pkgs/tools/misc/fd/default.nix
@@ -15,6 +15,8 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [ installShellFiles ];
+ JEMALLOC_SYS_WITH_LG_PAGE = 16;
+
# skip flaky test
checkFlags = [
"--skip=test_owner_current_group"
But I'm guessing that this case-by-case workaround isn't the most efficient way to provide a fix – #243324 seems simpler.
Some of the build parameters are auto-detected by jemalloc-sys:
https://github.com/gnzlbg/jemallocator/tree/master/jemalloc-sys#environment-variables
In our jemalloc package, we already consider support for >4k page size on aarch64, but jemalloc-sys builds its own jemalloc and thus these fixes are not applied there.
IMO the best solution would be to make jemalloc-sys use our distro's jemalloc package everywhere, using the JEMALLOC_OVERRIDE env variable.
For instance, this would work to fix
fd
: