如何将`aarch64-none-elf`添加到我的Rust工具链中?

4

今天开始我的CS140e项目,我已经完成了第三阶段的工作(编写C代码直接与Raspberry Pi 3的GPIO引脚通信,只是闪烁一个LED),但在第四阶段,当我尝试在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? ;) - Stargateur
@Stargateur 但看起来 rustup 也没有 aarch64-none-elf 工具链。 - ozkriff
1个回答

2
原来我只需要运行rustup default nightly并使用夜间版本的rustc,如警告中所述,我就能够避免这个错误。如果有人想解释一下为什么,请讲一下。
➜  phase4 git:(master) ✗ rustc --version
rustc 1.30.0-nightly (33b923fd4 2018-08-18)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接