Skip to content

Commit fec8724

Browse files
author
Jorge Aparicio
committed
add support for building standard crates for thumb* targets
1 parent 0cff11c commit fec8724

11 files changed

+46
-17
lines changed

mk/cfg/thumbv6m-none-eabi.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

mk/cfg/thumbv7em-none-eabi.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

mk/cfg/thumbv7em-none-eabihf.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

mk/cfg/thumbv7m-none-eabi.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn krate(build: &Build,
265265
target: &str,
266266
mode: Mode) {
267267
let (name, path, features) = match mode {
268-
Mode::Libstd => ("libstd", "src/rustc/std_shim", build.std_features()),
268+
Mode::Libstd => ("libstd", "src/rustc/std_shim", build.std_features(target)),
269269
Mode::Libtest => ("libtest", "src/rustc/test_shim", String::new()),
270270
Mode::Librustc => ("librustc", "src/rustc", build.rustc_features()),
271271
_ => panic!("can only test libraries"),

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
6262
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
6363
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
6464
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
65-
cargo.arg("--features").arg(build.std_features())
65+
cargo.arg("--features").arg(build.std_features(target))
6666
.arg("--manifest-path")
6767
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
6868

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub fn std(build: &Build, stage: u32, target: &str, out: &Path) {
144144
let mut cargo = build.cargo(&compiler, Mode::Libstd, target, "doc");
145145
cargo.arg("--manifest-path")
146146
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
147-
.arg("--features").arg(build.std_features());
147+
.arg("--features").arg(build.std_features(target));
148148
build.run(&mut cargo);
149149
cp_r(&out_dir, out)
150150
}

src/bootstrap/lib.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -712,17 +712,27 @@ impl Build {
712712

713713
/// Get the space-separated set of activated features for the standard
714714
/// library.
715-
fn std_features(&self) -> String {
715+
fn std_features(&self, target: &str) -> String {
716716
let mut features = String::new();
717-
if self.config.debug_jemalloc {
718-
features.push_str(" debug-jemalloc");
719-
}
720-
if self.config.use_jemalloc {
721-
features.push_str(" jemalloc");
722-
}
723-
if self.config.backtrace {
724-
features.push_str(" backtrace");
717+
718+
if target.starts_with("thumbv6m") {
719+
features.push_str(" thumb_no_atomics");
720+
} else if target.starts_with("thumb") {
721+
features.push_str(" thumb");
722+
} else {
723+
features.push_str("full");
724+
725+
if self.config.debug_jemalloc {
726+
features.push_str(" debug-jemalloc");
727+
}
728+
if self.config.use_jemalloc {
729+
features.push_str(" jemalloc");
730+
}
731+
if self.config.backtrace {
732+
features.push_str(" backtrace");
733+
}
725734
}
735+
726736
return features
727737
}
728738

src/rustc/std_shim/Cargo.lock

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

src/rustc/std_shim/Cargo.toml

+16-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,23 @@ debug = false
4040
debug-assertions = false
4141

4242
[dependencies]
43-
std = { path = "../../libstd" }
44-
core = { path = "../../libcore" }
43+
# full
44+
std = { path = "../../libstd", optional = true }
45+
46+
# thumb
47+
compiler_builtins = { path = "../../libcompiler_builtins", optional = true }
48+
core = { path = "../../libcore", optional = true }
49+
rustc_unicode = { path = "../../librustc_unicode", optional = true }
50+
51+
# thumb-no-atomics
52+
collections = { path = "../../libcollections", optional = true }
53+
rand = { path = "../../librand", optional = true }
4554

4655
# Reexport features from std
4756
[features]
48-
jemalloc = ["std/jemalloc"]
49-
debug-jemalloc = ["std/debug-jemalloc"]
5057
backtrace = ["std/backtrace"]
58+
debug-jemalloc = ["std/debug-jemalloc"]
59+
jemalloc = ["std/jemalloc"]
60+
full = ["core", "std"]
61+
thumb_no_atomics = ["compiler_builtins", "core", "rustc_unicode"]
62+
thumb = ["core", "compiler_builtins", "collections", "rand"]

src/rustc/std_shim/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
// compiling then this doesn't work with `#[macro_use] extern crate std;`. Work
1515
// around this by not having `#[macro_use] extern crate std;`
1616
#![no_std]
17-
extern crate std;

0 commit comments

Comments
 (0)