Rollup merge of #144092 - Gelbpunkt:musl-stage0, r=Kobzol

bootstrap: Detect musl hosts

Currently, all non-Android Linux hosts are assumed to be using glibc. This obviously isn't very portable and will currently result in downloading a stage0 toolchain for glibc even on musl hosts.

There are multiple ways to detect musl somewhat reliably, but the easiest option is to check for the python target, which is exposed in `sys.implementation._multiarch` and has values like "x86_64-linux-gnu" or "powerpc64le-linux-musl".
This commit is contained in:
Matthias Krüger 2025-07-19 08:55:36 +02:00 committed by GitHub
commit 870d429e25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ import re
import shutil
import subprocess
import sys
import sysconfig
import tarfile
import tempfile
@ -333,7 +334,11 @@ def default_build_triple(verbose):
if ostype == "Android":
kernel = "linux-android"
else:
kernel = "unknown-linux-gnu"
python_soabi = sysconfig.get_config_var("SOABI")
if python_soabi is not None and "musl" in python_soabi:
kernel = "unknown-linux-musl"
else:
kernel = "unknown-linux-gnu"
elif kernel == "SunOS":
kernel = "pc-solaris"
# On Solaris, uname -m will return a machine classification instead