mirror of
https://github.com/espressif/openthread.git
synced 2026-11-08 15:33:21 +00:00
[script] fix socat 1.7.4.4 build with C23 / glibc 2.43 (#13796)
In `socat-1.7.4.4/filan.c`, `printtime()` declares `const char *s`, assigns `asctime(localtime(&time))` (which returns `char *`), and strips the trailing newline in place via `*strchr(s, '\n') = '\0'`. With glibc 2.43 and `-D_GNU_SOURCE` (as on Ubuntu 26.04 with GCC 15.2), `<string.h>` enables ISO C23 qualifier-preserving `_Generic` macros so `strchr(const char *, int)` returns `const char *`, causing `make` in `script/install_socat` to fail with `error: assignment of read-only location` (even if `-std=gnu17` is passed). This commit patches `printtime()` in `filan.c` after archive extraction to declare `char *s;` (matching `asctime()`'s `char *` return type without altering `const char *s;` in `getfiletypestring()` above it), using a POSIX `sed` + `mv` sequence compatible with both Linux and macOS.
This commit is contained in:
@@ -75,4 +75,11 @@ cd "$TEMP_PATH"
|
||||
"$SOCAT_URL"
|
||||
verify_sha256 "$SOCAT_TAR"
|
||||
tar -xjf "$SOCAT_TAR"
|
||||
cd "$SOCAT" && ./configure "$INSTALL_PREFIX" && make && sudo make install
|
||||
cd "$SOCAT"
|
||||
# Fix C23 / glibc 2.43 build failure where const-preserving strchr() rejects
|
||||
# mutating asctime()'s char * return value through a const char * variable.
|
||||
sed '/^static int printtime(/,/^}/s/const char \*s;/char *s;/' filan.c >filan.c.tmp
|
||||
mv filan.c.tmp filan.c
|
||||
./configure "$INSTALL_PREFIX"
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Reference in New Issue
Block a user