如何将 `aarch64-none-elf` 添加到我的 Rust 工具链?
How can I add `aarch64-none-elf` to my Rust toolchain?
今天开始我的 CS140e 工作时,我已经完成了项目的第 3 阶段(编写 C 代码以直接与 Raspberry Pi 3 上的 GPIO 引脚对话,这只会使 LED 闪烁)但在第 4 阶段,一旦我尝试在 Rust 中编译我的解决方案,rustc
似乎无法找到 aarch64-none-elf
目标:
➜ phase4 git:(master) ✗ make
+ Building target/aarch64-none-elf/release/libblinky.a [xargo --release]
WARNING: the sysroot can't be built for the Stable channel. Switch to nightly.
warning: `panic` setting is ignored for `test` profile
Compiling rlibc v1.0.0
error[E0463]: can't find crate for `core`
|
= note: the `aarch64-none-elf` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rlibc`.
To learn more, run the command again with --verbose.
Makefile:35: recipe for target 'target/aarch64-none-elf/release/libblinky.a' failed
make: *** [target/aarch64-none-elf/release/libblinky.a] Error 101
而且 rustc --print target-list
确实不包括 aarch64-none-elf
:
➜ phase4 git:(master) ✗ rustc --print target-list
aarch64-linux-android
aarch64-unknown-cloudabi
aarch64-unknown-freebsd
aarch64-unknown-fuchsia
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
aarch64-unknown-openbsd
...
虽然我已经安装了工具链:
➜ phase4 git:(master) ✗ whereis aarch64-none-elf-gcc
aarch64-none-elf-gcc: /usr/local/bin/aarch64-none-elf/bin/aarch64-none-elf-gcc
此外,我有一个名为 aarch64-none-elf.json
的自定义目标文件,其中包含这些内容(可能在构建时传递给 xargo
):
{
"abi-blacklist": [
"stdcall",
"fastcall",
"vectorcall",
"thiscall",
"win64",
"sysv64"
],
"arch": "aarch64",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"executables": true,
"linker": "aarch64-none-elf-ld",
"linker-flavor": "ld",
"linker-is-gnu": true,
"llvm-target": "aarch64-unknown-none",
"no-compiler-rt": true,
"features": "+a53,+strict-align",
"max-atomic-width": 128,
"os": "none",
"panic": "abort",
"panic-strategy": "abort",
"position-independent-executables": true,
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64",
"disable-redzone": true
}
原来我需要做的就是 运行 rustup default nightly
并使用 rustc
的夜间版本,如警告中所述,我能够克服该错误.如果有人想解释 为什么 这是,那就太好了。
➜ phase4 git:(master) ✗ rustc --version
rustc 1.30.0-nightly (33b923fd4 2018-08-18)
今天开始我的 CS140e 工作时,我已经完成了项目的第 3 阶段(编写 C 代码以直接与 Raspberry Pi 3 上的 GPIO 引脚对话,这只会使 LED 闪烁)但在第 4 阶段,一旦我尝试在 Rust 中编译我的解决方案,rustc
似乎无法找到 aarch64-none-elf
目标:
➜ phase4 git:(master) ✗ make
+ Building target/aarch64-none-elf/release/libblinky.a [xargo --release]
WARNING: the sysroot can't be built for the Stable channel. Switch to nightly.
warning: `panic` setting is ignored for `test` profile
Compiling rlibc v1.0.0
error[E0463]: can't find crate for `core`
|
= note: the `aarch64-none-elf` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rlibc`.
To learn more, run the command again with --verbose.
Makefile:35: recipe for target 'target/aarch64-none-elf/release/libblinky.a' failed
make: *** [target/aarch64-none-elf/release/libblinky.a] Error 101
而且 rustc --print target-list
确实不包括 aarch64-none-elf
:
➜ phase4 git:(master) ✗ rustc --print target-list
aarch64-linux-android
aarch64-unknown-cloudabi
aarch64-unknown-freebsd
aarch64-unknown-fuchsia
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
aarch64-unknown-openbsd
...
虽然我已经安装了工具链:
➜ phase4 git:(master) ✗ whereis aarch64-none-elf-gcc
aarch64-none-elf-gcc: /usr/local/bin/aarch64-none-elf/bin/aarch64-none-elf-gcc
此外,我有一个名为 aarch64-none-elf.json
的自定义目标文件,其中包含这些内容(可能在构建时传递给 xargo
):
{
"abi-blacklist": [
"stdcall",
"fastcall",
"vectorcall",
"thiscall",
"win64",
"sysv64"
],
"arch": "aarch64",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"executables": true,
"linker": "aarch64-none-elf-ld",
"linker-flavor": "ld",
"linker-is-gnu": true,
"llvm-target": "aarch64-unknown-none",
"no-compiler-rt": true,
"features": "+a53,+strict-align",
"max-atomic-width": 128,
"os": "none",
"panic": "abort",
"panic-strategy": "abort",
"position-independent-executables": true,
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64",
"disable-redzone": true
}
原来我需要做的就是 运行 rustup default nightly
并使用 rustc
的夜间版本,如警告中所述,我能够克服该错误.如果有人想解释 为什么 这是,那就太好了。
➜ phase4 git:(master) ✗ rustc --version
rustc 1.30.0-nightly (33b923fd4 2018-08-18)