Author ncopa
Recipients ncopa
Date 2021-02-03.09:26:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The SOABI does not make any difference between GNU libc and musl libc.

Using official docker images:

# debian build with GNU libc
$ docker run --rm python:slim python -c  'import sysconfig;print(sysconfig.get_config_var("SOABI"))'

# alpine build with musl libc
$ docker run --rm python:alpine python -c  'import sysconfig;print(sysconfig.get_config_var("SOABI"))'

Both ends with `-gnu`, while it would be expected that with musl it would end with `-musl`

This affects the extension suffix:

$ docker run --rm python:slim python-config --extension-suffix

$ docker run --rm python:alpine python-config --extension-suffix

Which again affects the pre-compiled binary wheels, and binary modules built with musl libc gets mixed up with the GNU libc modules due to the suffix.

The source of the problem is that the `` file assumes that all defined(__linux__) is -gnu when detecting the PLATFORM_TRIPLET.

#if defined(__ANDROID__)
    # Android is not a multiarch system.
#elif defined(__linux__)
# if defined(__x86_64__) && defined(__LP64__)
# elif defined(__x86_64__) && defined(__ILP32__)
# elif defined(__i386__)

So when building python with musl libc the PLATFORM_TRIPLET always sets `*-linux-gnu`.

output from configure run on musl system:
checking for a sed that does not truncate output... /bin/sed                                                      
checking for --with-cxx-main=<compiler>... no                                                                     
checking for the platform triplet based on compiler characteristics... x86_64-linux-gnu  

A first step in fixing this would be to make sure that we only set -gnu when __GLIBC__ is defined:
diff --git a/ b/
index 1f5a008388..1b4690c90f 100644
--- a/
+++ b/
@@ -726,7 +726,7 @@ cat >> conftest.c <<EOF
 #undef unix
 #if defined(__ANDROID__)
     # Android is not a multiarch system.
-#elif defined(__linux__)
+#elif defined(__linux__) && defined (__GLIBC__)
 # if defined(__x86_64__) && defined(__LP64__)

But that would make build with musl fail with "unknown platform triplet".

Not sure what the proper fix would be, but one way to extract the suffix from `$CPP -dumpmachine`
Date User Action Args
2021-02-03 09:26:13ncopasetrecipients: + ncopa
2021-02-03 09:26:13ncopasetmessageid: <>
2021-02-03 09:26:13ncopalinkissue43112 messages
2021-02-03 09:26:12ncopacreate