加载目标规范时出错:找不到目标规范
Error loading target specification: Could not find specification for target
我正在关注 this tutorial 如何用 Rust 制作一个极其基本的操作系统。这是我目前的状态:
Cargo.toml
[package]
name = "blog_os"
version = "0.1.0"
authors = ["Philipp Oppermann <dev@phil-opp.com>"] # Here I used my own details
[lib]
crate-type = ["staticlib"]
src/lib.rs
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub extern fn rust_main() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}
x86_64-blog_os.json
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"arch": "x86_64",
"os": "none",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}
这里是Makefile。
如果您向下滚动到教程中的 修复链接器错误 部分,我们基本上会被要求将以下行添加到我们的 Cargo.toml
:
[dependencies]
rlibc = "1.0"
然后在lib.rs
中指定外部包(在#![no_std]
之后):
extern crate rlibc;
当我在终端中 运行 make run
时,我收到以下错误消息:
error: Error loading specification: Could not find specification for target "x86_64-blog_os"
error: Could not compile 'rlibc'
我们预计会收到一个错误...但不是这个。 修复链接器错误 部分中的示例给出了我们应该预料到的错误类型的概念。
可能出了什么问题?我在 Google 上到处搜索都没有找到解决方案。
我遇到了同样的问题。 Xargo 和 Cargo 上的这些问题似乎表明目标规范的位置存在错误:
在调用 xargo
之前设置 RUST_TARGET_PATH=pwd
为我解决了这个问题。给定 Makefile 中的调用将如下所示:
@RUST_TARGET_PATH=$(shell pwd) xargo build --target $(target)
我正在关注 this tutorial 如何用 Rust 制作一个极其基本的操作系统。这是我目前的状态:
Cargo.toml
[package]
name = "blog_os"
version = "0.1.0"
authors = ["Philipp Oppermann <dev@phil-opp.com>"] # Here I used my own details
[lib]
crate-type = ["staticlib"]
src/lib.rs
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub extern fn rust_main() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}
x86_64-blog_os.json
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"arch": "x86_64",
"os": "none",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}
这里是Makefile。
如果您向下滚动到教程中的 修复链接器错误 部分,我们基本上会被要求将以下行添加到我们的 Cargo.toml
:
[dependencies]
rlibc = "1.0"
然后在lib.rs
中指定外部包(在#![no_std]
之后):
extern crate rlibc;
当我在终端中 运行 make run
时,我收到以下错误消息:
error: Error loading specification: Could not find specification for target "x86_64-blog_os"
error: Could not compile 'rlibc'
我们预计会收到一个错误...但不是这个。 修复链接器错误 部分中的示例给出了我们应该预料到的错误类型的概念。
可能出了什么问题?我在 Google 上到处搜索都没有找到解决方案。
我遇到了同样的问题。 Xargo 和 Cargo 上的这些问题似乎表明目标规范的位置存在错误:
在调用 xargo
之前设置 RUST_TARGET_PATH=pwd
为我解决了这个问题。给定 Makefile 中的调用将如下所示:
@RUST_TARGET_PATH=$(shell pwd) xargo build --target $(target)