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

Support compiler prefix x86_64-linux-musl #1443

Merged
merged 2 commits into from
Mar 28, 2025

Conversation

justsmth
Copy link
Contributor

Motivation

Context

I found that in some (most?) environments, the musl compiler to use for targeting x86_64-unknown-linux-gnu is prefixed with x86_64-linux-musl. For example, on Ubuntu (AMD64) the musl-dev package contains /usr/bin/x86_64-linux-musl-gcc but it does not contain /usr/bin/musl-gcc, which is provided by the musl-tools package. (The musl-tools package depend on musl-dev.)

When musl-tools is installed, /usr/bin/musl-gcc is simply a symlink to the former:

❯ file /usr/bin/musl-gcc
/usr/bin/musl-gcc: symbolic link to x86_64-linux-musl-gcc

Change

This adds another compiler prefix (x86_64-linux-musl) to check for when building for this target.

Copy link
Collaborator

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Thanks, this seems to make sense, although if musl-gcc is a fallback to x86_64-linux-musl-gcc in all situations, I'd prefer to not do fallback, and only attempt to use x86_64-linux-musl-gcc (just like we do for the similar aarch64-linux-musl-gcc).

@justsmth
Copy link
Contributor Author

Thanks, this seems to make sense, although if musl-gcc is a fallback to x86_64-linux-musl-gcc in all situations, I'd prefer to not do fallback, and only attempt to use x86_64-linux-musl-gcc (just like we do for the similar aarch64-linux-musl-gcc).

I kept the inclusion of the musl prefix (and listed first) as I'm not certain whether Ubuntu's packages are necessarily representative of how other Linux distributions provide the MUSL binaries. Since previously the only prefix checked was musl, keeping it helps avoid breaking consumers that (for whatever reason) only have a musl-gcc compiler in their path.

@madsmtm
Copy link
Collaborator

madsmtm commented Mar 28, 2025

My issue with that is that it seems wrong still? E.g. if cross-compiling from aarch64-unknown-linux-musl to x86_64-unknown-linux-musl, you'll likely also have musl-gcc in your path, but it'll point to the wrong thing.

@justsmth
Copy link
Contributor Author

My issue with that is that it seems wrong still? E.g. if cross-compiling from aarch64-unknown-linux-musl to x86_64-unknown-linux-musl, you'll likely also have musl-gcc in your path, but it'll point to the wrong thing.

Yeah, that's fair. In the latest commit, it only uses the x86_64-linux-musl prefix.

Copy link
Collaborator

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Excellent, thanks!

Will be released next Friday.

@madsmtm madsmtm merged commit 59578ad into rust-lang:main Mar 28, 2025
73 checks passed
@justsmth justsmth deleted the compiler-prefix-x86_64-linux-musl branch March 28, 2025 17:01
@github-actions github-actions bot mentioned this pull request Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants