diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 22a9e10..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "library/backtrace"] - path = library/backtrace - url = https://github.com/rust-lang/backtrace-rs.git diff --git a/library/.gitignore b/library/.gitignore index efc0ca5..a69946a 100644 --- a/library/.gitignore +++ b/library/.gitignore @@ -1,3 +1,6 @@ +Cargo.toml + +backtrace portable-simd core_arch core @@ -15,3 +18,6 @@ windows_link profiler_builtins test proc_macro +alloctests +coretests +sysroot diff --git a/library/Cargo.toml b/library/Cargo.toml deleted file mode 100644 index ab037e8..0000000 --- a/library/Cargo.toml +++ /dev/null @@ -1,88 +0,0 @@ - -cargo-features = ["profile-rustflags"] - -[workspace] -resolver = "1" -members = [ - "std", - # "sysroot", - # "coretests", - # "alloctests", -] - -exclude = [ - # stdarch has its own Cargo workspace - "stdarch", - "windows_link" -] - -[profile.release.package.compiler_builtins] -# For compiler-builtins we always use a high number of codegen units. -# The goal here is to place every single intrinsic into its own object -# file to avoid symbol clashes with the system libgcc if possible. Note -# that this number doesn't actually produce this many object files, we -# just don't create more than this number of object files. -# -# It's a bit of a bummer that we have to pass this here, unfortunately. -# Ideally this would be specified through an env var to Cargo so Cargo -# knows how many CGUs are for this specific crate, but for now -# per-crate configuration isn't specifiable in the environment. -codegen-units = 10000 - -# These dependencies of the standard library implement symbolication for -# backtraces on most platforms. Their debuginfo causes both linking to be slower -# (more data to chew through) and binaries to be larger without really all that -# much benefit. This section turns them all to down to have no debuginfo which -# helps to improve link times a little bit. -[profile.release.package] -addr2line.debug = 0 -addr2line.opt-level = "s" -adler2.debug = 0 -gimli.debug = 0 -gimli.opt-level = "s" -miniz_oxide.debug = 0 -miniz_oxide.opt-level = "s" -# `opt-level = "s"` for `object` led to a size regression when tried previously -object.debug = 0 -rustc-demangle.debug = 0 -rustc-demangle.opt-level = "s" - -# panic_abort must always be compiled with panic=abort, even when the rest of the -# sysroot is panic=unwind. -[profile.dev.package.panic_abort] -rustflags = ["-Cpanic=abort"] - -[profile.release.package.panic_abort] -rustflags = ["-Cpanic=abort"] - -# The "dist" profile is used by bootstrap for prebuilt libstd artifacts -# These settings ensure that the prebuilt artifacts support a variety of features -# in the user's profile. -[profile.dist] -inherits = "release" -codegen-units = 1 -debug = 1 # "limited" -rustflags = [ - # `profile.lto=off` implies `-Cembed-bitcode=no`, but unconditionally embedding - # bitcode is necessary for when users enable LTO. - # Required until Cargo can re-build the standard library based on the value - # of `profile.lto` in the user's profile. - "-Cembed-bitcode=yes", - # Enable frame pointers - "-Zunstable-options", - "-Cforce-frame-pointers=non-leaf", -] - -[profile.dist.package.panic_abort] -rustflags = [ - "-Cpanic=abort", - "-Cembed-bitcode=yes", - "-Zunstable-options", - "-Cforce-frame-pointers=non-leaf", -] - -[patch.crates-io] -# See comments in `library/rustc-std-workspace-core/README.md` for what's going on here -rustc-std-workspace-core = { path = 'rustc-std-workspace-core' } -rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' } -# rustc-std-workspace-std = { path = 'rustc-std-workspace-std' } diff --git a/library/backtrace b/library/backtrace deleted file mode 160000 index 28ec93b..0000000 --- a/library/backtrace +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 28ec93b503bf0410745bc3d571bf3dc1caac3019 diff --git a/library/backtrace b/library/backtrace new file mode 120000 index 0000000..90b34e3 --- /dev/null +++ b/library/backtrace @@ -0,0 +1 @@ +/home/julien/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/backtrace \ No newline at end of file diff --git a/library/justfile b/library/justfile index c0d1165..e3610f2 100644 --- a/library/justfile +++ b/library/justfile @@ -31,6 +31,9 @@ real_cp_std path: @cp {{ RUST_SRC / "std/src" / path }} {{ "std/src" / path }} setup-std: + ln -fs {{ RUST_SRC / "Cargo.toml" }} "." + + ln -fs {{ RUST_SRC / "backtrace" }} "." ln -fs {{ RUST_SRC / "std_detect" }} "." ln -fs {{ RUST_SRC / "panic_abort" }} "." ln -fs {{ RUST_SRC / "panic_unwind" }} "." @@ -47,10 +50,15 @@ setup-std: ln -fs {{ RUST_SRC / "proc_macro" }} "." ln -fs {{ RUST_SRC / "profiler_builtins" }} "." ln -fs {{ RUST_SRC / "test" }} "." + ln -fs {{ RUST_SRC / "coretests" }} "." + ln -fs {{ RUST_SRC / "alloctests" }} "." + ln -fs {{ RUST_SRC / "sysroot" }} "." @just cp_std "../build.rs" @sed -i "59a\ || target_os == \"survos\"" std/build.rs + @just cp_std "../Cargo.toml" + @just cp_std "alloc.rs" @just cp_std "ascii.rs" @just cp_std "backtrace.rs" @@ -302,14 +310,15 @@ sys/exit.rs \ sys/mod.rs \ thread" -build-sysroot: update-std - RUSTFLAGS="-Zforce-unstable-if-unmarked -C relocation-model=pic -C link-arg=-pie" cargo build --target ../riscv64.json +build-sysroot: + RUSTFLAGS="-Zforce-unstable-if-unmarked -C relocation-model=pic -C link-arg=-pie" cargo build --package std --target ../riscv64.json \ + --features compiler-builtins-mem mkdir ../sysroot/lib/rustlib/riscv64/lib -p rm ../sysroot/lib/rustlib/riscv64/lib/* -rf cp target/riscv64/debug/deps/*.rlib ../sysroot/lib/rustlib/riscv64/lib clean: - # cargo clean + cargo clean rm ../sysroot/lib/rustlib/riscv64/lib/* -rf for file in {{ STD_FILES }}; do \ @@ -317,3 +326,5 @@ clean: done rm -rf std/build.rs + rm -rf std/Cargo.toml + rm -rf Cargo.toml diff --git a/library/std/.gitignore b/library/std/.gitignore index 6abdf1c..750959a 100644 --- a/library/std/.gitignore +++ b/library/std/.gitignore @@ -1,3 +1,4 @@ +Cargo.toml build.rs src/alloc.rs diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml deleted file mode 100644 index 388d917..0000000 --- a/library/std/Cargo.toml +++ /dev/null @@ -1,177 +0,0 @@ -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"] }