]> git.lizzy.rs Git - rust.git/commitdiff
Inject the `compiler_builtins` crate whenever the `core` crate is injected
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 30 Mar 2018 11:06:34 +0000 (13:06 +0200)
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Sat, 7 Apr 2018 07:24:35 +0000 (09:24 +0200)
18 files changed:
src/Cargo.lock
src/liballoc/Cargo.toml
src/liballoc_jemalloc/Cargo.toml
src/liballoc_system/Cargo.toml
src/libpanic_abort/Cargo.toml
src/libpanic_unwind/Cargo.toml
src/libprofiler_builtins/Cargo.toml
src/librustc_asan/Cargo.toml
src/librustc_lsan/Cargo.toml
src/librustc_msan/Cargo.toml
src/librustc_tsan/Cargo.toml
src/libstd/lib.rs
src/libstd_unicode/Cargo.toml
src/libsyntax/print/pprust.rs
src/libsyntax/std_inject.rs
src/libunwind/Cargo.toml
src/rustc/dlmalloc_shim/Cargo.toml
src/rustc/libc_shim/Cargo.toml

index f70fc81829f58e95a8d1c36d3abd99d194a82a0b..004d1c0ffc933aa56b69d79a12958630ef09784e 100644 (file)
@@ -10,6 +10,7 @@ dependencies = [
 name = "alloc"
 version = "0.0.0"
 dependencies = [
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
  "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "std_unicode 0.0.0",
@@ -23,6 +24,7 @@ dependencies = [
  "alloc_system 0.0.0",
  "build_helper 0.1.0",
  "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
  "libc 0.0.0",
 ]
@@ -32,6 +34,7 @@ name = "alloc_system"
 version = "0.0.0"
 dependencies = [
  "alloc 0.0.0",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
  "dlmalloc 0.0.0",
  "libc 0.0.0",
@@ -541,6 +544,7 @@ name = "dlmalloc"
 version = "0.0.0"
 dependencies = [
  "alloc 0.0.0",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -976,6 +980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 name = "libc"
 version = "0.0.0"
 dependencies = [
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -1254,6 +1259,7 @@ dependencies = [
 name = "panic_abort"
 version = "0.0.0"
 dependencies = [
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
  "libc 0.0.0",
 ]
@@ -1263,6 +1269,7 @@ name = "panic_unwind"
 version = "0.0.0"
 dependencies = [
  "alloc 0.0.0",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
  "libc 0.0.0",
  "unwind 0.0.0",
@@ -1401,6 +1408,7 @@ name = "profiler_builtins"
 version = "0.0.0"
 dependencies = [
  "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -1797,6 +1805,7 @@ dependencies = [
  "alloc_system 0.0.0",
  "build_helper 0.1.0",
  "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -1942,6 +1951,7 @@ dependencies = [
  "alloc_system 0.0.0",
  "build_helper 0.1.0",
  "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -1991,6 +2001,7 @@ dependencies = [
  "alloc_system 0.0.0",
  "build_helper 0.1.0",
  "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -2130,6 +2141,7 @@ dependencies = [
  "alloc_system 0.0.0",
  "build_helper 0.1.0",
  "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -2343,6 +2355,7 @@ dependencies = [
 name = "std_unicode"
 version = "0.0.0"
 dependencies = [
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
 ]
 
@@ -2725,6 +2738,7 @@ dependencies = [
 name = "unwind"
 version = "0.0.0"
 dependencies = [
+ "compiler_builtins 0.0.0",
  "core 0.0.0",
  "libc 0.0.0",
 ]
index 3bf919b0c0016e3c689b87146e5a0ba30c940f22..2eb8ea1260446a44cfd8fad1f09c91fdfe5ffcec 100644 (file)
@@ -10,6 +10,7 @@ path = "lib.rs"
 [dependencies]
 core = { path = "../libcore" }
 std_unicode = { path = "../libstd_unicode" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
 
 [dev-dependencies]
 rand = "0.4"
index 6d7d83dd99388aa10145a78c4b7b663dd38af802..fd4a45530463df9854455a883061962ba470e8b8 100644 (file)
@@ -16,6 +16,7 @@ alloc = { path = "../liballoc" }
 alloc_system = { path = "../liballoc_system" }
 core = { path = "../libcore" }
 libc = { path = "../rustc/libc_shim" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
 
 [build-dependencies]
 build_helper = { path = "../build_helper" }
index f9a57f7d97a74ea914602769708754e84958d9b4..936e20a32e10e9d064f55f22094052eaafc41455 100644 (file)
@@ -13,6 +13,7 @@ doc = false
 alloc = { path = "../liballoc" }
 core = { path = "../libcore" }
 libc = { path = "../rustc/libc_shim" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
 
 # See comments in the source for what this dependency is
 [target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
index e0eac41f49ec92b1ada6f8c0c027e811161fcd2a..633d273b3b93cd49834bd972a5dce5ab106a7ae1 100644 (file)
@@ -12,3 +12,4 @@ doc = false
 [dependencies]
 core = { path = "../libcore" }
 libc = { path = "../rustc/libc_shim" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index a978ea16e9e74245ecd355fe6dab581c6d005463..74aaa4d5ae3db6bf606fbcad57a1866324826fba 100644 (file)
@@ -14,3 +14,4 @@ alloc = { path = "../liballoc" }
 core = { path = "../libcore" }
 libc = { path = "../rustc/libc_shim" }
 unwind = { path = "../libunwind" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index 04f456917b95703b5eebe33a62e81baa864a36d7..79192fbb6819c4ba09f6822c6bf3515261e31fc3 100644 (file)
@@ -13,6 +13,7 @@ doc = false
 
 [dependencies]
 core = { path = "../libcore" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
 
 [build-dependencies]
 cc = "1.0.1"
index 8f8ef1cc4a0111165ced04bddc19f49a1078fe43..34d8b75a5bfb3476a1f587d33ad663f2d8498f37 100644 (file)
@@ -17,3 +17,4 @@ cmake = "0.1.18"
 alloc = { path = "../liballoc" }
 alloc_system = { path = "../liballoc_system" }
 core = { path = "../libcore" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index 087c3162119432a60af7000c58fd7c654dd11c09..9c19b53742654e4c760056a09d1233d25fad7851 100644 (file)
@@ -17,3 +17,4 @@ cmake = "0.1.18"
 alloc = { path = "../liballoc" }
 alloc_system = { path = "../liballoc_system" }
 core = { path = "../libcore" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index 8d7279b29eb552db3ac95907a5926334d7044e97..17ec2b96438ad02b97746e66de4a6d5a9c7021ad 100644 (file)
@@ -17,3 +17,4 @@ cmake = "0.1.18"
 alloc = { path = "../liballoc" }
 alloc_system = { path = "../liballoc_system" }
 core = { path = "../libcore" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index 7b83985ba673167370da3e40d6fb8dd6d9ba5e2f..8bb67c0bbac5f4e601154bf939c328550d71cba0 100644 (file)
@@ -17,3 +17,4 @@ cmake = "0.1.18"
 alloc = { path = "../liballoc" }
 alloc_system = { path = "../liballoc_system" }
 core = { path = "../libcore" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index 6f6abfdd31e57e81eab965d54199119e73742b7a..f9041ac8546b9db6820d19c5aee5a385e0e03a35 100644 (file)
 
 // compiler-rt intrinsics
 #[doc(masked)]
+#[cfg(stage0)]
 extern crate compiler_builtins;
 
 // During testing, this crate is not actually the "real" std library, but rather
index b3346dbe2fb1240ddd1033907e169134b2ad4442..283070a0e2cf7f42d9a54bd2a8a6a16a46cab8e2 100644 (file)
@@ -15,3 +15,4 @@ path = "tests/lib.rs"
 
 [dependencies]
 core = { path = "../libcore" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index 8d42206c5ccffa4c62c8c0f48ea123942aa5154f..8168db19058764f0585f148769062c1ffd917510 100644 (file)
@@ -94,7 +94,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
                        is_expanded: bool) -> io::Result<()> {
     let mut s = State::new_from_input(cm, sess, filename, input, out, ann, is_expanded);
 
-    if is_expanded && !std_inject::injected_crate_name().is_none() {
+    if is_expanded && std_inject::injected_crate_name().is_some() {
         // We need to print `#![no_std]` (and its feature gate) so that
         // compiling pretty-printed source won't inject libstd again.
         // However we don't want these attributes in the AST because
index 63d7b3336a861a9158d5c26aa3fa0f594a33a79a..bba7a2d73773646d5db9df809836d6645e811177 100644 (file)
@@ -44,27 +44,38 @@ pub fn injected_crate_name() -> Option<&'static str> {
 }
 
 pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<&str>) -> ast::Crate {
-    let name = if attr::contains_name(&krate.attrs, "no_core") {
+    // the first name in this list is the crate name of the crate with the prelude
+    let names: &[&str] = if attr::contains_name(&krate.attrs, "no_core") {
         return krate;
     } else if attr::contains_name(&krate.attrs, "no_std") {
-        "core"
+        if attr::contains_name(&krate.attrs, "compiler_builtins") {
+            &["core"]
+        } else {
+            &["core", "compiler_builtins"]
+        }
     } else {
-        "std"
+        &["std"]
     };
 
-    INJECTED_CRATE_NAME.with(|opt_name| opt_name.set(Some(name)));
+    for name in names {
+        krate.module.items.insert(0, P(ast::Item {
+            attrs: vec![attr::mk_attr_outer(DUMMY_SP,
+                                            attr::mk_attr_id(),
+                                            attr::mk_word_item(ast::Ident::from_str("macro_use")))],
+            vis: dummy_spanned(ast::VisibilityKind::Inherited),
+            node: ast::ItemKind::ExternCrate(alt_std_name.map(Symbol::intern)),
+            ident: ast::Ident::from_str(name),
+            id: ast::DUMMY_NODE_ID,
+            span: DUMMY_SP,
+            tokens: None,
+        }));
+    }
 
-    krate.module.items.insert(0, P(ast::Item {
-        attrs: vec![attr::mk_attr_outer(DUMMY_SP,
-                                        attr::mk_attr_id(),
-                                        attr::mk_word_item(ast::Ident::from_str("macro_use")))],
-        vis: dummy_spanned(ast::VisibilityKind::Inherited),
-        node: ast::ItemKind::ExternCrate(alt_std_name.map(Symbol::intern)),
-        ident: ast::Ident::from_str(name),
-        id: ast::DUMMY_NODE_ID,
-        span: DUMMY_SP,
-        tokens: None,
-    }));
+    // the crates have been injected, the assumption is that the first one is the one with
+    // the prelude.
+    let name = names[0];
+
+    INJECTED_CRATE_NAME.with(|opt_name| opt_name.set(Some(name)));
 
     let span = ignored_span(DUMMY_SP);
     krate.module.items.insert(0, P(ast::Item {
index fbd9789d2f52d16c98aa91319664b707cb9c2ad8..4760461df64e3895e73561fccd66785dedc6ff92 100644 (file)
@@ -14,3 +14,4 @@ doc = false
 [dependencies]
 core = { path = "../libcore" }
 libc = { path = "../rustc/libc_shim" }
+compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
index cf8440c40da1aaa8736f3467b950895abdec649c..d2fe159d80673d54dbdb48a6fd0affacfc3665d4 100644 (file)
@@ -11,4 +11,5 @@ doc = false
 
 [dependencies]
 core = { path = "../../libcore" }
+compiler_builtins = { path = "../../rustc/compiler_builtins_shim" }
 alloc = { path = "../../liballoc" }
index 0c04402124a2de290c13d4c2f3b47c9083da6ea7..e77897d6433136603451492472ebd6834a1fd561 100644 (file)
@@ -29,6 +29,8 @@ doc = false
 #
 # See https://github.com/rust-lang/rfcs/pull/1133.
 core = { path = "../../libcore" }
+compiler_builtins = { path = "../compiler_builtins_shim" }
+
 
 [features]
 # Certain parts of libc are conditionally compiled differently than when used