Add the rust std as a custom sysroot

This commit is contained in:
2026-03-17 18:29:00 +01:00
parent 404a681254
commit 46cdc3714e
50 changed files with 1158 additions and 320 deletions

109
library/std/.gitignore vendored Normal file
View File

@@ -0,0 +1,109 @@
build.rs
src/alloc.rs
src/ascii.rs
src/backtrace.rs
src/bstr.rs
src/env.rs
src/error.rs
src/fs.rs
src/keyword_docs.rs
src/lib.rs
src/macros.rs
src/panic.rs
src/panicking.rs
src/pat.rs
src/path.rs
src/process.rs
src/random.rs
src/rt.rs
src/tests_helpers.rs
src/time.rs
src/backtrace
src/collections
src/ffi
src/fs
src/hash
src/io
src/net
src/num
src/os/raw/mod.rs
src/os/raw/tests.rs
src/os/mod.rs
src/prelude
src/process
src/sync
src/sys/alloc/mod.rs
src/sys/args/mod.rs
src/sys/args/unsupported.rs
src/sys/env/mod.rs
src/sys/env/common.rs
src/sys/env/unsupported.rs
src/sys/fd/mod.rs
src/sys/fs/mod.rs
src/sys/fs/common.rs
src/sys/fs/unsupported.rs
src/sys/helpers/mod.rs
src/sys/helpers/small_c_string.rs
src/sys/helpers/tests.rs
src/sys/helpers/wstr.rs
src/sys/io/error/generic.rs
src/sys/io/error/mod.rs
src/sys/io/io_slice/unsupported.rs
src/sys/io/is_terminal/unsupported.rs
src/sys/io/kernel_copy/mod.rs
src/sys/io/mod.rs
src/sys/net/connection/mod.rs
src/sys/net/connection/unsupported.rs
src/sys/net/hostname/mod.rs
src/sys/net/hostname/unsupported.rs
src/sys/net/mod.rs
src/sys/os_str/bytes/tests.rs
src/sys/os_str/bytes.rs
src/sys/os_str/mod.rs
src/sys/pal/mod.rs
src/sys/pal/unsupported/mod.rs
src/sys/pal/unsupported/common.rs
src/sys/pal/unsupported/os.rs
src/sys/path/mod.rs
src/sys/path/unix.rs
src/sys/personality/dwarf/eh.rs
src/sys/personality/dwarf/mod.rs
src/sys/personality/dwarf/tests.rs
src/sys/personality/mod.rs
src/sys/pipe/mod.rs
src/sys/pipe/unsupported.rs
src/sys/platform_version/mod.rs
src/sys/process/mod.rs
src/sys/process/env.rs
src/sys/process/unsupported.rs
src/sys/random/mod.rs
src/sys/random/unsupported.rs
src/sys/stdio/mod.rs
src/sys/stdio/unsupported.rs
src/sys/sync/condvar/mod.rs
src/sys/sync/condvar/no_threads.rs
src/sys/sync/mutex/mod.rs
src/sys/sync/mutex/no_threads.rs
src/sys/sync/once/mod.rs
src/sys/sync/once/no_threads.rs
src/sys/sync/rwlock/mod.rs
src/sys/sync/rwlock/no_threads.rs
src/sys/sync/thread_parking/mod.rs
src/sys/sync/thread_parking/unsupported.rs
src/sys/sync/mod.rs
src/sys/sync/once_box.rs
src/sys/thread/mod.rs
src/sys/thread/unsupported.rs
src/sys/thread_local/mod.rs
src/sys/thread_local/no_threads.rs
src/sys/thread_local/os.rs
src/sys/time/mod.rs
src/sys/time/unsupported.rs
src/sys/backtrace.rs
src/sys/cmath.rs
src/sys/configure_builtins.rs
src/sys/env_consts.rs
src/sys/exit.rs
src/sys/mod.rs
src/thread

177
library/std/Cargo.toml Normal file
View File

