From b2371efbe06d4a533dfd01c5958341166bc23faa Mon Sep 17 00:00:00 2001 From: Yury Kirsanov Date: Sat, 25 Jul 2026 10:51:22 +1000 Subject: [PATCH 1/2] lib/url.c: keep _GNU_SOURCE defined for musl libc builds url.c defined _GNU_SOURCE only around / and then undefined it again before including ut.h. On musl libc the feature-test macros are re-evaluated by every system header, so once _GNU_SOURCE is removed the later (pulled in through ut.h and dprint.h) no longer exposes clock_gettime(), CLOCK_REALTIME or ctime_r(). The core then fails to compile on Alpine/musl with gcc 15: lib/../mem/../dprint.h:204: implicit declaration of 'ctime_r' lib/../ut.h:1401: implicit declaration of 'clock_gettime' lib/../ut.h:1401: 'CLOCK_REALTIME' undeclared glibc is unaffected: it latches internal __USE_* macros at the first header inclusion, which the later #undef does not clear. Keep _GNU_SOURCE defined for the whole translation unit, matching how other core files (io_wait.h, transformations.c) enable it. --- lib/url.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/url.c b/lib/url.c index 8947d8e3b95..511c0a7e20b 100644 --- a/lib/url.c +++ b/lib/url.c @@ -18,10 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/* _GNU_SOURCE must stay defined for the rest of this file. On musl libc + * the feature-test macros are re-evaluated by every system header, so + * undefining it here would hide the clock_gettime()/ctime_r() prototypes + * that ut.h and dprint.h (via ) rely on, breaking the build. */ #define _GNU_SOURCE #include #include -#undef _GNU_SOURCE #include "../mem/mem.h" #include "../ut.h" From 97ca82a219f30e83fd42cdca24602691910bc239 Mon Sep 17 00:00:00 2001 From: Yury Kirsanov Date: Wed, 5 Aug 2026 12:40:18 +1000 Subject: [PATCH 2/2] modules/mathops: keep the feature-test macros defined for musl libc Both mathops sources define _XOPEN_SOURCE/_GNU_SOURCE for , then undefine them again before including the OpenSIPS headers - the same pattern lib/url.c had. musl re-evaluates the feature-test macros in every system header rather than only on the first one, and its features.h turns on the permissive default set only when no source macro is defined at all. Once the block above has defined them, undefining them leaves the translation unit with none of them set, so stops declaring ctime_r() and dprint.h no longer compiles: Compiling mathops.c ../../parser/../dprint.h:204:9: error: implicit declaration of function 'ctime_r'; did you mean 'ctime'? Since gcc 14 an implicit declaration is an error, so this is a hard build failure of the module on Alpine. Keep the macros defined for the rest of each file, as lib/url.c now does. --- modules/mathops/math_funcs.c | 9 ++++----- modules/mathops/mathops.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/mathops/math_funcs.c b/modules/mathops/math_funcs.c index 696e6b2dad0..29a205dbc14 100644 --- a/modules/mathops/math_funcs.c +++ b/modules/mathops/math_funcs.c @@ -32,11 +32,10 @@ #include #include -#ifdef _ADDED_XOPEN -#undef _ADDED_XOPEN -#undef _XOPEN_SOURCE -#undef _GNU_SOURCE -#endif +/* The feature-test macros above must stay defined for the OpenSIPS headers + * below. musl evaluates them in every system header, so undefining them + * here leaves the translation unit with none of them set and takes ctime_r() + * out of , which dprint.h needs. */ #include #include diff --git a/modules/mathops/mathops.c b/modules/mathops/mathops.c index 461f5d32072..ec7d9c4a18e 100644 --- a/modules/mathops/mathops.c +++ b/modules/mathops/mathops.c @@ -32,11 +32,10 @@ #include #include -#ifdef _ADDED_XOPEN -#undef _ADDED_XOPEN -#undef _XOPEN_SOURCE -#undef _GNU_SOURCE -#endif +/* The feature-test macros above must stay defined for the OpenSIPS headers + * below. musl evaluates them in every system header, so undefining them + * here leaves the translation unit with none of them set and takes ctime_r() + * out of , which dprint.h needs. */ #include "../../sr_module.h" #include "../../dprint.h"