From 74f5d66b391e63fbf33fc9d6c427221298cd6141 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 5 Dec 2025 17:51:03 +0100 Subject: [PATCH] perl: unset NDEBUG after loading Perl headers Otherwise, loading Perl bindings fails early with[1] undefined symbol: Perl_pad_sv at /nix/store/h2jsb5i4yfblr2f3ac2c7zpmlmj7zjym-perl-5.40.0/lib/perl5/5.40.0/XSLoader.pm line 94 Apparently, it's expected behavior by Perl that this symbol only exists with `DEBUGGING` being set, hence it's used by the headers. However, `pkgs.perl` from nixpkgs is apparently not built with `-DDEBUGGING` causing this error. Now, `NDEBUG` is manually unset after loading the Perl headers rather than setting `DEBUGGING` causing the error mentioned above. I confirmed that this not only fixes the problem described above, but running the Hydra tests with diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs index dfdd64d28..14788266c 100644 --- a/perl/lib/Nix/Store.xs +++ b/perl/lib/Nix/Store.xs @@ -27,6 +27,7 @@ using namespace nix; static AsyncIoRoot & aio() { +assert(false); static thread_local AsyncIoRoot root; return root; } still results in assertion errors. Finally, added a small install-check that importing `Nix::Store` works fine. [1] https://git.lix.systems/lix-project/hydra/issues/69 Change-Id: I58521777eb0f94b766a9813aa4bbd06f9052bd35 --- perl/default.nix | 5 +++++ perl/lib/Nix/Store.xs | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/perl/default.nix b/perl/default.nix index 742263067..dc0de1b2b 100644 --- a/perl/default.nix +++ b/perl/default.nix @@ -57,5 +57,10 @@ perl.pkgs.toPerlModule ( postUnpack = "sourceRoot=$sourceRoot/perl"; passthru = { inherit perl; }; + + doInstallCheck = true; + installCheckPhase = '' + env PERL5LIB="$PERL5LIB:$out/${perl.libPrefix}" perl -e 'use Nix::Store' + ''; } ) diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs index a1f72cf7c..dfdd64d28 100644 --- a/perl/lib/Nix/Store.xs +++ b/perl/lib/Nix/Store.xs @@ -5,14 +5,12 @@ // can i make it any more obvious? #include "lix/libutil/result.hh" -// Without this, Perl defines NDEBUG, which makes the assertions -// ineffective and might break Lix -#define DEBUGGING - #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#undef NDEBUG + /* Prevent a clash between some Perl and libstdc++ macros. */ #undef do_open #undef do_close