-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add ARM MUSL targets #33189
Add ARM MUSL targets #33189
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -83,7 +83,7 @@ pub fn std_link(build: &Build, | |||
add_to_sysroot(&out_dir, &libdir); | |||
|
|||
if target.contains("musl") && | |||
(target.contains("x86_64") || target.contains("i686")) { | |||
(target.contains("x86_64") || target.contains("i686") || target.contains("arm")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm perhaps this condition could be reversed to say if target.contains("musl") && !target.contains("mips")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks for the PR @timonvo, and nice! Also cc @rust-lang/tools, curious on thoughts of the idea on using I don't quite know what the best way to expose this would be. We could perhaps add a |
Hi Alex, I think I've addressed all your comments. Is there anything else you'd like to see before this can land? I was thinking I'd squash the last two commits into the Regarding the |
Hm yeah I was thinking on waiting for a resolution of musleabi vs just musl, but I think you're right that it's probably best to duke out elsewhere. If you wanna do some squashes I'll r+. Thanks @timonvo! |
This is to pull in changes to support ARM MUSL targets. This change also commits a couple of other cargo-generated changes to other dependencies in the various Cargo.toml files.
The targets are: - `arm-unknown-linux-musleabi` - `arm-unknown-linux-musleabihf` - `armv7-unknown-linux-musleabihf` These mirror the existing `gnueabi` targets. All of these targets produce fully static binaries, similar to the x86 MUSL targets. For now these targets can only be used with `--rustbuild` builds, as rust-lang/compiler-rt#22 only made the necessary compiler-rt changes in the CMake configs, not the plain GNU Make configs. I've tested these targets GCC 5.3.0 compiled again musl-1.1.12 (downloaded from http://musl.codu.org/). An example `./configure` invocation is: ``` ./configure \ --enable-rustbuild --target=arm-unknown-linux-musleabi \ --musl-root="$MUSL_ROOT" ``` where `MUSL_ROOT` points to the `arm-linux-musleabi` prefix. Usually that path will be of the form `/foobar/arm-linux-musleabi/arm-linux-musleabi`. Usually the cross-compile toolchain will live under `/foobar/arm-linux-musleabi/bin`. That path should either by added to your `PATH` variable, or you should add a section to your `config.toml` as follows: ``` [target.arm-unknown-linux-musleabi] cc = "/foobar/arm-linux-musleabi/bin/arm-linux-musleabi-gcc" cxx = "/foobar/arm-linux-musleabi/bin/arm-linux-musleabi-g++" ``` As a prerequisite you'll also have to put a cross-compiled static `libunwind.a` library in `$MUSL_ROOT/lib`. This is similar to [how the x86_64 MUSL targets are built] (https://doc.rust-lang.org/book/advanced-linking.html).
Just did the squash of the last two commits. |
// It's important we use "gnueabi" and not "musleabi" here. LLVM uses it | ||
// to determine the calling convention and float ABI, and it doesn't | ||
// support the "musleabi" value. | ||
llvm_target: "arm-unknown-linux-gnueabi".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional to pass "gneuabi" to LLVM instead of "musleabi"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. I believe the comment above explains why :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I can totally read
Just one minor nit but otherwise r=me |
⌛ Testing commit 483d805 with merge 9147703... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
Sure, I'll try to make that change. I'm not sure when I'll have time in next week or two, so this may be on hold for a while. |
rustc_back: use a common musl base extracted from #33327. cc #33189. r? @alexcrichton
rustc_back: use a common musl base extracted from #33327. cc #33189. r? @alexcrichton
☔ The latest upstream changes (presumably #33359) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing due to inactivity, but feel free to resubmit with a rebase! |
@timonvo If you don't mind, I'm going to try to rebase this. |
Add ARM MUSL targets Rebase of rust-lang#33189. I tested this by producing a std for `arm-unknown-linux-musleabi` then I cross compiled Hello world to said target. Checked that the produced binary was statically linked and verified that the binary worked under QEMU. This depends on rust-lang/libc#341. I'll have to update this PR after that libc PR is merged. I'm also working on generating ARM musl cross toolchain via crosstool-ng. Once I verified those work, I'll send a PR to rust-buildbot. r? @alexcrichton cc @timonvo
Add ARM MUSL targets Rebase of #33189. I tested this by producing a std for `arm-unknown-linux-musleabi` then I cross compiled Hello world to said target. Checked that the produced binary was statically linked and verified that the binary worked under QEMU. This depends on rust-lang/libc#341. I'll have to update this PR after that libc PR is merged. I'm also working on generating ARM musl cross toolchain via crosstool-ng. Once I verified those work, I'll send a PR to rust-buildbot. r? @alexcrichton cc @timonvo
The targets are:
arm-unknown-linux-musleabi
arm-unknown-linux-musleabihf
armv7-unknown-linux-musleabihf
These mirror the existing
gnueabi
targets.All of these targets produce fully static binaries, similar to the
x86 MUSL targets.
For now these targets can only be used with
--rustbuild
builds, asrust-lang/compiler-rt#22 only made the
necessary compiler-rt changes in the CMake configs, not the plain
GNU Make configs.
I've tested these targets GCC 5.3.0 compiled again musl-1.1.12
(downloaded from http://musl.codu.org/). An example
./configure
invocation is:
where
MUSL_ROOT
points to thearm-linux-musleabi
prefix.Usually that path will be of the form
/foobar/arm-linux-musleabi/arm-linux-musleabi
.Usually the cross-compile toolchain will live under
/foobar/arm-linux-musleabi/bin
. That path should either by addedto your
PATH
variable, or you should add a section to yourconfig.toml
as follows:As a prerequisite you'll also have to put a cross-compiled static
libunwind.a
library in$MUSL_ROOT/lib
. This is similar to howthe x86_64 MUSL targets are built.
r? @alexcrichton