Skip to content

Commit 56714ac

Browse files
committed
Auto merge of #49684 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests Successful merges: - #48658 (Add a generic CAS loop to std::sync::Atomic*) - #49253 (Take the original extra-filename passed to a crate into account when resolving it as a dependency) - #49345 (RFC 2008: Finishing Touches) - #49432 (Flush executables to disk after linkage) - #49496 (Add more vec![... ; n] optimizations) - #49563 (add a dist builder to build rust-std components for the THUMB targets) - #49654 (Host compiler documentation: Include private items) - #49667 (Add more features to rust_2018_preview) - #49674 (ci: Remove x86_64-gnu-incremental builder) Failed merges:
2 parents 01d0be9 + f4511e2 commit 56714ac

File tree

35 files changed

+567
-121
lines changed

35 files changed

+567
-121
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ matrix:
171171
if: branch = auto
172172
- env: IMAGE=x86_64-gnu-distcheck
173173
if: branch = auto
174-
- env: IMAGE=x86_64-gnu-incremental
175-
if: branch = auto
176174

177175
- stage: publish toolstate
178176
if: branch = master AND type = push

src/bootstrap/compile.rs

+44-34
Original file line numberDiff line numberDiff line change
@@ -140,48 +140,58 @@ pub fn std_cargo(build: &Builder,
140140
compiler: &Compiler,
141141
target: Interned<String>,
142142
cargo: &mut Command) {
143-
let mut features = build.std_features();
144-
145143
if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
146144
cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
147145
}
148146

149-
// When doing a local rebuild we tell cargo that we're stage1 rather than
150-
// stage0. This works fine if the local rust and being-built rust have the
151-
// same view of what the default allocator is, but fails otherwise. Since
152-
// we don't have a way to express an allocator preference yet, work
153-
// around the issue in the case of a local rebuild with jemalloc disabled.
154-
if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
155-
features.push_str(" force_alloc_system");
156-
}
147+
if build.no_std(target) == Some(true) {
148+
// for no-std targets we only compile a few no_std crates
149+
cargo.arg("--features").arg("c mem")
150+
.args(&["-p", "alloc"])
151+
.args(&["-p", "compiler_builtins"])
152+
.args(&["-p", "std_unicode"])
153+
.arg("--manifest-path")
154+
.arg(build.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
155+
} else {
156+
let mut features = build.std_features();
157+
158+
// When doing a local rebuild we tell cargo that we're stage1 rather than
159+
// stage0. This works fine if the local rust and being-built rust have the
160+
// same view of what the default allocator is, but fails otherwise. Since
161+
// we don't have a way to express an allocator preference yet, work
162+
// around the issue in the case of a local rebuild with jemalloc disabled.
163+
if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
164+
features.push_str(" force_alloc_system");
165+
}
157166

158-
if compiler.stage != 0 && build.config.sanitizers {
159-
// This variable is used by the sanitizer runtime crates, e.g.
160-
// rustc_lsan, to build the sanitizer runtime from C code
161-
// When this variable is missing, those crates won't compile the C code,
162-
// so we don't set this variable during stage0 where llvm-config is
163-
// missing
164-
// We also only build the runtimes when --enable-sanitizers (or its
165-
// config.toml equivalent) is used
166-
let llvm_config = build.ensure(native::Llvm {
167-
target: build.config.build,
168-
emscripten: false,
169-
});
170-
cargo.env("LLVM_CONFIG", llvm_config);
171-
}
167+
if compiler.stage != 0 && build.config.sanitizers {
168+
// This variable is used by the sanitizer runtime crates, e.g.
169+
// rustc_lsan, to build the sanitizer runtime from C code
170+
// When this variable is missing, those crates won't compile the C code,
171+
// so we don't set this variable during stage0 where llvm-config is
172+
// missing
173+
// We also only build the runtimes when --enable-sanitizers (or its
174+
// config.toml equivalent) is used
175+
let llvm_config = build.ensure(native::Llvm {
176+
target: build.config.build,
177+
emscripten: false,
178+
});
179+
cargo.env("LLVM_CONFIG", llvm_config);
180+
}
172181

173-
cargo.arg("--features").arg(features)
174-
.arg("--manifest-path")
175-
.arg(build.src.join("src/libstd/Cargo.toml"));
182+
cargo.arg("--features").arg(features)
183+
.arg("--manifest-path")
184+
.arg(build.src.join("src/libstd/Cargo.toml"));
176185

177-
if let Some(target) = build.config.target_config.get(&target) {
178-
if let Some(ref jemalloc) = target.jemalloc {
179-
cargo.env("JEMALLOC_OVERRIDE", jemalloc);
186+
if let Some(target) = build.config.target_config.get(&target) {
187+
if let Some(ref jemalloc) = target.jemalloc {
188+
cargo.env("JEMALLOC_OVERRIDE", jemalloc);
189+
}
180190
}
181-
}
182-
if target.contains("musl") {
183-
if let Some(p) = build.musl_root(target) {
184-
cargo.env("MUSL_ROOT", p);
191+
if target.contains("musl") {
192+
if let Some(p) = build.musl_root(target) {
193+
cargo.env("MUSL_ROOT", p);
194+
}
185195
}
186196
}
187197
}

src/bootstrap/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ pub struct Target {
161161
pub crt_static: Option<bool>,
162162
pub musl_root: Option<PathBuf>,
163163
pub qemu_rootfs: Option<PathBuf>,
164+
pub no_std: bool,
164165
}
165166

166167
/// Structure of the `config.toml` file that configuration is read from.

src/bootstrap/dist.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,12 @@ impl Step for Std {
642642
if build.hosts.iter().any(|t| t == target) {
643643
builder.ensure(compile::Rustc { compiler, target });
644644
} else {
645-
builder.ensure(compile::Test { compiler, target });
645+
if build.no_std(target) == Some(true) {
646+
// the `test` doesn't compile for no-std targets
647+
builder.ensure(compile::Std { compiler, target });
648+
} else {
649+
builder.ensure(compile::Test { compiler, target });
650+
}
646651
}
647652

648653
let image = tmpdir(build).join(format!("{}-{}-image", name, target));

src/bootstrap/doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ impl Step for Rustc {
698698
t!(symlink_dir_force(&builder.config, &out, &out_dir));
699699

700700
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
701+
cargo.env("RUSTDOCFLAGS", "--document-private-items");
701702
compile::rustc_cargo(build, &mut cargo);
702703

703704
// Only include compiler crates, no dependencies of those, such as `libc`.

src/bootstrap/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,12 @@ impl Build {
750750
.map(|p| &**p)
751751
}
752752

753+
/// Returns true if this is a no-std `target`, if defined
754+
fn no_std(&self, target: Interned<String>) -> Option<bool> {
755+
self.config.target_config.get(&target)
756+
.map(|t| t.no_std)
757+
}
758+
753759
/// Returns whether the target will be tested using the `remote-test-client`
754760
/// and `remote-test-server` binaries.
755761
fn remote_tested(&self, target: Interned<String>) -> bool {

src/bootstrap/sanity.rs

+13
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ pub fn check(build: &mut Build) {
169169
panic!("the iOS target is only supported on macOS");
170170
}
171171

172+
if target.contains("-none-") {
173+
if build.no_std(*target).is_none() {
174+
let target = build.config.target_config.entry(target.clone())
175+
.or_insert(Default::default());
176+
177+
target.no_std = true;
178+
}
179+
180+
if build.no_std(*target) == Some(false) {
181+
panic!("All the *-none-* targets are no-std targets")
182+
}
183+
}
184+
172185
// Make sure musl-root is valid
173186
if target.contains("musl") {
174187
// If this is a native target (host is also musl) and no musl-root is given,

src/ci/docker/dist-various-1/Dockerfile

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2020
bzip2 \
2121
patch \
2222
libssl-dev \
23-
pkg-config
23+
pkg-config \
24+
gcc-arm-none-eabi \
25+
libnewlib-arm-none-eabi
2426

2527
WORKDIR /build
2628

@@ -86,6 +88,10 @@ ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
8688
ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl
8789
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
8890
ENV TARGETS=$TARGETS,x86_64-unknown-redox
91+
ENV TARGETS=$TARGETS,thumbv6m-none-eabi
92+
ENV TARGETS=$TARGETS,thumbv7m-none-eabi
93+
ENV TARGETS=$TARGETS,thumbv7em-none-eabi
94+
ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
8995

9096
# FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271
9197
# get fixed and cc update

src/ci/docker/x86_64-gnu-incremental/Dockerfile

-22
This file was deleted.

src/liballoc/vec.rs

+55-26
Original file line numberDiff line numberDiff line change
@@ -1594,40 +1594,69 @@ impl SpecFromElem for u8 {
15941594
}
15951595
}
15961596

1597-
macro_rules! impl_spec_from_elem {
1597+
impl<T: Clone + IsZero> SpecFromElem for T {
1598+
#[inline]
1599+
fn from_elem(elem: T, n: usize) -> Vec<T> {
1600+
if elem.is_zero() {
1601+
return Vec {
1602+
buf: RawVec::with_capacity_zeroed(n),
1603+
len: n,
1604+
}
1605+
}
1606+
let mut v = Vec::with_capacity(n);
1607+
v.extend_with(n, ExtendElement(elem));
1608+
v
1609+
}
1610+
}
1611+
1612+
unsafe trait IsZero {
1613+
/// Whether this value is zero
1614+
fn is_zero(&self) -> bool;
1615+
}
1616+
1617+
macro_rules! impl_is_zero {
15981618
($t: ty, $is_zero: expr) => {
1599-
impl SpecFromElem for $t {
1619+
unsafe impl IsZero for $t {
16001620
#[inline]
1601-
fn from_elem(elem: $t, n: usize) -> Vec<$t> {
1602-
if $is_zero(elem) {
1603-
return Vec {
1604-
buf: RawVec::with_capacity_zeroed(n),
1605-
len: n,
1606-
}
1607-
}
1608-
let mut v = Vec::with_capacity(n);
1609-
v.extend_with(n, ExtendElement(elem));
1610-
v
1621+
fn is_zero(&self) -> bool {
1622+
$is_zero(*self)
16111623
}
16121624
}
1613-
};
1625+
}
16141626
}
16151627

1616-
impl_spec_from_elem!(i8, |x| x == 0);
1617-
impl_spec_from_elem!(i16, |x| x == 0);
1618-
impl_spec_from_elem!(i32, |x| x == 0);
1619-
impl_spec_from_elem!(i64, |x| x == 0);
1620-
impl_spec_from_elem!(i128, |x| x == 0);
1621-
impl_spec_from_elem!(isize, |x| x == 0);
1628+
impl_is_zero!(i8, |x| x == 0);
1629+
impl_is_zero!(i16, |x| x == 0);
1630+
impl_is_zero!(i32, |x| x == 0);
1631+
impl_is_zero!(i64, |x| x == 0);
1632+
impl_is_zero!(i128, |x| x == 0);
1633+
impl_is_zero!(isize, |x| x == 0);
1634+
1635+
impl_is_zero!(u16, |x| x == 0);
1636+
impl_is_zero!(u32, |x| x == 0);
1637+
impl_is_zero!(u64, |x| x == 0);
1638+
impl_is_zero!(u128, |x| x == 0);
1639+
impl_is_zero!(usize, |x| x == 0);
1640+
1641+
impl_is_zero!(char, |x| x == '\0');
1642+
1643+
impl_is_zero!(f32, |x: f32| x.to_bits() == 0);
1644+
impl_is_zero!(f64, |x: f64| x.to_bits() == 0);
16221645

1623-
impl_spec_from_elem!(u16, |x| x == 0);
1624-
impl_spec_from_elem!(u32, |x| x == 0);
1625-
impl_spec_from_elem!(u64, |x| x == 0);
1626-
impl_spec_from_elem!(u128, |x| x == 0);
1627-
impl_spec_from_elem!(usize, |x| x == 0);
1646+
unsafe impl<T: ?Sized> IsZero for *const T {
1647+
#[inline]
1648+
fn is_zero(&self) -> bool {
1649+
(*self).is_null()
1650+
}
1651+
}
1652+
1653+
unsafe impl<T: ?Sized> IsZero for *mut T {
1654+
#[inline]
1655+
fn is_zero(&self) -> bool {
1656+
(*self).is_null()
1657+
}
1658+
}
16281659

1629-
impl_spec_from_elem!(f32, |x: f32| x.to_bits() == 0);
1630-
impl_spec_from_elem!(f64, |x: f64| x.to_bits() == 0);
16311660

16321661
////////////////////////////////////////////////////////////////////////////////
16331662
// Common trait implementations for Vec

0 commit comments

Comments
 (0)