Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43112: detect musl as a separate SOABI #24502

Merged
merged 10 commits into from
Jan 28, 2022
7 changes: 5 additions & 2 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,13 @@ def test_triplet_in_ext_suffix(self):
if re.match('(i[3-6]86|x86_64)$', machine):
if ctypes.sizeof(ctypes.c_char_p()) == 4:
self.assertTrue(suffix.endswith('i386-linux-gnu.so') or
ncopa marked this conversation as resolved.
Show resolved Hide resolved
suffix.endswith('x86_64-linux-gnux32.so'),
suffix.endswith('x86_64-linux-gnux32.so') or
suffix.endswith('i386-linux-musl.so'),
suffix)
brettcannon marked this conversation as resolved.
Show resolved Hide resolved
else: # 8 byte pointer size
self.assertTrue(suffix.endswith('x86_64-linux-gnu.so'), suffix)
expected_suffixes = 'x86_64-linux-gnu.so', 'x86_64-linux-musl.so'
self.assertTrue(suffix.endswith(expected_suffixes),
f'unexpected suffix {suffix!r}'))
ncopa marked this conversation as resolved.
Show resolved Hide resolved

@unittest.skipUnless(sys.platform == 'darwin', 'OS X-specific test')
def test_osx_ext_suffix(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Detect musl libc as a separate SOABI.
ncopa marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5351,6 +5351,11 @@ EOF

if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
case "$build_os" in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, PLATFORM_TRIPLET should refer to the target platform on which cpython will run. If that is the case, the musl libc vs. glibc decision should be based on $host_os rather than $build_os as the former is based on autoconf's AC_CANONICAL_HOST macro1 which refers to the target platform that might differ from build platform in case of cross-compilation.

For example, the decision based on $build_os leads to
cpython 3.9.13 build failing2 when cross-compiling on AMD64 Linux with glibc for mpc8548 Linux (OpenWrt) with musl. (build runs correctly if $host_os is used)

Footnotes

  1. https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Canonicalizing.html

  2. "internal configure error for the platform triplet, please file a bug report"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the code is wrong. In fact the entire block should be revisited. We really should check for __GLIBC__ and use a heuristic to detect musl. Could you please open a new issue for the problem?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, but there's #87278 already. Is yet another issue needed?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #95855

linux-musl*)
PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PLATFORM_TRIPLET" >&5
$as_echo "$PLATFORM_TRIPLET" >&6; }
else
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ EOF

if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
case "$build_os" in
linux-musl*)
PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
;;
esac
AC_MSG_RESULT([$PLATFORM_TRIPLET])
else
AC_MSG_RESULT([none])
Expand Down