From a4cef7f922842fd5491fc8cf66ee55f781ac30c7 Mon Sep 17 00:00:00 2001 From: Martin Vogel Date: Mon, 3 Aug 2026 17:47:36 +0200 Subject: [PATCH] fix(msan): pin _GNU_SOURCE for the zstd object alongside the forced stdint Scoping -include stdint.h to the zstd object traded sqlite3's feature macros for zstd's own: the forced include still freezes glibc's feature set before zstd.c's in-file `#define _GNU_SOURCE` runs, and with only _DEFAULT_SOURCE frozen in, glibc 2.39 does not declare qsort_r -- zstd.c:47409 fails exactly as the x86-64 leg reported. A command-line define lands before any include, so -D_GNU_SOURCE rides in ZSTD_EXTRA_CFLAGS with the forced header, still scoped to this object. Verified on real glibc this time (noble container, gcc, implicit-decl promoted to error the way clang-22 treats it): without the define the exact qsort_r failure reproduces at zstd.c:47409; with it the file is clean. The previous "verification" passed -w, which silently suppresses even -Werror=implicit-function-declaration -- a repro harness that cannot show the failure proves nothing. Signed-off-by: Martin Vogel --- scripts/msan.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/msan.sh b/scripts/msan.sh index e924e213..ad2941b7 100755 --- a/scripts/msan.sh +++ b/scripts/msan.sh @@ -46,7 +46,12 @@ MSAN_SAN="-fsanitize=memory $MSAN_ORIGIN_FLAG -fno-omit-frame-pointer -isystem $ # Makefile.cbm): zstd's MSan block needs stdint.h that its amalgamation lost, # but force-including it globally freezes glibc feature-test macros before # sqlite3.c can set _GNU_SOURCE, breaking that compile instead. -ZSTD_EXTRA="-include stdint.h" +# +# -D_GNU_SOURCE rides along for the same freeze reason IN this object: +# a command-line define lands before the forced include, while zstd.c's own +# in-file feature setup lands after it -- without this, glibc freezes +# without _GNU_SOURCE and zstd loses qsort_r. +ZSTD_EXTRA="-D_GNU_SOURCE -include stdint.h" # Always clean: make does not encode flags into dependencies, so a build dir # populated under different stdlib/sanitizer flags silently mixes objects