Skip to content

Commit 1b7698c

Browse files
leoparenteclaude
andcommitted
fix: patch Corrade strerror_r for musl libc compatibility
musl only provides the XSI strerror_r (returns int). Corrade's ErrorString.cpp falls into the GNU branch (expects char*) when _GNU_SOURCE is defined by GCC even on musl targets, causing a compile error: "invalid conversion from int to const char*". Add a portability patch that extends the existing POSIX branch condition to also cover non-glibc Linux (detected via __linux__ && !__GLIBC__), so musl builds use the int-returning XSI variant that actually exists. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fc16118 commit 1b7698c

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

conan/corrade/conandata.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ sources:
22
"cci.20260327":
33
sha256: d8f30e9a857172003b6b02304783f40e8038c36e4127a0cfec7fe14f41c13fd4
44
url: https://github.com/mosra/corrade/archive/22e7ffc6fcdeaa0df96e0d8b3d482ad6abe7dc36.tar.gz
5+
6+
patches:
7+
"cci.20260327":
8+
- patch_file: "patches/0001-fix-strerror_r-musl-compat.patch"
9+
patch_description: "Fix strerror_r usage for non-glibc Linux (musl): always use POSIX XSI variant"
10+
patch_type: "portability"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- a/src/Corrade/Utility/Implementation/ErrorString.cpp
2+
+++ b/src/Corrade/Utility/Implementation/ErrorString.cpp
3+
@@ -61,7 +61,8 @@ void printErrnoErrorString(Debug& debug, const int error) {
4+
the buffer. Sigh. */
5+
/** @todo might want to add CORRADE_TARGET_BSD covering all three variants,
6+
there's no overarching BSD define present on all BSDs :( */
7+
- #if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_APPLE) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
8+
+ /* Also include non-glibc Linux (e.g. musl) which always provides only the XSI variant returning int */
9+
+ #if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_APPLE) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || (defined(__linux__) && !defined(__GLIBC__))
10+
char string[256];
11+
CORRADE_INTERNAL_ASSERT_OUTPUT(strerror_r(error, string, Containers::arraySize(string)) == 0);
12+
#else

0 commit comments

Comments
 (0)