]> git.lizzy.rs Git - rust.git/commitdiff
test: Verify all sysroot crates are unstable
authorAlex Crichton <alex@alexcrichton.com>
Wed, 15 Feb 2017 16:53:18 +0000 (08:53 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 21 Feb 2017 19:38:17 +0000 (11:38 -0800)
As we continue to add more crates to the compiler and use them to implement
various features we want to be sure we're not accidentally expanding the API
surface area of the compiler! To that end this commit adds a new `run-make` test
which will attempt to `extern crate foo` all crates in the sysroot, verifying
that they're all unstable.

This commit discovered that the `std_shim` and `test_shim` crates were
accidentally stable and fixes the situation by deleting those shims. The shims
are no longer necessary due to changes in Cargo that have happened since they
were originally incepted.

14 files changed:
src/Cargo.lock
src/Cargo.toml
src/bootstrap/README.md
src/bootstrap/check.rs
src/bootstrap/compile.rs
src/bootstrap/doc.rs
src/bootstrap/metadata.rs
src/bootstrap/step.rs
src/liballoc_jemalloc/lib.rs
src/rustc/std_shim/Cargo.toml [deleted file]
src/rustc/std_shim/lib.rs [deleted file]
src/rustc/test_shim/Cargo.toml [deleted file]
src/rustc/test_shim/lib.rs [deleted file]
src/test/run-make/sysroot-crates-are-unstable/Makefile [new file with mode: 0644]

index 51d45c06fcb49f0cc0a97f69efd87110e972a15f..1d1d63c9ee46328201bde24841cc366ee65e00e9 100644 (file)
@@ -762,14 +762,6 @@ dependencies = [
  "unwind 0.0.0",
 ]
 
-[[package]]
-name = "std_shim"
-version = "0.0.0"
-dependencies = [
- "core 0.0.0",
- "std 0.0.0",
-]
-
 [[package]]
 name = "std_unicode"
 version = "0.0.0"
@@ -835,13 +827,6 @@ dependencies = [
  "term 0.0.0",
 ]
 
-[[package]]
-name = "test_shim"
-version = "0.0.0"
-dependencies = [
- "test 0.0.0",
-]
-
 [[package]]
 name = "thread-id"
 version = "2.0.0"
index d8dedd11f357d3ad9c164a6668399ded8c7a324a..0dafbb8428e3ebf6cd1d44d149805c914cff3e46 100644 (file)
@@ -2,8 +2,8 @@
 members = [
   "bootstrap",
   "rustc",
-  "rustc/std_shim",
-  "rustc/test_shim",
+  "libstd",
+  "libtest",
   "tools/cargotest",
   "tools/compiletest",
   "tools/error_index_generator",
index ac84edb4038470445bdc7e56b93ade654fa4c18b..2f7757fb1d5ba61de10331c6bbccf80e2d34555a 100644 (file)
@@ -267,8 +267,8 @@ build/
 The current build is unfortunately not quite as simple as `cargo build` in a
 directory, but rather the compiler is split into three different Cargo projects:
 
-* `src/rustc/std_shim` - a project which builds and compiles libstd
-* `src/rustc/test_shim` - a project which builds and compiles libtest
+* `src/libstd` - the standard library
+* `src/libtest` - testing support, depends on libstd
 * `src/rustc` - the actual compiler itself
 
 Each "project" has a corresponding Cargo.lock file with all dependencies, and
index 00758460becc58790ef7e9547bfa4cc70633d647..dfe96b51799c0f5813442a69fbc020513370e5b6 100644 (file)
@@ -346,10 +346,10 @@ pub fn krate(build: &Build,
              krate: Option<&str>) {
     let (name, path, features, root) = match mode {
         Mode::Libstd => {
-            ("libstd", "src/rustc/std_shim", build.std_features(), "std_shim")
+            ("libstd", "src/libstd", build.std_features(), "std")
         }
         Mode::Libtest => {
-            ("libtest", "src/rustc/test_shim", String::new(), "test_shim")
+            ("libtest", "src/libtest", String::new(), "test")
         }
         Mode::Librustc => {
             ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
index 0b1a1f39d8d42e1765950e7c0d3fcdf9871ca366..00904bc776aa909eb791d8b538f4fceb7a1d6e09 100644 (file)
@@ -64,7 +64,7 @@ pub fn std(build: &Build, target: &str, compiler: &Compiler) {
     }
     cargo.arg("--features").arg(features)
          .arg("--manifest-path")
-         .arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
+         .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 {
@@ -162,7 +162,7 @@ pub fn test(build: &Build, target: &str, compiler: &Compiler) {
     build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
     let mut cargo = build.cargo(compiler, Mode::Libtest, target, "build");
     cargo.arg("--manifest-path")
-         .arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
+         .arg(build.src.join("src/libtest/Cargo.toml"));
     build.run(&mut cargo);
     update_mtime(build, &libtest_stamp(build, compiler, target));
 }
index 74b13144f2ff0e0984c9e42a9ca6e56010a25968..3fcc15b35b541e75b88abbb0dd6123dcc0dc743a 100644 (file)
@@ -152,7 +152,7 @@ pub fn std(build: &Build, stage: u32, target: &str) {
 
     let mut cargo = build.cargo(&compiler, Mode::Libstd, target, "doc");
     cargo.arg("--manifest-path")
-         .arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
+         .arg(build.src.join("src/libstd/Cargo.toml"))
          .arg("--features").arg(build.std_features());
 
     // We don't want to build docs for internal std dependencies unless
@@ -198,7 +198,7 @@ pub fn test(build: &Build, stage: u32, target: &str) {
 
     let mut cargo = build.cargo(&compiler, Mode::Libtest, target, "doc");
     cargo.arg("--manifest-path")
-         .arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
+         .arg(build.src.join("src/libtest/Cargo.toml"));
     build.run(&mut cargo);
     cp_r(&out_dir, &out)
 }
index 8befb105ff618974e5650bf7977fd7d720578eed..5ab542b6a24893c1281eddf0f3cc6a5a2fc63017 100644 (file)
@@ -43,8 +43,8 @@ struct ResolveNode {
 }
 
 pub fn build(build: &mut Build) {
-    build_krate(build, "src/rustc/std_shim");
-    build_krate(build, "src/rustc/test_shim");
+    build_krate(build, "src/libstd");
+    build_krate(build, "src/libtest");
     build_krate(build, "src/rustc");
 }
 
index ee5b61062fed86dc4fd32eeb998958ed7d2a74d8..ef84693b5b319db2320aa088469283bdc80f8ec0 100644 (file)
@@ -246,14 +246,14 @@ fn crate_rule<'a, 'b>(build: &'a Build,
     crate_rule(build,
                &mut rules,
                "libstd-link",
-               "build-crate-std_shim",
+               "build-crate-std",
                compile::std_link)
         .dep(|s| s.name("startup-objects"))
         .dep(|s| s.name("create-sysroot").target(s.host));
     crate_rule(build,
                &mut rules,
                "libtest-link",
-               "build-crate-test_shim",
+               "build-crate-test",
                compile::test_link)
         .dep(|s| s.name("libstd-link"));
     crate_rule(build,
@@ -263,13 +263,13 @@ fn crate_rule<'a, 'b>(build: &'a Build,
                compile::rustc_link)
         .dep(|s| s.name("libtest-link"));
 
-    for (krate, path, _default) in krates("std_shim") {
+    for (krate, path, _default) in krates("std") {
         rules.build(&krate.build_step, path)
              .dep(|s| s.name("startup-objects"))
              .dep(move |s| s.name("rustc").host(&build.config.build).target(s.host))
              .run(move |s| compile::std(build, s.target, &s.compiler()));
     }
-    for (krate, path, _default) in krates("test_shim") {
+    for (krate, path, _default) in krates("test") {
         rules.build(&krate.build_step, path)
              .dep(|s| s.name("libstd-link"))
              .run(move |s| compile::test(build, s.target, &s.compiler()));
@@ -384,7 +384,7 @@ fn crate_rule<'a, 'b>(build: &'a Build,
               "pretty", "run-fail-fulldeps");
     }
 
-    for (krate, path, _default) in krates("std_shim") {
+    for (krate, path, _default) in krates("std") {
         rules.test(&krate.test_step, path)
              .dep(|s| s.name("libtest"))
              .dep(|s| s.name("emulator-copy-libs"))
@@ -400,7 +400,7 @@ fn crate_rule<'a, 'b>(build: &'a Build,
                                     Mode::Libstd, TestKind::Test, None));
 
     // std benchmarks
-    for (krate, path, _default) in krates("std_shim") {
+    for (krate, path, _default) in krates("std") {
         rules.bench(&krate.bench_step, path)
              .dep(|s| s.name("libtest"))
              .dep(|s| s.name("emulator-copy-libs"))
@@ -415,7 +415,7 @@ fn crate_rule<'a, 'b>(build: &'a Build,
          .run(move |s| check::krate(build, &s.compiler(), s.target,
                                     Mode::Libstd, TestKind::Bench, None));
 
-    for (krate, path, _default) in krates("test_shim") {
+    for (krate, path, _default) in krates("test") {
         rules.test(&krate.test_step, path)
              .dep(|s| s.name("libtest"))
              .dep(|s| s.name("emulator-copy-libs"))
@@ -583,13 +583,13 @@ fn crate_rule<'a, 'b>(build: &'a Build,
          .default(build.config.docs)
          .host(true)
          .run(move |s| doc::error_index(build, s.target));
-    for (krate, path, default) in krates("std_shim") {
+    for (krate, path, default) in krates("std") {
         rules.doc(&krate.doc_step, path)
              .dep(|s| s.name("libstd-link"))
              .default(default && build.config.docs)
              .run(move |s| doc::std(build, s.stage, s.target));
     }
-    for (krate, path, default) in krates("test_shim") {
+    for (krate, path, default) in krates("test") {
         rules.doc(&krate.doc_step, path)
              .dep(|s| s.name("libtest-link"))
              .default(default && build.config.compiler_docs)
@@ -1154,23 +1154,23 @@ fn build(args: &[&str],
 
         let mut build = Build::new(flags, config);
         let cwd = env::current_dir().unwrap();
-        build.crates.insert("std_shim".to_string(), ::Crate {
-            name: "std_shim".to_string(),
+        build.crates.insert("std".to_string(), ::Crate {
+            name: "std".to_string(),
             deps: Vec::new(),
-            path: cwd.join("src/std_shim"),
-            doc_step: "doc-std_shim".to_string(),
-            build_step: "build-crate-std_shim".to_string(),
-            test_step: "test-std_shim".to_string(),
-            bench_step: "bench-std_shim".to_string(),
+            path: cwd.join("src/std"),
+            doc_step: "doc-std".to_string(),
+            build_step: "build-crate-std".to_string(),
+            test_step: "test-std".to_string(),
+            bench_step: "bench-std".to_string(),
         });
-        build.crates.insert("test_shim".to_string(), ::Crate {
-            name: "test_shim".to_string(),
+        build.crates.insert("test".to_string(), ::Crate {
+            name: "test".to_string(),
             deps: Vec::new(),
-            path: cwd.join("src/test_shim"),
-            doc_step: "doc-test_shim".to_string(),
-            build_step: "build-crate-test_shim".to_string(),
-            test_step: "test-test_shim".to_string(),
-            bench_step: "bench-test_shim".to_string(),
+            path: cwd.join("src/test"),
+            doc_step: "doc-test".to_string(),
+            build_step: "build-crate-test".to_string(),
+            test_step: "test-test".to_string(),
+            bench_step: "bench-test".to_string(),
         });
         build.crates.insert("rustc-main".to_string(), ::Crate {
             name: "rustc-main".to_string(),
@@ -1360,7 +1360,7 @@ fn dist_host_with_target_flag() {
         let all = rules.expand(&plan);
         println!("all rules: {:#?}", all);
         assert!(!all.contains(&step.name("rustc")));
-        assert!(!all.contains(&step.name("build-crate-std_shim").stage(1)));
+        assert!(!all.contains(&step.name("build-crate-std").stage(1)));
 
         // all stage0 compiles should be for the build target, A
         for step in all.iter().filter(|s| s.stage == 0) {
@@ -1425,7 +1425,7 @@ fn build_filtered() {
 
         assert!(!plan.iter().any(|s| s.name.contains("rustc")));
         assert!(plan.iter().all(|s| {
-            !s.name.contains("test_shim") || s.target == "C"
+            !s.name.contains("test") || s.target == "C"
         }));
     }
 
index 8d81a09f5af0fbf947726145a61a7c8f42235e57..a496ab870c63b83a0fac2e0a5d683c5408be85a5 100644 (file)
@@ -122,18 +122,6 @@ pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
         let flags = align_to_flags(align);
         unsafe { nallocx(size as size_t, flags) as usize }
     }
-
-    // These symbols are used by jemalloc on android but the really old android
-    // we're building on doesn't have them defined, so just make sure the symbols
-    // are available.
-    #[no_mangle]
-    #[cfg(all(target_os = "android", not(cargobuild)))]
-    pub extern "C" fn pthread_atfork(_prefork: *mut u8,
-                                     _postfork_parent: *mut u8,
-                                     _postfork_child: *mut u8)
-                                     -> i32 {
-        0
-    }
 }
 
 #[cfg(dummy_jemalloc)]
diff --git a/src/rustc/std_shim/Cargo.toml b/src/rustc/std_shim/Cargo.toml
deleted file mode 100644 (file)
index db96079..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-# This is a shim Cargo.toml which serves as a proxy for building the standard
-# library. The reason for this is a little subtle, as one might reasonably
-# expect that we just `cargo build` the standard library itself.
-#
-# One of the output artifacts for the standard library is a dynamic library, and
-# on platforms like OSX the name of the output artifact is actually encoded into
-# the library itself (similar to a soname on Linux). When the library is linked
-# against, this encoded name is what's literally looked for at runtime when the
-# dynamic loader is probing for libraries.
-#
-# Cargo, however, by default will not mangle the output filename of the
-# top-level target. If we were to run `cargo build` on libstd itself, we would
-# generate a file `libstd.so`. When installing, however, this file is called
-# something like `libstd-abcdef0123.so`. On OSX at least this causes a failure
-# at runtime because the encoded "soname" is `libstd.so`, not what the file is
-# actually called.
-#
-# By using this shim library to build the standard library by proxy we sidestep
-# this problem. The standard library is built with mangled hex already in its
-# name so there's nothing extra we need to do.
-
-[package]
-name = "std_shim"
-version = "0.0.0"
-authors = ["The Rust Project Developers"]
-
-[lib]
-name = "std_shim"
-path = "lib.rs"
-doc = false
-
-[dependencies]
-std = { path = "../../libstd" }
-core = { path = "../../libcore" }
-
-# Reexport features from std
-[features]
-asan = ["std/asan"]
-backtrace = ["std/backtrace"]
-debug-jemalloc = ["std/debug-jemalloc"]
-jemalloc = ["std/jemalloc"]
-force_alloc_system = ["std/force_alloc_system"]
-lsan = ["std/lsan"]
-msan = ["std/msan"]
-panic-unwind = ["std/panic-unwind"]
-tsan = ["std/tsan"]
diff --git a/src/rustc/std_shim/lib.rs b/src/rustc/std_shim/lib.rs
deleted file mode 100644 (file)
index 2fc5d8d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// See comments in Cargo.toml for why this exists
-
-// There's a bug right now where if we pass --extern std=... and we're cross
-// compiling then this doesn't work with `#[macro_use] extern crate std;`. Work
-// around this by not having `#[macro_use] extern crate std;`
-#![no_std]
-extern crate std;
diff --git a/src/rustc/test_shim/Cargo.toml b/src/rustc/test_shim/Cargo.toml
deleted file mode 100644 (file)
index 6ef613e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# This is a shim Cargo.toml which serves as a proxy for building libtest.
-#
-# The reason this shim exists is basically the same reason that `std_shim`
-# exists, and more documentation can be found in that `Cargo.toml` as to why.
-
-[package]
-name = "test_shim"
-version = "0.0.0"
-authors = ["The Rust Project Developers"]
-
-[lib]
-name = "test_shim"
-path = "lib.rs"
-
-[dependencies]
-test = { path = "../../libtest" }
diff --git a/src/rustc/test_shim/lib.rs b/src/rustc/test_shim/lib.rs
deleted file mode 100644 (file)
index d614d96..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// See comments in Cargo.toml for why this exists
-
-#![feature(test)]
-
-extern crate test;
diff --git a/src/test/run-make/sysroot-crates-are-unstable/Makefile b/src/test/run-make/sysroot-crates-are-unstable/Makefile
new file mode 100644 (file)
index 0000000..2bdc76e
--- /dev/null
@@ -0,0 +1,34 @@
+-include ../tools.mk
+
+# This is a whitelist of crates which are stable, we don't check for the
+# instability of these crates as they're all stable!
+STABLE_CRATES := \
+       std \
+       core \
+       proc_macro \
+       rsbegin.o \
+       rsend.o \
+       dllcrt2.o \
+       crt2.o
+
+# Generate a list of all crates in the sysroot. To do this we list all files in
+# rustc's sysroot, look at the filename, strip everything after the `-`, and
+# strip the leading `lib` (if present)
+SYSROOT := $(shell $(RUSTC) --print sysroot)
+LIBS := $(wildcard $(SYSROOT)/lib/rustlib/$(TARGET)/lib/*)
+LIBS := $(foreach lib,$(LIBS),$(notdir $(lib)))
+LIBS := $(foreach lib,$(LIBS),$(word 1,$(subst -, ,$(lib))))
+LIBS := $(foreach lib,$(LIBS),$(patsubst lib%,%,$(lib)))
+LIBS := $(filter-out $(STABLE_CRATES),$(LIBS))
+
+all: $(foreach lib,$(LIBS),check-crate-$(lib)-is-unstable)
+
+check-crate-%-is-unstable:
+       @echo verifying $* is an unstable crate
+       @echo 'extern crate $*;' | \
+               $(RUSTC) - --crate-type rlib 2>&1 | cat > $(TMPDIR)/$*; \
+               true
+       @grep -q 'use of unstable library feature' $(TMPDIR)/$* || \
+               (echo crate $* is not unstable && \
+               cat $(TMPDIR)/$* && \
+               false)