Hello! I've the following setup (assuming we're the src
directory):
main.rs
:
#![no_std]
#![no_main]
#![feature(const_ptr_offset)]
use os_clone2;
#[no_mangle]
pub extern "C" fn os_clone2_entry() -> ! {
loop {}
}
lib.rs
#![no_std]
#![no_main]
#![feature(const_ptr_offset)]
#![feature(custom_test_frameworks)]
#![test_runner(test_runner)]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
fn test_runner(_test: &[&i32]) {
loop {}
}
.cargo/config.toml
[build]
target = "target.json"
[unstable]
build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]
target.json
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}
Cargo.toml
[package]
name = "os_clone2"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
(I've configered rustup
to use the nightly
channel) If I run cargo clean && cargo build -Zbuild-std && cargo test
then I'm getting the following error message:
error[E0463]: can't find crate for `test`
But shouldn't it work according to this page? What am I doing wrong?
Edit
I created a test repository where you can get the exact same project to test with. Just run cargo test
with the nightly version with rustup
.