【问题标题】:How can I add `aarch64-none-elf` to my Rust toolchain?如何将 `aarch64-none-elf` 添加到我的 Rust 工具链?
【发布时间】:2018-08-20 00:46:00
【问题描述】:

今天开始我的 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 吗? ;)
  • @Stargateur 但看起来 rustup 也没有 aarch64-none-elf 工具链。

标签: rust operating-system arm64 toolchain


【解决方案1】:

结果我需要做的只是运行rustup default nightly 并使用rustc 的夜间版本,如警告中所述,我能够克服该错误。如果有人想解释为什么会这样,那就太好了。

➜  phase4 git:(master) ✗ rustc --version
rustc 1.30.0-nightly (33b923fd4 2018-08-18)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 2020-10-06
    • 2020-02-19
    相关资源
    最近更新 更多