std: Depend directly on crates.io crates

Ever since we added a Cargo-based build system for the compiler the
standard library has always been a little special, it's never been able
to depend on crates.io crates for runtime dependencies. This has been a
result of various limitations, namely that Cargo doesn't understand that
crates from crates.io depend on libcore, so Cargo tries to build crates
before libcore is finished.

I had an idea this afternoon, however, which lifts the strategy
from #52919 to directly depend on crates.io crates from the standard
library. After all is said and done this removes a whopping three
submodules that we need to manage!

The basic idea here is that for any crate `std` depends on it adds an
*optional* dependency on an empty crate on crates.io, in this case named
`rustc-std-workspace-core`. This crate is overridden via `[patch]` in
this repository to point to a local crate we write, and *that* has a
`path` dependency on libcore.

Note that all `no_std` crates also depend on `compiler_builtins`, but if
we're not using submodules we can publish `compiler_builtins` to
crates.io and all crates can depend on it anyway! The basic strategy
then looks like:

* The standard library (or some transitive dep) decides to depend on a
  crate `foo`.
* The standard library adds

  ```toml
  [dependencies]
  foo = { version = "0.1", features = ['rustc-dep-of-std'] }
  ```
* The crate `foo` has an optional dependency on `rustc-std-workspace-core`
* The crate `foo` has an optional dependency on `compiler_builtins`
* The crate `foo` has a feature `rustc-dep-of-std` which activates these
  crates and any other necessary infrastructure in the crate.

A sample commit for `dlmalloc` [turns out to be quite simple][commit].
After that all `no_std` crates should largely build "as is" and still be
publishable on crates.io! Notably they should be able to continue to use
stable Rust if necessary, since the `rename-dependency` feature of Cargo
is soon stabilizing.

As a proof of concept, this commit removes the `dlmalloc`,
`libcompiler_builtins`, and `libc` submodules from this repository. Long
thorns in our side these are now gone for good and we can directly
depend on crates.io! It's hoped that in the long term we can bring in
other crates as necessary, but for now this is largely intended to
simply make it easier to manage these crates and remove submodules.

This should be a transparent non-breaking change for all users, but one
possible stickler is that this almost for sure breaks out-of-tree
`std`-building tools like `xargo` and `cargo-xbuild`. I think it should
be relatively easy to get them working, however, as all that's needed is
an entry in the `[patch]` section used to build the standard library.
Hopefully we can work with these tools to solve this problem!

[commit]: 28ee12db81
This commit is contained in:
Alex Crichton 2018-11-19 21:52:50 -08:00
parent 4c0116e13f
commit 4c21a3bc2a
99 changed files with 231 additions and 314 deletions

12
.gitmodules vendored
View File

@ -5,9 +5,6 @@
[submodule "src/rust-installer"]
path = src/tools/rust-installer
url = https://github.com/rust-lang/rust-installer.git
[submodule "src/liblibc"]
path = src/liblibc
url = https://github.com/rust-lang/libc.git
[submodule "src/doc/nomicon"]
path = src/doc/nomicon
url = https://github.com/rust-lang-nursery/nomicon.git
@ -23,9 +20,6 @@
[submodule "src/tools/rls"]
path = src/tools/rls
url = https://github.com/rust-lang-nursery/rls.git
[submodule "src/libcompiler_builtins"]
path = src/libcompiler_builtins
url = https://github.com/rust-lang-nursery/compiler-builtins.git
[submodule "src/tools/clippy"]
path = src/tools/clippy
url = https://github.com/rust-lang-nursery/rust-clippy.git
@ -35,9 +29,6 @@
[submodule "src/tools/miri"]
path = src/tools/miri
url = https://github.com/solson/miri.git
[submodule "src/dlmalloc"]
path = src/dlmalloc
url = https://github.com/alexcrichton/dlmalloc-rs.git
[submodule "src/doc/rust-by-example"]
path = src/doc/rust-by-example
url = https://github.com/rust-lang/rust-by-example.git
@ -67,6 +58,3 @@
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide
[submodule "src/rust-sgx"]
path = src/rust-sgx
url = https://github.com/fortanix/rust-sgx

View File

