From 14f337afb6fde2e847ea499bb6250a57a9660d48 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 13 Aug 2022 02:47:31 -0700 Subject: [PATCH 1/2] lib/systems/inspect.nix: add isILP32 predicate I've run into a few packages that need an extra flag on platforms where `int` has more bits than `void*` does. I know of three such platforms: * [aarch64ilp32], used on both Linux and also on the [Apple Watch] * [x32], the x86 ILP32 ABI * [mips64n32], used on [Longsoon] and Cavium Octeon routers. This PR introduces a predicate so the package flags can be added in a generic way. [Apple Watch]: https://gist.github.com/woachk/943828f37c14563a607a26116435bf27#watch [mips64n32]: https://en.wikipedia.org/wiki/MIPS_architecture#Calling_conventions [Longsoon]: https://en.wikipedia.org/wiki/Loongson [x32]: https://en.wikipedia.org/wiki/X32_ABI --- lib/systems/inspect.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 4e0bb8e672e9..53d84118bd30 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -48,6 +48,7 @@ rec { is32bit = { cpu = { bits = 32; }; }; is64bit = { cpu = { bits = 64; }; }; + isILP32 = map (a: { abi = { abi = a; }; }) [ "n32" "ilp32" "x32" ]; isBigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; }; isLittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; }; From c0a40bee00461f2b4999cbec319d1e54baa9d87f Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 13 Aug 2022 02:48:07 -0700 Subject: [PATCH 2/2] nss: set -DNS_PTR_LE_32=1 if isILP32 A comment in RNG_RandomUpdate() (drdbg.c) says to add the -DNS_PTR_LE_32=1 flag on ILP32 platforms. Without this PR, pkgsCross.mips64el-linux-gnuabin32.nss fails to build. With this PR, it succeeds. --- pkgs/development/libraries/nss/generic.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/nss/generic.nix b/pkgs/development/libraries/nss/generic.nix index a2e44f40227f..89227b78f2f7 100644 --- a/pkgs/development/libraries/nss/generic.nix +++ b/pkgs/development/libraries/nss/generic.nix @@ -103,7 +103,11 @@ stdenv.mkDerivation rec { runHook postBuild ''; - NIX_CFLAGS_COMPILE = "-Wno-error -DNIX_NSS_LIBDIR=\"${placeholder "out"}/lib/\" " + lib.optionalString stdenv.hostPlatform.is64bit "-DNSS_USE_64=1"; + NIX_CFLAGS_COMPILE = + "-Wno-error -DNIX_NSS_LIBDIR=\"${placeholder "out"}/lib/\" " + + lib.optionalString stdenv.hostPlatform.is64bit "-DNSS_USE_64=1" + + lib.optionalString stdenv.hostPlatform.isILP32 " -DNS_PTR_LE_32=1" # See RNG_RandomUpdate() in drdbg.c + ; installPhase = '' runHook preInstall