From b5fa38a5e5e7c7b3f4b0ef71141b890391710e4e Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 9 Sep 2025 19:23:34 +0200 Subject: [PATCH] perl: unconditionally set _GNU_SOURCE Perl uses GNU extensions if they are available. Its build system tries to detect whether the libc is one that recognizes _GNU_SOURCE with bad heuristics, that don't work for e.g. riscv64 musl. Upstream is not willing to unconditionally set _GNU_SOURCE like programs usually do, because of an IMO misguided fear of somebody one day writing a libc that interprets _GNU_SOURCE to mean something different, so the only thing we can really do is set it ourselves. On libcs that don't gate GNU extensions behind _GNU_SOURCE, like BSDs, this should be a no-op. This should also improve things for cross where musl builds are currently broken due to perl-cross setting _GNU_SOURCE for the configure step but not the build step, although I haven't tested that. Link: https://github.com/Perl/perl5/issues/16807#issuecomment-544099623 Link: https://github.com/arsv/perl-cross/issues/158 --- pkgs/development/interpreters/perl/interpreter.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/interpreters/perl/interpreter.nix b/pkgs/development/interpreters/perl/interpreter.nix index be75635d7e98..0de0d9c6cdb7 100644 --- a/pkgs/development/interpreters/perl/interpreter.nix +++ b/pkgs/development/interpreters/perl/interpreter.nix @@ -147,6 +147,7 @@ stdenv.mkDerivation ( "-Dinstallstyle=lib/perl5" "-Dlocincpth=${libcInc}/include" "-Dloclibpth=${libcLib}/lib" + "-Accflags=-D_GNU_SOURCE" ] ++ lib.optional stdenv.hostPlatform.isStatic "-Uusedl" ++ lib.optionals ((builtins.match ''5\.[0-9]*[13579]\..+'' version) != null) [