@ -15,9 +15,9 @@ dependencies = [
name = "alloc"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -407,10 +407,11 @@ dependencies = [
[[package]]
name = "compiler_builtins"
version = "0.0.0"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"rustc-std-workspace-core 1.0.0",
]
[[package]]
@ -456,7 +457,7 @@ dependencies = [
name = "core"
version = "0.0.0"
dependencies = [
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -658,10 +659,12 @@ dependencies = [
[[package]]
name = "dlmalloc"
version = "0.0.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.0.0",
"core 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]
[[package]]
@ -814,10 +817,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fortanix-sgx-abi"
version = "0.0.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.0.0",
"core 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]
[[package]]
@ -1138,18 +1142,13 @@ name = "lazycell"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.0.0",
"core 0.0.0",
]
[[package]]
name = "libc"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc-std-workspace-core 1.0.0",
]
[[package]]
name = "libgit2-sys"
@ -1520,9 +1519,9 @@ dependencies = [
name = "panic_abort"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.0.0",
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1530,9 +1529,9 @@ name = "panic_unwind"
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.0.0",
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"unwind 0.0.0",
]
@ -1683,7 +1682,7 @@ name = "profiler_builtins"
version = "0.0.0"
dependencies = [
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -1814,7 +1813,7 @@ name = "rand_chacha"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1836,7 +1835,7 @@ name = "rand_hc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1861,7 +1860,7 @@ name = "rand_xorshift"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2242,6 +2241,13 @@ name = "rustc-serialize"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-std-workspace-core"
version = "1.0.0"
dependencies = [
"core 0.0.0",
]
[[package]]
name = "rustc-workspace-hack"
version = "1.0.0"
@ -2284,7 +2290,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -2479,7 +2485,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -2531,7 +2537,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -2644,7 +2650,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]
@ -2877,15 +2883,15 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"dlmalloc 0.0.0",
"fortanix-sgx-abi 0.0.0",
"libc 0.0.0",
"dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
"panic_abort 0.0.0",
"panic_unwind 0.0.0",
"profiler_builtins 0.0.0",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_asan 0.0.0",
"rustc_lsan 0.0.0",
"rustc_msan 0.0.0",
@ -3217,9 +3223,9 @@ dependencies = [
name = "unwind"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.0.0",
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.0.0",
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3397,6 +3403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
"checksum compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad611263b9f31bdb66e66227d3b781600fd1e68d5deee29b23f5e2ac9cb4892"
"checksum compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "89747fe073b7838343bd2c2445e7a7c2e0d415598f8925f0fa9205b9cdfc48cb"
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
@ -3418,6 +3425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f"
"checksum dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c46c65de42b063004b31c67a98abe071089b289ff0919c660ed7ff4f59317f8"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elasticlunr-rs 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a99a310cd1f9770e7bf8e48810c7bcbb0e078c8fb23a8c7bcf0da4c2bf61a455"
"checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"
@ -3434,6 +3442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
"checksum fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "26105e20b4c3f7a319db1376b54ac9a46e5761e949405553375095d05a0cee4d"
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"

View File

@ -65,6 +65,10 @@ rustfmt-nightly = { path = "src/tools/rustfmt" }
# here
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
# See comments in `tools/rustc-std-workspace-core/README.md` for what's going on
# here
rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
[patch."https://github.com/rust-lang/rust-clippy"]
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
rustc_tools_util = { path = "src/tools/clippy/rustc_tools_util" }

View File

@ -152,11 +152,10 @@ pub fn std_cargo(builder: &Builder,
if builder.no_std(target) == Some(true) {
// for no-std targets we only compile a few no_std crates
cargo.arg("--features").arg("c mem")
cargo
.args(&["-p", "alloc"])
.args(&["-p", "compiler_builtins"])
.arg("--manifest-path")
.arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
.arg(builder.src.join("src/liballoc/Cargo.toml"));
} else {
let features = builder.std_features();

View File

@ -857,12 +857,9 @@ impl Step for Src {
// (essentially libstd and all of its path dependencies)
let std_src_dirs = [
"src/build_helper",
"src/dlmalloc",
"src/liballoc",
"src/libbacktrace",
"src/libcompiler_builtins",
"src/libcore",
"src/liblibc",
"src/libpanic_abort",
"src/libpanic_unwind",
"src/librustc_asan",
@ -871,21 +868,15 @@ impl Step for Src {
"src/librustc_tsan",
"src/libstd",
"src/libunwind",
"src/rustc/compiler_builtins_shim",
"src/rustc/libc_shim",
"src/rustc/dlmalloc_shim",
"src/rustc/fortanix-sgx-abi_shim",
"src/libtest",
"src/libterm",
"src/libprofiler_builtins",
"src/stdsimd",
"src/libproc_macro",
];
let std_src_dirs_exclude = [
"src/libcompiler_builtins/compiler-rt/test",
"src/tools/rustc-std-workspace-core",
];
copy_src_dirs(builder, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);
copy_src_dirs(builder, &std_src_dirs[..], &[], &dst_src);
for file in src_files.iter() {
builder.copy(&builder.src.join(file), &dst_src.join(file));
}
@ -909,7 +900,7 @@ impl Step for Src {
}
}
const CARGO_VENDOR_VERSION: &str = "0.1.19";
const CARGO_VENDOR_VERSION: &str = "0.1.22";
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct PlainSourceTarball;

View File

@ -1134,10 +1134,10 @@ impl Build {
let krate = &self.crates[&krate];
if krate.is_local(self) {
ret.push(krate);
for dep in &krate.deps {
if visited.insert(dep) && dep != "build_helper" {
list.push(*dep);
}
}
for dep in &krate.deps {
if visited.insert(dep) && dep != "build_helper" {
list.push(*dep);
}
}
}

View File

@ -1558,10 +1558,7 @@ impl Step for Crate {
let builder = run.builder;
run = run.krate("test");
for krate in run.builder.in_tree_crates("std") {
if krate.is_local(&run.builder)
&& !(krate.name.starts_with("rustc_") && krate.name.ends_with("san"))
&& krate.name != "dlmalloc"
{
if !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) {
run = run.path(krate.local_path(&builder).to_str().unwrap());
}
}

View File

@ -224,14 +224,12 @@ impl Drop for NativeLibBoilerplate {
// Timestamps are created automatically when the result of `native_lib_boilerplate` goes out
// of scope, so all the build actions should be completed until then.
pub fn native_lib_boilerplate(
src_name: &str,
src_dir: &Path,
out_name: &str,
link_name: &str,
search_subdir: &str,
) -> Result<NativeLibBoilerplate, ()> {
let current_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let src_dir = current_dir.join("..").join(src_name);
rerun_if_changed_anything_in_dir(&src_dir);
rerun_if_changed_anything_in_dir(src_dir);
let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or_else(||
env::var_os("OUT_DIR").unwrap());
@ -248,9 +246,9 @@ pub fn native_lib_boilerplate(
);
let timestamp = out_dir.join("rustbuild.timestamp");
if !up_to_date(Path::new("build.rs"), &timestamp) || !up_to_date(&src_dir, &timestamp) {
if !up_to_date(Path::new("build.rs"), &timestamp) || !up_to_date(src_dir, &timestamp) {
Ok(NativeLibBoilerplate {
src_dir: src_dir,
src_dir: src_dir.to_path_buf(),
out_dir: out_dir,
})
} else {
@ -279,8 +277,11 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str)
} else {
format!("static={}", link_name)
};
// The source for `compiler-rt` comes from the `compiler-builtins` crate, so
// load our env var set by cargo to find the source code.
let dir = env::var_os("DEP_COMPILER_RT_COMPILER_RT").unwrap();
let lib = native_lib_boilerplate(
"libcompiler_builtins/compiler-rt",
dir.as_ref(),
sanitizer_name,
&to_link,
search_path,

@ -1 +0,0 @@
Subproject commit de99f4b0c886f5916cd1a146464276d65bef61b8

View File

@ -11,10 +11,10 @@ path = "lib.rs"
[dependencies]
core = { path = "../libcore" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
[dev-dependencies]
rand = "0.5"
rand = "0.6"
[[test]]
name = "collectionstests"

View File

@ -14,7 +14,7 @@ use std::collections::binary_heap::{Drain, PeekMut};
use std::panic::{self, AssertUnwindSafe};
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use rand::{thread_rng, Rng};
use rand::{thread_rng, seq::SliceRandom};
#[test]
fn test_iterator() {
@ -332,7 +332,7 @@ fn panic_safe() {
let panic_item = PanicOrd(i, true);
// heapify the sane items
rng.shuffle(&mut panic_ords);
panic_ords.shuffle(&mut rng);
let mut heap = BinaryHeap::from(panic_ords);
let inner_data;

View File

@ -18,7 +18,7 @@ use std::sync::atomic::Ordering::Relaxed;
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize};
use std::thread;
use rand::{Rng, RngCore, thread_rng};
use rand::{Rng, RngCore, thread_rng, seq::SliceRandom};
use rand::distributions::Standard;
fn square(n: usize) -> usize {
@ -459,7 +459,7 @@ fn test_sort() {
for i in 0..v.len() {
v[i] = i as i32;
}
v.sort_by(|_, _| *rng.choose(&[Less, Equal, Greater]).unwrap());
v.sort_by(|_, _| *[Less, Equal, Greater].choose(&mut rng).unwrap());
v.sort();
for i in 0..v.len() {
assert_eq!(v[i], i as i32);

@ -1 +0,0 @@
Subproject commit 10f4f35f9670bb29715a8c1ec01284852d47ed35

View File

@ -20,7 +20,7 @@ name = "corebenches"
path = "../libcore/benches/lib.rs"
[dev-dependencies]
rand = "0.5"
rand = "0.6"
[features]
# Make panics and failed asserts immediately abort without formatting any message

View File

@ -18,7 +18,8 @@ use core::num::flt2dec::strategy::grisu::format_exact_opt;
use core::num::flt2dec::strategy::grisu::format_shortest_opt;
use core::num::flt2dec::{decode, DecodableFloat, FullDecoded, Decoded};
use rand::{FromEntropy, XorShiftRng};
use rand::FromEntropy;
use rand::rngs::SmallRng;
use rand::distributions::{Distribution, Uniform};
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
@ -71,7 +72,10 @@ fn iterate<F, G, V>(func: &str, k: usize, n: usize, mut f: F, mut g: G, mut v: V
pub fn f32_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
where F: FnMut(&Decoded, &mut [u8]) -> Option<(usize, i16)>,
G: FnMut(&Decoded, &mut [u8]) -> (usize, i16) {
let mut rng = XorShiftRng::from_entropy();
if cfg!(target_os = "emscripten") {
return // using rng pulls in i128 support, which doesn't work
}
let mut rng = SmallRng::from_entropy();
let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000);
iterate("f32_random_equivalence_test", k, n, f, g, |_| {
let x = f32::from_bits(f32_range.sample(&mut rng));
@ -82,7 +86,10 @@ pub fn f32_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
pub fn f64_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
where F: FnMut(&Decoded, &mut [u8]) -> Option<(usize, i16)>,
G: FnMut(&Decoded, &mut [u8]) -> (usize, i16) {
let mut rng = XorShiftRng::from_entropy();
if cfg!(target_os = "emscripten") {
return // using rng pulls in i128 support, which doesn't work
}
let mut rng = SmallRng::from_entropy();
let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000);
iterate("f64_random_equivalence_test", k, n, f, g, |_| {
let x = f64::from_bits(f64_range.sample(&mut rng));

View File

@ -1024,11 +1024,11 @@ fn test_rotate_right() {
fn sort_unstable() {
use core::cmp::Ordering::{Equal, Greater, Less};
use core::slice::heapsort;
use rand::{FromEntropy, Rng, XorShiftRng};
use rand::{FromEntropy, Rng, rngs::SmallRng, seq::SliceRandom};
let mut v = [0; 600];
let mut tmp = [0; 600];
let mut rng = XorShiftRng::from_entropy();
let mut rng = SmallRng::from_entropy();
for len in (2..25).chain(500..510) {
let v = &mut v[0..len];
@ -1073,7 +1073,7 @@ fn sort_unstable() {
for i in 0..v.len() {
v[i] = i as i32;
}
v.sort_unstable_by(|_, _| *rng.choose(&[Less, Equal, Greater]).unwrap());
v.sort_unstable_by(|_, _| *[Less, Equal, Greater].choose(&mut rng).unwrap());
v.sort_unstable();
for i in 0..v.len() {
assert_eq!(v[i], i as i32);

@ -1 +0,0 @@
Subproject commit 5b403753da9ec8ff501adf34cb6d63b319b4a3ae

View File

@ -11,5 +11,5 @@ doc = false
[dependencies]
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
libc = { version = "0.2", default-features = false }
compiler_builtins = "0.1.0"

View File

@ -12,6 +12,6 @@ doc = false
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
libc = { version = "0.2", default-features = false }
unwind = { path = "../libunwind" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = "0.1.0"

View File

@ -13,7 +13,7 @@ doc = false
[dependencies]
core = { path = "../libcore" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
[build-dependencies]
cc = "1.0.1"

View File

@ -56,9 +56,15 @@ fn main() {
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
}
// The source for `compiler-rt` comes from the `compiler-builtins` crate, so
// load our env var set by cargo to find the source code.
let root = env::var_os("DEP_COMPILER_RT_COMPILER_RT").unwrap();
let root = Path::new(&root);
for src in profile_sources {
cfg.file(Path::new("../libcompiler_builtins/compiler-rt/lib/profile").join(src));
cfg.file(root.join("lib").join("profile").join(src));
}
cfg.warnings(false);
cfg.compile("profiler-rt");
}

View File

@ -16,4 +16,4 @@ cmake = "0.1.18"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = "0.1.0"

View File

@ -16,4 +16,4 @@ cmake = "0.1.18"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = "0.1.0"

View File

@ -16,4 +16,4 @@ cmake = "0.1.18"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = "0.1.0"

View File

@ -295,9 +295,8 @@ that has been imported into the current module.
Erroneous code example:
```compile_fail,E0259
# #![feature(libc)]
extern crate core;
extern crate libc as core;
extern crate std as core;
fn main() {}
```
@ -308,9 +307,8 @@ external crate imported into the current module.
Correct example:
```
# #![feature(libc)]
extern crate core;
extern crate libc as other_name;
extern crate std as other_name;
fn main() {}
```

View File

@ -16,4 +16,4 @@ cmake = "0.1.18"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
compiler_builtins = "0.1.0"

View File

@ -17,13 +17,13 @@ alloc = { path = "../liballoc" }
panic_unwind = { path = "../libpanic_unwind", optional = true }
panic_abort = { path = "../libpanic_abort" }
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
libc = { version = "0.2.44", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.1" }
profiler_builtins = { path = "../libprofiler_builtins", optional = true }
unwind = { path = "../libunwind" }
[dev-dependencies]
rand = "0.5"
rand = "0.6.1"
[target.x86_64-apple-darwin.dependencies]
rustc_asan = { path = "../librustc_asan" }
@ -36,10 +36,10 @@ rustc_msan = { path = "../librustc_msan" }
rustc_tsan = { path = "../librustc_tsan" }
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))'.dependencies]
dlmalloc = { path = '../rustc/dlmalloc_shim' }
dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
[target.x86_64-fortanix-unknown-sgx.dependencies]
fortanix-sgx-abi = { path = "../rustc/fortanix-sgx-abi_shim" }
fortanix-sgx-abi = { version = "0.3.1", features = ['rustc-dep-of-std'] }
[build-dependencies]
cc = "1.0"

View File

@ -82,7 +82,12 @@ fn main() {
}
fn build_libbacktrace(target: &str) -> Result<(), ()> {
let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", "")?;
let native = native_lib_boilerplate(
"../libbacktrace".as_ref(),
"libbacktrace",
"backtrace",
"",
)?;
let mut build = cc::Build::new();
build

View File

@ -2089,7 +2089,7 @@ mod tests {
use fs::{self, File, OpenOptions};
use io::{ErrorKind, SeekFrom};
use path::Path;
use rand::{StdRng, FromEntropy, RngCore};
use rand::{rngs::StdRng, FromEntropy, RngCore};
use str;
use sys_common::io::test::{TempDir, tmpdir};
use thread;

View File

@ -426,7 +426,7 @@ mod prim_unit { }
/// ## 3. Get it from C.
///
/// ```
/// # #![feature(libc)]
/// # #![feature(rustc_private)]
/// extern crate libc;
///
/// use std::mem;

View File

@ -348,7 +348,7 @@ pub trait OpenOptionsExt {
/// # Examples
///
/// ```no_run
/// # #![feature(libc)]
/// # #![feature(rustc_private)]
/// extern crate libc;
/// use std::fs::OpenOptions;
/// use std::os::unix::fs::OpenOptionsExt;

View File

@ -13,5 +13,5 @@ doc = false
[dependencies]
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
libc = { version = "0.2.43", features = ['rustc-dep-of-std'], default-features = false }
compiler_builtins = "0.1.0"

@ -1 +0,0 @@
Subproject commit 9656260888095f44830641ca7bb3da609a793451

View File

@ -1,40 +0,0 @@
[package]
name = "compiler_builtins"
authors = ["The Rust Project Developers"]
version = "0.0.0"
build = "../../libcompiler_builtins/build.rs"
[lib]
path = "../../libcompiler_builtins/src/lib.rs"
test = false
doctest = false
[dependencies]
# Specify the path to libcore; at the time of writing, removing this shim in
# favor of using compiler-builtins from git results in a compilation failure:
#
# Building stage0 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
# Compiling compiler_builtins v0.1.0 (https://github.com/rust-lang-nursery/compiler-builtins.git#23f14d3f)
# error[E0463]: can't find crate for `core`
#
# error: aborting due to previous error
#
# error: Could not compile `compiler_builtins`.
#
# Caused by:
# process didn't exit successfully: `/Users/tamird/src/rust/build/bootstrap/debug/rustc --crate-name compiler_builtins /Users/tamird/.cargo/git/checkouts/compiler-builtins-ec094dc45a0179c8/23f14d3/src/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C opt-level=2 --cfg feature="c" --cfg feature="compiler-builtins" --cfg feature="default" --cfg feature="gcc" -C metadata=876d429e8d7eae1f -C extra-filename=-876d429e8d7eae1f --out-dir /Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/release/deps --cap-lints allow -L native=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/build/compiler_builtins-f18fab55928102ad/out -l static=compiler-rt` (exit code: 101)
# thread 'main' panicked at 'command did not execute successfully: "/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-apple-darwin" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/Users/tamird/src/rust/src/libstd/Cargo.toml" "--message-format" "json"
# expected success, got: exit code: 101', src/bootstrap/compile.rs:883:8
#
# See https://github.com/rust-lang/rfcs/pull/1133.
core = { path = "../../libcore" }
[build-dependencies]
cc = "1.0.1"
[features]
c = []
default = ["rustbuild", "compiler-builtins"]
mem = []
rustbuild = []
compiler-builtins = []

View File

@ -1,15 +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.
// This file is left intentionally empty (and not removed) to avoid an issue
// where this crate is always considered dirty due to compiler-builtins'
// `cargo:rerun-if-changed=build.rs` directive; since the path is relative, it
// refers to this file when this shim crate is being built, and the absence of
// this file is considered by cargo to be equivalent to it having changed.

View File

@ -1,14 +0,0 @@
[package]
name = "dlmalloc"
version = "0.0.0"
authors = ["The Rust Project Developers"]
[lib]
path = "../../dlmalloc/src/lib.rs"
test = false
bench = false
doc = false
[dependencies]
core = { path = "../../libcore" }
compiler_builtins = { path = "../../rustc/compiler_builtins_shim" }

View File

@ -1,14 +0,0 @@
[package]
name = "fortanix-sgx-abi"
version = "0.0.0"
authors = ["The Rust Project Developers"]
[lib]
path = "../../rust-sgx/fortanix-sgx-abi/src/lib.rs"
test = false
bench = false
doc = false
[dependencies]
core = { path = "../../libcore" }
compiler_builtins = { path = "../../rustc/compiler_builtins_shim" }

View File

@ -1,40 +0,0 @@
[package]
name = "libc"
version = "0.0.0"
authors = ["The Rust Project Developers"]
[lib]
name = "libc"
path = "../../liblibc/src/lib.rs"
test = false
bench = false
doc = false
[dependencies]
# Specify the path to libcore; at the time of writing, removing this shim in
# favor of using libc from git results in a compilation failure:
#
# Building stage0 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
# Compiling libc v0.0.0 (file:///Users/tamird/src/rust/src/rustc/libc_shim)
# error[E0463]: can't find crate for `core`
#
# error: aborting due to previous error
#
# error: Could not compile `libc`.
#
# Caused by:
# process didn't exit successfully: `/Users/tamird/src/rust/build/bootstrap/debug/rustc --crate-name libc src/rustc/libc_shim/../../liblibc/src/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C opt-level=2 --cfg feature="default" --cfg feature="no_std" --cfg feature="stdbuild" -C metadata=d758f87058112d7d -C extra-filename=-d758f87058112d7d --out-dir /Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/release/deps` (exit code: 101)
# thread 'main' panicked at 'command did not execute successfully: "/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-apple-darwin" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/Users/tamird/src/rust/src/libstd/Cargo.toml" "--message-format" "json"
# expected success, got: exit code: 101', src/bootstrap/compile.rs:883:8
#
# 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
# outside rustc. See https://github.com/rust-lang/libc/search?l=Rust&q=stdbuild&type=&utf8=%E2%9C%93.
stdbuild = []
default = ["stdbuild", "align"]
align = []

View File

@ -12,7 +12,7 @@
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
# `0.x.0` for Cargo where they were released on `date`.
date: 2018-10-30
date: 2018-11-21
rustc: beta
cargo: beta

View File

@ -13,7 +13,7 @@
// revisions: rpass1
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -10,7 +10,7 @@
#![crate_type = "staticlib"]
#![feature(c_variadic)]
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -8,14 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
extern crate libc;
#[link(name = "test", kind = "static")]
extern {
fn slice_len(s: &[u8]) -> libc::size_t;
fn slice_elem(s: &[u8], idx: libc::size_t) -> u8;
fn slice_len(s: &[u8]) -> usize;
fn slice_elem(s: &[u8], idx: usize) -> u8;
}
fn main() {

View File

@ -7,7 +7,7 @@
// <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.
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
fn main(){}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// no-prefer-dynamic
// pretty-expanded FIXME #23616
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -12,7 +12,7 @@
// ignore-emscripten no no_std executables
#![feature(lang_items, start, libc, alloc)]
#![feature(lang_items, start, rustc_private, alloc)]
#![no_std]
extern crate std as other;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_name="anonexternmod"]
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -10,7 +10,7 @@
// Helper definition for test/run-pass/check-static-recursion-foreign.rs.
#![feature(libc)]
#![feature(rustc_private)]
#![crate_name = "check_static_recursion_foreign_helper"]
#![crate_type = "lib"]

View File

@ -10,7 +10,7 @@
#![crate_name="foreign_lib"]
#![feature(libc)]
#![feature(rustc_private)]
pub mod rustrt {
extern crate libc;

View File

@ -11,7 +11,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
mod rustrt {
extern crate libc;

View File

@ -10,7 +10,7 @@
// ignore-wasm32-bare no libc to test with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -16,7 +16,7 @@
// pretty-expanded FIXME #23616
#![feature(custom_attribute, libc)]
#![feature(custom_attribute, rustc_private)]
extern crate check_static_recursion_foreign_helper;
extern crate libc;

View File

@ -13,7 +13,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
#![feature(process_exec, libc)]
#![feature(process_exec, rustc_private)]
extern crate libc;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_name="anonexternmod"]
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -20,7 +20,7 @@
// memory, which makes for some *confusing* logs. That's why these are here
// instead of in std.
#![feature(libc, duration)]
#![feature(rustc_private, duration)]
extern crate libc;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_name="anonexternmod"]
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -16,7 +16,7 @@
// ignore-emscripten no execve
// no-prefer-dynamic
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -15,7 +15,7 @@
// issue-53200
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
use std::env;

View File

@ -10,7 +10,7 @@
#![crate_name="externcallback"]
#![crate_type = "lib"]
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -12,7 +12,7 @@
#![allow(unused_must_use)]
// ignore-emscripten no threads support
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
use std::thread;

View File

@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -16,7 +16,7 @@
// ignore-emscripten no threads support
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
use std::thread;

View File

@ -12,7 +12,7 @@
// aux-build:extern-crosscrate-source.rs
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate externcallback;
extern crate libc;

View File

@ -14,7 +14,7 @@
// ignore-emscripten no processes
// ignore-haiku
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -10,7 +10,7 @@
#![crate_name="foreign_lib"]
#![feature(libc)]
#![feature(rustc_private)]
pub mod rustrt {
extern crate libc;

View File

@ -11,7 +11,7 @@
// run-pass
// ignore-emscripten no threads support
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
use std::ffi::CString;

View File

@ -14,7 +14,7 @@
// ignore-wasm32-bare no libc to test ffi with
// pretty-expanded FIXME #23616
#![feature(libc)]
#![feature(rustc_private)]
mod rustrt {
extern crate libc;

View File

@ -13,7 +13,7 @@
// ignore-wasm32-bare no libc to test ffi with
// pretty-expanded FIXME #23616
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -15,7 +15,7 @@
// compile-flags: -C debug_assertions=yes
#![stable(feature = "rustc", since = "1.0.0")]
#![feature(const_fn, libc, staged_api, rustc_attrs)]
#![feature(const_fn, rustc_private, staged_api, rustc_attrs)]
#![allow(const_err)]
extern crate libc;

View File

@ -9,7 +9,7 @@
// except according to those terms.
// run-pass
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// run-pass
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -18,7 +18,7 @@
// where the descriptors to inherit were already stdio descriptors.
// This test checks to avoid that regression.
#![cfg_attr(unix, feature(libc))]
#![cfg_attr(unix, feature(rustc_private))]
#![cfg_attr(windows, allow(unused_imports))]
#[cfg(unix)]

View File

@ -19,7 +19,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
use libc::{c_uint, uint32_t, c_void};

View File

@ -12,7 +12,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -16,7 +16,7 @@
// ignore-emscripten no processes
#![feature(asm)]
#![feature(libc)]
#![feature(rustc_private)]
#[cfg(unix)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// run-pass
#![allow(dead_code)]
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -13,7 +13,7 @@
// ignore-cloudabi stdout does not map to file descriptor 1 by default
// ignore-wasm32-bare no libc
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -12,7 +12,7 @@
// ignore-cloudabi can't run commands
// ignore-emscripten can't run commands
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -16,7 +16,7 @@
// ignore-wasm32-bare no libc
// ignore-windows
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
use libc::*;

View File

@ -15,7 +15,7 @@
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(alloc, libc)]
#![feature(alloc, rustc_private)]
#![allow(unused_extern_crates)]
extern crate alloc;

View File

@ -7,7 +7,7 @@
// run-rustfix
// ignore-wasm32 no external library to link to.
// compile-flags: -g -Z continue-parse-after-error
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]

View File

@ -7,7 +7,7 @@
// run-rustfix
// ignore-wasm32 no external library to link to.
// compile-flags: -g -Z continue-parse-after-error
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]

View File

@ -14,7 +14,7 @@
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
#![crate_id="rust_get_test_int"]

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -4,13 +4,13 @@ error[E0432]: unresolved import `libc`
LL | use libc::*; //~ ERROR unresolved import
| ^^^^ maybe a missing `extern crate libc;`?
error[E0658]: use of unstable library feature 'libc': use `libc` from crates.io (see issue #27783)
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? (see issue #27812)
--> $DIR/issue-37887.rs:12:5
|
LL | extern crate libc; //~ ERROR use of unstable
| ^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(libc)] to the crate attributes to enable
= help: add #![feature(rustc_private)] to the crate attributes to enable
error: aborting due to 2 previous errors

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![deny(improper_ctypes)]
#![feature(libc)]
#![feature(rustc_private)]
#![allow(private_in_public)]

View File

@ -10,7 +10,7 @@
// ignore-wasm32-bare no libc to test ffi with
#![feature(libc)]
#![feature(rustc_private)]
extern crate libc;

View File

@ -11,7 +11,7 @@
// edition:2018
#![deny(unused_extern_crates)]
#![feature(alloc, test, libc, crate_visibility_modifier)]
#![feature(alloc, test, rustc_private, crate_visibility_modifier)]
extern crate libc;
//~^ ERROR unused extern crate

View File

@ -0,0 +1,14 @@
[package]
name = "rustc-std-workspace-core"
version = "1.0.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = 'MIT/Apache-2.0'
description = """
Hack for the compiler's own build system
"""
[lib]
path = "lib.rs"
[dependencies]
core = { path = "../../libcore" }

View File

@ -0,0 +1,29 @@
# The `rustc-std-workspace-core` crate
This crate is a shim and empty crate which simply depends on `libcore` and
reexports all of its contents. The crate is the crux of empowering the standard
library to depend on crates from crates.io
Crates on crates.io that the standard library depend on the
`rustc-std-workspace-core` crate from crates.io. On crates.io, however, this
crate is empty. We use `[patch]` to override it to this crate in this
repository. As a result, crates on crates.io will draw a dependency edge to
`libcore`, the version defined in this repository. That should draw all the
dependency edges to ensure Cargo builds crates successfully!
Note that crates on crates.io need to depend on this crate with the name `core`
for everything to work correctly. To do that they can use:
```toml
core = { version = "1.0.0", optional = true, package = 'rustc-std-workspace-core' }
```
Through the use of the `package` key the crate is renamed to `core`, meaning
it'll look like
```
--extern core=.../librustc_std_workspace_core-XXXXXXX.rlib
```
when Cargo invokes the compiler, satisfying the implicit `extern crate core`
directive injected by the compiler.

View File

@ -0,0 +1,6 @@
#![feature(no_core)]
#![no_core]
extern crate core;
pub use core::*;

View File

@ -53,6 +53,7 @@ const EXCEPTIONS: &[&str] = &[
"bytesize", // Apache-2.0, cargo
"im-rc", // MPL-2.0+, cargo
"adler32", // BSD-3-Clause AND Zlib, cargo dep that isn't used
"fortanix-sgx-abi", // MPL-2.0+, libstd but only for sgx target
];
/// Which crates to check against the whitelist?

View File

@ -56,15 +56,11 @@ pub mod libcoretest;
fn filter_dirs(path: &Path) -> bool {
let skip = [
"src/dlmalloc",
"src/llvm",
"src/llvm-emscripten",
"src/libbacktrace",
"src/libcompiler_builtins",
"src/librustc_data_structures/owning_ref",
"src/compiler-rt",
"src/liblibc",
"src/rt/hoedown",
"src/vendor",
"src/tools/cargo",
"src/tools/clang",
"src/tools/rls",

View File

@ -26,7 +26,6 @@
//! exceptions:
//!
//! - core may not have platform-specific code
//! - libcompiler_builtins may have platform-specific code
//! - libpanic_abort may have platform-specific code
//! - libpanic_unwind may have platform-specific code
//! - libunwind may have platform-specific code
@ -50,8 +49,6 @@ use std::iter::Iterator;
// Paths that may contain platform-specific code
const EXCEPTION_PATHS: &[&str] = &[
// std crates
"src/libcompiler_builtins",
"src/liblibc",
"src/libpanic_abort",
"src/libpanic_unwind",
"src/libunwind",