about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJens Reidel <adrian@travitia.xyz>2025-07-18 00:46:56 +0200
committerJens Reidel <adrian@travitia.xyz>2025-07-18 09:39:13 +0200
commit9e4f777602cdac0458c57615f3019c92e4152d72 (patch)
tree49f10aec017eab9b073717f91e8b58f47d351c5a
parent9cd918bcbbc26deb005eb4e1bd9a445380195e56 (diff)
downloadrust-9e4f777602cdac0458c57615f3019c92e4152d72.tar.gz
rust-9e4f777602cdac0458c57615f3019c92e4152d72.zip
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 SOABI config variable, which
has values like "cpython-313-x86_64-linux-gnu" or
"cpython-313-powerpc64-linux-musl".

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
-rw-r--r--src/bootstrap/bootstrap.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index d8c6be78247..40e08361a0f 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -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