-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 support for the crosstool-ng Raspberry Pi 2 toolchain #30948
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (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. |
On the rust side, Rpi2 is just a standard armhf target and As long as the custom targets are not officially recognized it will just cause problems during cargo builds. odroid, banana/orange pi, tegra, beaglebone, etc. |
I didn't know about RustBuild, but that would work for me, once warricksothr/RustBuild#11 is fixed. |
That would still be nice to have a non-android armv7 target in the tree I think however. |
Awesome! I've wondered in the past if we'd end up grown a custom target here... Before we land though I was wondering if you could help me understand this target triple a little better? Right now we're currently producing nightlies for two different ARM OSes:
I'm not personally aware of what ARM version they're using (e.g. v5, v6, v7, etc), but I think that the raspberry pi is using Linux, right? Along those lines, I'm curious how With that, I wonder if If that's the case, though, would we benefit from a new target? It may be good to have a nice set of pre-defined defaults for the raspberry pi if it's common enough in any case. |
The only difference is I did a few benchmarks to see whether the fact A more generic alternative would be to add a target named Simply using the latest binary builds from RustBuild fully addresses the cross-compilation issue, i.e. rlibs built for v7 even though, as I'd mentioned at the beginning, it's not necessary at all. |
I still want to check why crosstool-ng has a specific rpi2 target in addition to the generic armv7. |
The one that's popular due to the volume produced and the time it's been around is the original Rpi. It would make more sense to create a target for that. (incl. Rpi Zero!) Rpi2 is just standard armv7 using a newer distro. It was introduced in response to much better alternatives available for the same money or even cheaper. In short, there's nothing special about it. For your own use, and to make this patch at all meaningful, you should modify the target: let mut base = super::linux_base::opts();
base.cpu = "cortex-a7".to_string(); as well as add Once you've done that you could post your results here to make llvm better on ARM. |
Ok, so it sounds like We've had a lot of cases in the past where only a few minor tweaks are made to codegen options for a target (e.g. a small delta from an existing target), so for now it sounds like it may be overkill to add a whole new target for some tweaks here and there. @fabricedesre would it be possible to use the |
Have a look at the LLVM triple doc and the Clang cross compilation doc: LLVM does not understand the vendor rpi2 nor rpi. LLVM defaults to |
Yes @alexcrichton we can use arm-unknown-linux-gnueabihf as a target. We can definitely live with that. @petevine I'll upload my results to the llvm bug soon. |
Ah ok, now we may still want to add a dedicated armv7 target for CPUs with those features (e.g. ship an armv7 standard library) as opposed to only turning those features on selectively for each crate (via I'd be ok adding a |
@alexcrichton You could consider doing a modern @fabricedesre Thx, if you know anyone on a Cortex-A15 (e.g. XU4), please pass the request to them. |
@fabricedesre ah if you want to rebase this and squash the commits I'll go ahead an r+. Per our offline chat we may not produce libstd binaries for this triple just yet, but we will hopefully start providing easier methods in the future to tweak these sorts of compilation options! |
@alexcrichton If you ever start distributing crates for this triple, just make sure bootstrapping with |
Ah yeah if we ever ship a snapshot for ARM then it'll likely be for older processors (not v7), so it's unlikely to have that problem I believe. |
True, but I was referring to this particular triple which is about to be accepted and then maybe get a |
@petevine could you spell things out a bit more for me? Unfortunately I'm not too familiar with arm versions/features, so I don't know what the interactions are between armv7, neon, etc. Can you explicitly state the scenario that you're worried about? |
Sure, even though it's rather improbable it could affect rustc. We're talking about turning on a set of simd instructions called NEON, the arm equivalent of sorts of SSE2, that unlike the latter, flushes denormals to zero and has lower precision than the default vfp. |
@alexcrichton I squashed |
This adds support for the armv7 crosstool-ng toolchain for the Raspberry Pi 2. Getting the toolchain ready: Checkout crosstool-ng from https://github.com/crosstool-ng/crosstool-ng Build crosstool-ng Configure the rpi2 target with |ct-ng armv7-rpi2-linux-gnueabihf| Build the toolchain with |ct-build| and add the path to $toolchain_install_dir/bin to your $PATH Then, on the rust side: configure --target=armv7-rpi2-linux-gnueabihf && make && make install To cross compile for the rpi2, add $rust_install_path/lib to your $LD_LIBRARY_PATH, then use rustc --target=armv7-rpi2-linux-gnueabihf -C linker=armv7-rpi2-linux-gnueabihf-g++ hello.rs
Cool, just don't let's forget to tell cargo about it! :) |
This adds support for the armv7 crosstool-ng toolchain for the Raspberry Pi 2.
Getting the toolchain ready:
Checkout crosstool-ng from https://github.com/crosstool-ng/crosstool-ng
Build crosstool-ng
Configure the rpi2 target with |ct-ng armv7-rpi2-linux-gnueabihf|
Build the toolchain with |ct-build| and add the path to $toolchain_install_dir/bin to your $PATH
Then, on the rust side:
configure --target=armv7-rpi2-linux-gnueabihf && make && make install
To cross compile for the rpi2,
add $rust_install_path/lib to your $LD_LIBRARY_PATH, then use
rustc --target=armv7-rpi2-linux-gnueabihf -C linker=armv7-rpi2-linux-gnueabihf-g++ hello.rs