about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-04-05 16:51:24 +0800
committerkennytm <kennytm@gmail.com>2018-04-05 18:37:25 +0800
commitb146e335180e00db10d729837cd0507b4a945be5 (patch)
tree7500f08813237e7b163c5dd9cac077b3288cdea7 /src
parent23689cc8e9a6d2c1e6b5f01c749714194bf8f653 (diff)
parentb1015f5c5a4dcd6118b86ef5361371f04a7bce8b (diff)
downloadrust-b146e335180e00db10d729837cd0507b4a945be5.tar.gz
rust-b146e335180e00db10d729837cd0507b4a945be5.zip
Rollup merge of #49563 - japaric:std-thumb, r=alexcrichton
add a dist builder to build rust-std components for the THUMB targets

the rust-std component only contains the core and compiler-builtins (+c +mem) crates

cc #49382

- I'm not entirely sure if this PR alone will produce rust-std components installable by rustup or if something else needs to be changed
- I could have done the THUMB builds in an existing builder / image; I wasn't sure if that was a good idea so I added a new image
- I could build other crates like alloc into the rust-std component but, AFAICT, that would require calling Cargo a second time (one for alloc and one for compiler-builtins), or have alloc depend on compiler-builtins (#49503 will perform that change) *and* have alloc resurface the "c" and "mem" Cargo features.

r? @alexcrichton
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/compile.rs78
-rw-r--r--src/bootstrap/config.rs1
-rw-r--r--src/bootstrap/dist.rs7
-rw-r--r--src/bootstrap/lib.rs6
-rw-r--r--src/bootstrap/sanity.rs13
-rw-r--r--src/ci/docker/dist-various-1/Dockerfile8
-rw-r--r--src/rustc/compiler_builtins_shim/Cargo.toml1
7 files changed, 78 insertions, 36 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index da57881202d..9cc18464fea 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -140,48 +140,58 @@ pub fn std_cargo(build: &Builder,
                  compiler: &Compiler,
                  target: Interned<String>,
                  cargo: &mut Command) {
-    let mut features = build.std_features();
-
     if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
         cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
     }
 
-    // When doing a local rebuild we tell cargo that we're stage1 rather than
-    // stage0. This works fine if the local rust and being-built rust have the
-    // same view of what the default allocator is, but fails otherwise. Since
-    // we don't have a way to express an allocator preference yet, work
-    // around the issue in the case of a local rebuild with jemalloc disabled.
-    if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
-        features.push_str(" force_alloc_system");
-    }
+    if build.no_std(target) == Some(true) {
+        // for no-std targets we only compile a few no_std crates
+        cargo.arg("--features").arg("c mem")
+            .args(&["-p", "alloc"])
+            .args(&["-p", "compiler_builtins"])
+            .args(&["-p", "std_unicode"])
+            .arg("--manifest-path")
+            .arg(build.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
+    } else {
+        let mut features = build.std_features();
+
+        // When doing a local rebuild we tell cargo that we're stage1 rather than
+        // stage0. This works fine if the local rust and being-built rust have the
+        // same view of what the default allocator is, but fails otherwise. Since
+        // we don't have a way to express an allocator preference yet, work
+        // around the issue in the case of a local rebuild with jemalloc disabled.
+        if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
+            features.push_str(" force_alloc_system");
+        }
 
-    if compiler.stage != 0 && build.config.sanitizers {
-        // This variable is used by the sanitizer runtime crates, e.g.
-        // rustc_lsan, to build the sanitizer runtime from C code
-        // When this variable is missing, those crates won't compile the C code,
-        // so we don't set this variable during stage0 where llvm-config is
-        // missing
-        // We also only build the runtimes when --enable-sanitizers (or its
-        // config.toml equivalent) is used
-        let llvm_config = build.ensure(native::Llvm {
-            target: build.config.build,
-            emscripten: false,
-        });
-        cargo.env("LLVM_CONFIG", llvm_config);
-    }
+        if compiler.stage != 0 && build.config.sanitizers {
+            // This variable is used by the sanitizer runtime crates, e.g.
+            // rustc_lsan, to build the sanitizer runtime from C code
+            // When this variable is missing, those crates won't compile the C code,
+            // so we don't set this variable during stage0 where llvm-config is
+            // missing
+            // We also only build the runtimes when --enable-sanitizers (or its
+            // config.toml equivalent) is used
+            let llvm_config = build.ensure(native::Llvm {
+                target: build.config.build,
+                emscripten: false,
+            });
+            cargo.env("LLVM_CONFIG", llvm_config);
+        }
 
-    cargo.arg("--features").arg(features)
-        .arg("--manifest-path")
-        .arg(build.src.join("src/libstd/Cargo.toml"));
+        cargo.arg("--features").arg(features)
+            .arg("--manifest-path")
+            .arg(build.src.join("src/libstd/Cargo.toml"));
 
-    if let Some(target) = build.config.target_config.get(&target) {
-        if let Some(ref jemalloc) = target.jemalloc {
-            cargo.env("JEMALLOC_OVERRIDE", jemalloc);
+        if let Some(target) = build.config.target_config.get(&target) {
+            if let Some(ref jemalloc) = target.jemalloc {
+                cargo.env("JEMALLOC_OVERRIDE", jemalloc);
+            }
         }
-    }
-    if target.contains("musl") {
-        if let Some(p) = build.musl_root(target) {
-            cargo.env("MUSL_ROOT", p);
+        if target.contains("musl") {
+            if let Some(p) = build.musl_root(target) {
+                cargo.env("MUSL_ROOT", p);
+            }
         }
     }
 }
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 76672df5c57..863abd14935 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -161,6 +161,7 @@ pub struct Target {
     pub crt_static: Option<bool>,
     pub musl_root: Option<PathBuf>,
     pub qemu_rootfs: Option<PathBuf>,
+    pub no_std: bool,
 }
 
 /// Structure of the `config.toml` file that configuration is read from.
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index c9be17ff1ad..e1f5d34bf67 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -642,7 +642,12 @@ impl Step for Std {
         if build.hosts.iter().any(|t| t == target) {
             builder.ensure(compile::Rustc { compiler, target });
         } else {
-            builder.ensure(compile::Test { compiler, target });
+            if build.no_std(target) == Some(true) {
+                // the `test` doesn't compile for no-std targets
+                builder.ensure(compile::Std { compiler, target });
+            } else {
+                builder.ensure(compile::Test { compiler, target });
+            }
         }
 
         let image = tmpdir(build).join(format!("{}-{}-image", name, target));
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 2eeb2691eae..ea4368c0323 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -750,6 +750,12 @@ impl Build {
             .map(|p| &**p)
     }
 
+    /// Returns true if this is a no-std `target`, if defined
+    fn no_std(&self, target: Interned<String>) -> Option<bool> {
+        self.config.target_config.get(&target)
+            .map(|t| t.no_std)
+    }
+
     /// Returns whether the target will be tested using the `remote-test-client`
     /// and `remote-test-server` binaries.
     fn remote_tested(&self, target: Interned<String>) -> bool {
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index 5184cca653c..1b1cec5f18c 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -169,6 +169,19 @@ pub fn check(build: &mut Build) {
             panic!("the iOS target is only supported on macOS");
         }
 
+        if target.contains("-none-") {
+            if build.no_std(*target).is_none() {
+                let target = build.config.target_config.entry(target.clone())
+                    .or_insert(Default::default());
+
+                target.no_std = true;
+            }
+
+            if build.no_std(*target) == Some(false) {
+                panic!("All the *-none-* targets are no-std targets")
+            }
+        }
+
         // Make sure musl-root is valid
         if target.contains("musl") {
             // If this is a native target (host is also musl) and no musl-root is given,
diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
index 1b6ee44d87a..00366301aa1 100644
--- a/src/ci/docker/dist-various-1/Dockerfile
+++ b/src/ci/docker/dist-various-1/Dockerfile
@@ -20,7 +20,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
   bzip2 \
   patch \
   libssl-dev \
-  pkg-config
+  pkg-config \
+  gcc-arm-none-eabi \
+  libnewlib-arm-none-eabi
 
 WORKDIR /build
 
@@ -86,6 +88,10 @@ ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
 ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl
 ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
 ENV TARGETS=$TARGETS,x86_64-unknown-redox
+ENV TARGETS=$TARGETS,thumbv6m-none-eabi
+ENV TARGETS=$TARGETS,thumbv7m-none-eabi
+ENV TARGETS=$TARGETS,thumbv7em-none-eabi
+ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
 
 # FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271
 #        get fixed and cc update
diff --git a/src/rustc/compiler_builtins_shim/Cargo.toml b/src/rustc/compiler_builtins_shim/Cargo.toml
index 608e5f5f36d..7d8423ca84e 100644
--- a/src/rustc/compiler_builtins_shim/Cargo.toml
+++ b/src/rustc/compiler_builtins_shim/Cargo.toml
@@ -35,5 +35,6 @@ cc = "1.0.1"
 [features]
 c = []
 default = ["c", "rustbuild", "compiler-builtins"]
+mem = []
 rustbuild = []
 compiler-builtins = []