From 956bf2a2a4baf60a231a5e0377b418860a47cd32 Mon Sep 17 00:00:00 2001 From: Eugene Blikh Date: Tue, 19 May 2026 13:18:11 +0300 Subject: [PATCH] c-accel: fix strdup on glibc with -std=c99 strdup is POSIX, not ISO C99, so glibc's only exposes it when _POSIX_C_SOURCE >= 200809. With -std=c99 (strict mode) gcc otherwise treats strdup as an implicit-int function, which on 64-bit Linux truncates the returned pointer to int and yields warnings + likely crashes. macOS happens to declare strdup unconditionally so the issue only surfaces on the srht.bigb.es Ubuntu builder. Define _POSIX_C_SOURCE at the top of c_runtime.c before any include. --- runtime/pb/c/c_runtime.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime/pb/c/c_runtime.c b/runtime/pb/c/c_runtime.c index e97ff3bdbe174b89d3866ad75d43df39fdedeae8..b540ce1cf0b83e660d43b870a7bedb02b94a8baf 100644 --- a/runtime/pb/c/c_runtime.c +++ b/runtime/pb/c/c_runtime.c @@ -10,6 +10,12 @@ * Conventions follow docs/specs/c_accel_strategy.md. */ +/* strdup is POSIX, not C99; declare we want the POSIX surface from + * before any system header pulls it in. */ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + #include #include