Skip to content

bootstrap: Detect musl hosts #144092

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gelbpunkt
Copy link
Contributor

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".

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".

Signed-off-by: Jens Reidel <[email protected]>
@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2025

r? @albertlarsan68

rustbot has assigned @albertlarsan68.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 17, 2025
@Gelbpunkt
Copy link
Contributor Author

The alternative I would suggest is to check ldd --version for the string musl, but that would require a larger, more intrusive change, since it outputs to stderr, while the current command execution code only accounts for stdout. I think the python target is sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants