Author ncopa
Recipients ncopa
Date 2021-02-03.09:26:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612344373.45.0.663786135841.issue43112@roundup.psfhosted.org>
In-reply-to
Content
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"))'
cpython-39-x86_64-linux-gnu

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


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
.cpython-39-x86_64-linux-gnu.so

$ docker run --rm python:alpine python-config --extension-suffix
.cpython-39-x86_64-linux-gnu.so

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 -gnu.so suffix.

The source of the problem is that the `configure.ac` 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__)
        x86_64-linux-gnu
# elif defined(__x86_64__) && defined(__ILP32__)
        x86_64-linux-gnux32
# 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
diff --git a/configure.ac b/configure.ac
index 1f5a008388..1b4690c90f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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__)
         x86_64-linux-gnu
```

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`
History
Date User Action Args
2021-02-03 09:26:13ncopasetrecipients: + ncopa
2021-02-03 09:26:13ncopasetmessageid: <1612344373.45.0.663786135841.issue43112@roundup.psfhosted.org>
2021-02-03 09:26:13ncopalinkissue43112 messages
2021-02-03 09:26:12ncopacreate