-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add new tier-3 target: armv7-unknown-linux-uclibceabihf #88952
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::spec::{Target, TargetOptions}; | ||
|
||
// This target is for uclibc Linux on ARMv7 without NEON or | ||
// thumb-mode. See the thumbv7neon variant for enabling both. | ||
|
||
pub fn target() -> Target { | ||
let base = super::linux_uclibc_base::opts(); | ||
Target { | ||
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), | ||
nagisa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), | ||
arch: "arm".to_string(), | ||
|
||
options: TargetOptions { | ||
// Info about features at https://wiki.debian.org/ArmHardFloatPort | ||
skrap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), | ||
cpu: "generic".to_string(), | ||
max_atomic_width: Some(64), | ||
mcount: "_mcount".to_string(), | ||
abi: "eabihf".to_string(), | ||
..base | ||
}, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabihf.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# armv7-unknown-linux-uclibceabihf | ||
|
||
**Tier: 3** | ||
|
||
This tier supports the ARMv7 processor running a Linux kernel and uClibc-ng standard library. It provides full support for rust and the rust standard library. | ||
|
||
## Designated Developers | ||
|
||
* [@skrap](https://github.com/skrap) | ||
|
||
## Requirements | ||
|
||
This target is cross compiled, and requires a cross toolchain. You can find suitable pre-built toolchains at [bootlin](https://toolchains.bootlin.com/) or build one yourself via [buildroot](https://buildroot.org). | ||
|
||
## Building | ||
|
||
### Get a C toolchain | ||
|
||
Compiling rust for this target has been tested on `x86_64` linux hosts. Other host types have not been tested, but may work, if you can find a suitable cross compilation toolchain for them. | ||
|
||
If you don't already have a suitable toolchain, download one [here](https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2020.08-1.tar.bz2), and unpack it into a directory. | ||
|
||
### Configure rust | ||
|
||
The target can be built by enabling it for a `rustc` build, by placing the following in `config.toml`: | ||
|
||
```toml | ||
[build] | ||
target = ["armv7-unknown-linux-uclibceabihf"] | ||
stage = 2 | ||
|
||
[target.armv7-unknown-linux-uclibceabihf] | ||
# ADJUST THIS PATH TO POINT AT YOUR TOOLCHAIN | ||
cc = "/TOOLCHAIN_PATH/bin/arm-buildroot-linux-uclibcgnueabihf-gcc" | ||
``` | ||
|
||
### Build | ||
|
||
```sh | ||
# in rust dir | ||
./x.py build --stage 2 | ||
``` | ||
|
||
## Building and Running Rust Programs | ||
|
||
To test cross-compiled binaries on a `x86_64` system, you can use the `qemu-arm` [userspace emulation](https://qemu-project.gitlab.io/qemu/user/main.html) program. This avoids having a full emulated ARM system by doing dynamic binary translation and dynamic system call translation. It lets you run ARM programs directly on your `x86_64` kernel. It's very convenient! | ||
|
||
To use: | ||
|
||
* Install `qemu-arm` according to your distro. | ||
* Link your built toolchain via: | ||
* `rustup toolchain link stage2 ${RUST}/build/x86_64-unknown-linux-gnu/stage2` | ||
* Create a test program | ||
|
||
```sh | ||
cargo new hello_world | ||
cd hello_world | ||
``` | ||
|
||
* Build and run | ||
|
||
```sh | ||
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_RUNNER="qemu-arm -L ${TOOLCHAIN}/arm-buildroot-linux-uclibcgnueabihf/sysroot/" \ | ||
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_LINKER=${TOOLCHAIN}/bin/arm-buildroot-linux-uclibcgnueabihf-gcc \ | ||
cargo +stage2 run --target armv7-unknown-linux-uclibceabihf | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.