From 1bc29c0e286fa4b4ba630b0e1afe3f69bf201fb4 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Tue, 6 Oct 2026 07:12:21 -0700 Subject: [PATCH] sqlite: fix tests on musl Since test failures now fail the build, pkgsMusl.sqlite fails in checkPhase for two reasons: - testrunner builds fuzzcheck-asan and fuzzcheck-ubsan, which cannot be linked because neither GCC's libsanitizer nor compiler-rt's sanitizers are built for musl. Exclude them with a testrunner pattern. - capi3c.test, a copy of capi3.test, still runs the intentional use-after-free cases that upstream disabled in capi3.test because they occasionally segfault. musl's allocator makes them segfault reliably. Disable them the same way upstream did. Assisted-by: Claude Code (claude-opus-5-5) (cherry picked from commit a66e91bfe80ca283699cc40cffb9943395cdeb81) --- pkgs/development/libraries/sqlite/default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix index 6a278055e950..65ee34162a9d 100644 --- a/pkgs/development/libraries/sqlite/default.nix +++ b/pkgs/development/libraries/sqlite/default.nix @@ -110,6 +110,16 @@ stdenv.mkDerivation (finalAttrs: { }) ]; + # capi3c.test is a copy of capi3.test, but upstream only disabled the + # intentional use-after-free cases in the original. They segfault with + # allocators that return freed memory to the OS eagerly, such as musl's. + ${if stdenv.hostPlatform.isMusl then "postPatch" else null} = '' + substituteInPlace test/capi3c.test \ + --replace-fail \ + 'if {[clang_sanitize_address]==0} {' \ + 'if {0 && [clang_sanitize_address]==0} {' + ''; + buildInputs = [ zlib ] @@ -199,6 +209,9 @@ stdenv.mkDerivation (finalAttrs: { doCheck = stdenv.hostPlatform.isLinux; # When tcl is not available, only run test targets that don't need it. checkTarget = lib.optionalString stdenv.hostPlatform.isStatic "fuzztest sourcetest"; + # Neither GCC's libsanitizer nor compiler-rt's sanitizers are built for + # musl, so the fuzzcheck-asan and fuzzcheck-ubsan programs cannot be linked. + ${if stdenv.hostPlatform.isMusl then "checkFlags" else null} = [ "TSTRNNR_OPTS=~fuzzcheck-%san" ]; passthru = { tests = {