Skip to content

Commit 14768f9

Browse files
committed
create a nostd crate
the goal is to build, in a single Cargo invocation, several no-std crates that we want to put in the rust-std component of no-std targets. The nostd crate builds these crates: - core - compiler-builtin (with the "c" and "mem" features enabled) - alloc - std_unicode
1 parent 862c839 commit 14768f9

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

src/Cargo.lock

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"bootstrap",
44
"rustc",
5+
"libnostd",
56
"libstd",
67
"libtest",
78
"librustc_trans",

src/bootstrap/compile.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ pub fn std_cargo(build: &Builder,
145145
}
146146

147147
if build.no_std(target) == Some(true) {
148-
// for no-std targets we only compile core and compiler-builtins
149-
cargo.arg("--features").arg("c mem")
150-
.arg("--manifest-path")
151-
.arg(build.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
148+
// for no-std targets we compile a minimal nostd crate that only depends on crates that work
149+
// without an OS
150+
cargo.arg("--manifest-path")
151+
.arg(build.src.join("src/libnostd/Cargo.toml"));
152152
} else {
153153
let mut features = build.std_features();
154154

src/libnostd/Cargo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
authors = ["The Rust Project Developers"]
3+
name = "nostd"
4+
version = "0.0.0"
5+
license = "MIT/Apache-2.0"
6+
repository = "https://github.com/rust-lang/rust.git"
7+
description = "(not) The Rust Standard Library"
8+
9+
[lib]
10+
name = "nostd"
11+
path = "lib.rs"
12+
13+
[dependencies]
14+
alloc = { path = "../liballoc" }
15+
compiler_builtins = { path = "../rustc/compiler_builtins_shim", features = ["c", "mem"] }
16+
core = { path = "../libcore" }
17+
std_unicode = { path = "../libstd_unicode" }

src/libnostd/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#![feature(staged_api)]
2+
#![no_std]
3+
#![unstable(feature = "nostd", issue = "0")]

0 commit comments

Comments
 (0)