Closed chrfranke closed 2 months ago
I wonder what #defines are available. What's the output from the following command?
musl-gcc -E -dM -xc /dev/null
Here the result of diff -U1 <(gcc -E -dM -xc /dev/null) <(musl-gcc -E -dM -xc /dev/null)
from current Debian 12:
@@ -85,7 +85,4 @@
#define __SIZEOF_LONG__ 8
-#define __STDC_IEC_559__ 1
-#define __STDC_ISO_10646__ 201706L
#define __UINT16_C(c) c
#define __DECIMAL_DIG__ 21
-#define __STDC_IEC_559_COMPLEX__ 1
#define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64
@@ -173,3 +170,2 @@
#define __UINT64_C(c) c ## UL
-#define _STDC_PREDEF_H 1
#define __INT_LEAST32_MAX__ 0x7fffffff
@@ -180,3 +176,2 @@
#define __FLT32X_MIN_EXP__ (-1021)
-#define __STDC_IEC_60559_COMPLEX__ 201404L
#define __FLT128_HAS_DENORM__ 1
@@ -210,3 +205,2 @@
#define __USER_LABEL_PREFIX__
-#define __STDC_IEC_60559_BFP__ 201404L
#define __SIZEOF_PTRDIFF_T__ 8
This does not show any obvious difference to heuristically distinguish musl libc from others.
A search for grep -Eir 'MUSL|VER|REV' /usr/include/x86_64-linux-musl
does also not show anything which is musl related. Apparently this libc does not provide an easy way to detect it.
Looks line one can do:
echo | gcc -E -Wp,-v - 2>&1 | grep musl
also, gcc compiled binaries have __data_start and musl-gcc does not.
I've pushed the following commit that seems to address the issue when I tried it with Cygwin:
commit b537623c8caf511ede24ab01669eae98c90cecad
Author: Colin Ian King <colin.i.king@gmail.com>
Date: Sat Sep 14 13:36:39 2024 +0100
Makefile: make musl-gcc detection more robust
This method relies on the musl
substring in the preset include path. May not work on systems with musl as the default libc or if the user has a custom build environment. So if the this detection is only used to inform the user that the alternative musl libc is used, it is possibly sufficient. If a behavioral change is required if musl is used instead of glibc, it is possibly not.
Musl upstream decided to avoid a __MUSL__
define, see https://wiki.musl-libc.org/faq . I disagree.
On Cygwin,
stress-ng --version
says that musl-gcc is used which is not the case:stress-ng, version 0.18.04 (musl-gcc 12.4.0, x86_64 CYGWIN_NT-10.0-19045 3.5.4-1.x86_64)
HAVE_COMPILER_MUSL
is misdetected because__USE_GNU
is undefined.A quick fix which should also cover other use cases of the newlib libc:
Possibly better: Check for some define from some
__MUSL*
define if available.