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
This commit is contained in:
Alyssa Ross
2025-11-15 19:34:53 +01:00
committed by Stig Palmquist
parent 2e2fd31065
commit b5fa38a5e5
@@ -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) [