我试图按照内嵌式中解释的步骤来编译最小的#![no-std]
程序,但是在新架构上有一个新的目标。
./x.py setup
,然后更新config.toml:[llvm]
download-ci-llvm = false
ninja = true
targets = "X86"
experimental-targets = "ARC"
arc-pc-unknown-gnu.json
并通过RUST_TARGET_PATH
envvar使其可见:{
"arch": "arc",
"cpu": "generic",
"abi": "eabi",
"c-enum-min-bits": 8,
"data-layout": "e-m:e-p:32:32-i64:32-f64:32-v64:32-v128:32-a:0:32-n32",
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"executables": true,
"features": "",
"linker": "rust-lld",
"linker-flavor": "ld.lld",
"llvm-target": "arc-pc-unknown-gnu",
"max-atomic-width": 32,
"atomic-cas": false,
"panic-strategy": "abort",
"relocation-model": "static",
"target-pointer-width": "32"
}
./x.py build -i --target=arc-pc-unknown-gnu library/core
。它成功地完成了,我可以看到用于arc-pc-unknown-gnu
目标的arc-pc-unknown-gnu
库$ rustc --emit=llvm-ir -o rust_main.ll -C panic=abort --target arc-pc-unknown-gnu src/main.rs
error[E0463]: can't find crate for `core`
|
= note: the `arc-pc-unknown-gnu` target may not be installed
= help: consider downloading the target with `rustup target add arc-pc-unknown-gnu`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
error[E0463]: can't find crate for `compiler_builtins`
error[E0412]: cannot find type `PanicInfo` in this scope
--> src/main.rs:18:18
这很奇怪,因为在上一步我应该为我的目标编译这些库.
cargo build-std
重建libcore (虽然我不知道确切原因,但网络上有人提到了这一点)?我尝试过这样做,但是现在有以下错误:$ cargo build -Z build-std=core --target arc-pc-unknown-gnu
Compiling compiler_builtins v0.1.70
Compiling core v0.0.0 (/home/valeriyk/proj/rust-arc/1.60.0/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/core)
error[E0463]: can't find crate for `std`
error: cannot find macro `println` in this scope
--> /home/valeriyk/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.70/build.rs:88:9
|
88 | println!("cargo:rustc-cfg=kernel_user_helpers")
| ^^^^^^^
error: cannot find macro `println` in this scope
--> /home/valeriyk/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.70/build.rs:78:9
|
78 | println!("cargo:rustc-cfg=thumb_1")
| ^^^^^^^
...
为什么libcore
需要std
?我只想让它使用stage1 rustc进行交叉编译,然后在我的#示例编译过程中学习。如有任何指导,将不胜感激。
发布于 2022-05-19 18:15:32
我就是这样解决这个问题的:
compiler_builtins
不兼容。有关更多详细信息,请参阅这里。然后我需要升级到最新的夜间。$ ./x.py build -i --stage=1 --target=arcv2-none-elf32 compiler/rustc
.cargo/config.toml
,不要使用Xargo
或-Z build-std=core
。compiler-builtins-mem
的事情被解释为这里。[unstable]
build-std = [
"core",
"compiler_builtins"
]
build-std-features = ["compiler-builtins-mem"]
[build]
target = "arcv2-none-elf32"
cargo build
构建代码。它编译得很好,尽管后来没能链接起来--但这是另一个故事。https://stackoverflow.com/questions/72247284
复制相似问题