@@ -0,0 +1,177 @@
cargo-features = ["public-dependency"]
[package]
name = "std"
version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "The Rust Standard Library"
edition = "2024"
autobenches = false
[lib]
crate-type = ["dylib", "rlib"]
[dependencies]
alloc = { path = "../alloc", public = true }
# std no longer uses cfg-if directly, but the included copy of backtrace does.
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.16.1", default-features = false, features = [
'rustc-dep-of-std',
] }
std_detect = { path = "../std_detect", public = true }
# Dependencies of the `backtrace` crate
rustc-demangle = { version = "0.1.27", features = ['rustc-dep-of-std'] }
[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies]
miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
addr2line = { version = "0.25.0", optional = true, default-features = false }
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
libc = { version = "0.2.178", default-features = false, features = [
'rustc-dep-of-std',
], public = true }
[target.'cfg(all(not(target_os = "aix"), not(all(windows, target_env = "msvc", not(target_vendor = "uwp")))))'.dependencies]
object = { version = "0.37.1", default-features = false, optional = true, features = [
'read_core',
'elf',
'macho',
'pe',
'unaligned',
'archive',
] }
[target.'cfg(target_os = "aix")'.dependencies]
object = { version = "0.37.1", default-features = false, optional = true, features = [
'read_core',
'xcoff',
'unaligned',
'archive',
] }
[target.'cfg(any(windows, target_os = "cygwin"))'.dependencies.windows-link]
path = "../windows_link"
[dev-dependencies]
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }
rand_xorshift = "0.4.0"
[target.'cfg(any(all(target_family = "wasm", target_os = "unknown"), target_os = "xous", target_os = "vexos", all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
dlmalloc = { version = "0.2.10", features = ['rustc-dep-of-std'] }
[target.x86_64-fortanix-unknown-sgx.dependencies]
fortanix-sgx-abi = { version = "0.6.1", features = [
'rustc-dep-of-std',
], public = true }
[target.'cfg(target_os = "motor")'.dependencies]
moto-rt = { version = "0.16", features = ['rustc-dep-of-std'], public = true }
[target.'cfg(target_os = "hermit")'.dependencies]
hermit-abi = { version = "0.5.0", features = [
'rustc-dep-of-std',
], public = true }
[target.'cfg(all(target_os = "wasi", target_env = "p1"))'.dependencies]
wasi = { version = "0.11.0", features = [
'rustc-dep-of-std',
], default-features = false }
[target.'cfg(all(target_os = "wasi", target_env = "p2"))'.dependencies]
wasip2 = { version = '0.14.4', features = [
'rustc-dep-of-std',
], default-features = false, package = 'wasi' }
[target.'cfg(all(target_os = "wasi", target_env = "p3"))'.dependencies]
wasip2 = { version = '0.14.4', features = [
'rustc-dep-of-std',
], default-features = false, package = 'wasi' }
[target.'cfg(target_os = "uefi")'.dependencies]
r-efi = { version = "5.2.0", features = ['rustc-dep-of-std'] }
r-efi-alloc = { version = "2.0.0", features = ['rustc-dep-of-std'] }
[target.'cfg(target_os = "vexos")'.dependencies]
vex-sdk = { version = "0.27.0", features = [
'rustc-dep-of-std',
], default-features = false }
[features]
default = ["compiler-builtins-mem"]
backtrace = [
'addr2line/rustc-dep-of-std',
'object/rustc-dep-of-std',
'miniz_oxide/rustc-dep-of-std',
]
# Disable symbolization in backtraces. For use with -Zbuild-std.
# FIXME: Ideally this should be an additive backtrace-symbolization feature
backtrace-trace-only = []
panic-unwind = ["dep:panic_unwind"]
compiler-builtins-c = ["alloc/compiler-builtins-c"]
compiler-builtins-mem = ["alloc/compiler-builtins-mem"]
llvm-libunwind = ["unwind/llvm-libunwind"]
system-llvm-libunwind = ["unwind/system-llvm-libunwind"]
# Choose algorithms that are optimized for binary size instead of runtime performance
optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"]
# Make `RefCell` store additional debugging information, which is printed out when
# a borrow error occurs
debug_refcell = ["core/debug_refcell"]
llvm_enzyme = ["core/llvm_enzyme"]
# Enable using raw-dylib for Windows imports.
# This will eventually be the default.
windows_raw_dylib = ["windows-link/windows_raw_dylib"]
[package.metadata.fortanix-sgx]
# Maximum possible number of threads when testing
threads = 125
# Maximum heap size
heap_size = 0x8000000
[[test]]
name = "pipe-subprocess"
path = "tests/pipe_subprocess.rs"
harness = false
[[test]]
name = "sync"
path = "tests/sync/lib.rs"
[[test]]
name = "thread_local"
path = "tests/thread_local/lib.rs"
[[bench]]
name = "stdbenches"
path = "benches/lib.rs"
test = true
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
# std use #[path] imports to portable-simd `std_float` crate
# and to the `backtrace` crate which messes-up with Cargo list
# of declared features, we therefor expect any feature cfg
'cfg(feature, values(any()))',
# Internal features aren't marked known config by default, we use these to
# gate tests.
'cfg(target_has_reliable_f16)',
'cfg(target_has_reliable_f16_math)',
'cfg(target_has_reliable_f128)',
'cfg(target_has_reliable_f128_math)',
]
# shared = { path = "../shared", features = ["user"] }
# io_crate = { package = "io", path = "../io", features = ["alloc_crate"] }

View File

@@ -0,0 +1,4 @@
# 55a \ target_os = "survos" => { \
# mod survos; \
# pub use survos::*; \
# }

View File

@@ -0,0 +1 @@
45a \ target_os = "survos",

View File

@@ -0,0 +1,6 @@
62a \ target_os = "survos" => { \
mod unsupported; \
pub use self::unsupported::*; \
mod survos; \
pub use self::survos::*; \
}

View File

@@ -0,0 +1,2 @@
108a \target_os = "survos",
124a \target_os = "survos",

View File

@@ -0,0 +1,6 @@
32a \ target_os = "survos",
129a \ target_os = "survos" => { \
// todo \
pub(crate) fn enable() {} \
}

22
library/std/riscv64.json Normal file
View File

@@ -0,0 +1,22 @@
{
"llvm-target": "riscv64",
"llvm-abiname": "lp64",
"abi": "lp64",
"data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
"target-endian": "little",
"target-pointer-width": 64,
"arch": "riscv64",
"os": "survos",
"vendor": "unknown",
"env": "",
"features": "+i,+m,+a,+zicsr",
"linker": "ld.lld",
"linker-flavor": "ld",
"executables": true,
"panic-strategy": "abort",
"relocation-model": "static",
"disable-redzone": true,
"emit-debug-gdb-scripts": false,
"eh-frame-header": false,
"code-model": "medium"
}

View File

@@ -0,0 +1,11 @@
/// # Safety
/// `argc` and `argv` are passed by the kernel
#[unsafe(no_mangle)]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe extern "C" fn _start(argc: isize, argv: *const *const u8) -> isize {
unsafe extern "C" {
fn main(argc: isize, argv: *const *const u8) -> isize;
}
unsafe { main(argc, argv) }
}