Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #73954

Merged
merged 32 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
79a42e3
linker: Create GNU_EH_FRAME header by default when producing ELFs
petrochenkov Jun 20, 2020
7055c23
ast_pretty: Pass some token streams and trees by reference
petrochenkov Jun 24, 2020
4966272
Add newline to rustc MultiSpan docs
pierwill Jun 28, 2020
5239a68
add spans to injected coverage counters
richkadel Jun 22, 2020
9154863
Compile rustdoc less often.
ehuss Jun 28, 2020
844dc31
ci: fix wasm32 broken due to a NodeJS version bump
pietroalbini Jun 30, 2020
8ee1dec
Deny unsafe ops in unsafe fns, part 1
LeSeulArtichaut Jun 21, 2020
8a515e9
Deny unsafe ops in unsafe fns, part 2
LeSeulArtichaut Jun 22, 2020
ac7539c
Deny unsafe ops in unsafe fns, part 3
LeSeulArtichaut Jun 24, 2020
c68f478
Deny unsafe ops in unsafe fns, part 4
LeSeulArtichaut Jun 25, 2020
b365233
Deny unsafe ops in unsafe fns, part 5
LeSeulArtichaut Jun 30, 2020
a1623ff
Deny unsafe ops in unsafe fns, part 6
LeSeulArtichaut Jun 30, 2020
6a7a652
Bless failing tests
LeSeulArtichaut Jun 30, 2020
e191358
Changes required for rustc/cargo to build for iOS targets
Jun 30, 2020
c22bcb0
Only set the flag in LLVM builds.
Jun 30, 2020
5f3dbd8
Don't break on iOS Simulator builds.
Jun 30, 2020
cd9d833
Implement slice_strip feature
tesuji Jul 1, 2020
4fd1c77
Document the CMake defines.
Jul 1, 2020
22e8ced
Also document iphoneos-version-min.
Jul 1, 2020
67b162f
Explicitly check for iOS/tvOS.
Jul 1, 2020
86d8644
Optimise fast path of checked_ops with `unlikely`
nbdd0121 Jun 26, 2020
0b9bc79
Tests for number of times rustdoc is built with x.py test and doc.
ehuss Jul 1, 2020
63d392e
Rollup merge of #73414 - lzutao:slice_strip, r=dtolnay
Manishearth Jul 2, 2020
1c68bb6
Rollup merge of #73564 - petrochenkov:ehdr, r=Amanieu
Manishearth Jul 2, 2020
500634b
Rollup merge of #73622 - LeSeulArtichaut:unsafe-libcore, r=nikomatsakis
Manishearth Jul 2, 2020
dc762ce
Rollup merge of #73684 - richkadel:llvm-coverage-map-gen-2, r=wesleyw…
Manishearth Jul 2, 2020
32f5e63
Rollup merge of #73812 - petrochenkov:prettyref, r=varkor
Manishearth Jul 2, 2020
294b972
Rollup merge of #73853 - pierwill:pierwill-multispan-doc, r=jonas-sch…
Manishearth Jul 2, 2020
7b2f44a
Rollup merge of #73883 - ehuss:rustdoc-stage-previous, r=Mark-Simulacrum
Manishearth Jul 2, 2020
4593e9f
Rollup merge of #73885 - pietroalbini:ci-fix-wasm32, r=kennytm
Manishearth Jul 2, 2020
061f1c6
Rollup merge of #73903 - luxxxxy:ios-rustc, r=nikomatsakis
Manishearth Jul 2, 2020
4f536f2
Rollup merge of #73938 - nbdd0121:checked_opt, r=nagisa
Manishearth Jul 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ fn dist_baseline() {
&[dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a },]
);
assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
// Make sure rustdoc is only built once.
assert_eq!(
first(builder.cache.all::<tool::Rustdoc>()),
&[tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } },]
);
}

#[test]
Expand Down Expand Up @@ -414,3 +419,77 @@ fn test_exclude() {
// Ensure other tests are not affected.
assert!(builder.cache.contains::<test::RustdocUi>());
}

#[test]
fn doc_default() {
let mut config = configure(&[], &[]);
config.compiler_docs = true;
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false };
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), &[]);
let a = INTERNER.intern_str("A");

// error_index_generator uses stage 1 to share rustdoc artifacts with the
// rustdoc tool.
assert_eq!(
first(builder.cache.all::<doc::ErrorIndex>()),
&[doc::ErrorIndex { compiler: Compiler { host: a, stage: 1 }, target: a },]
);
assert_eq!(
first(builder.cache.all::<tool::ErrorIndex>()),
&[tool::ErrorIndex { compiler: Compiler { host: a, stage: 1 } }]
);
// This is actually stage 1, but Rustdoc::run swaps out the compiler with
// stage minus 1 if --stage is not 0. Very confusing!
assert_eq!(
first(builder.cache.all::<tool::Rustdoc>()),
&[tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } },]
);
}

#[test]
fn test_docs() {
// Behavior of `x.py test` doing various documentation tests.
let mut config = configure(&[], &[]);
config.cmd = Subcommand::Test {
paths: vec![],
test_args: vec![],
rustc_args: vec![],
fail_fast: true,
doc_tests: DocTests::Yes,
bless: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
};
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]);
let a = INTERNER.intern_str("A");

// error_index_generator uses stage 1 to share rustdoc artifacts with the
// rustdoc tool.
assert_eq!(
first(builder.cache.all::<doc::ErrorIndex>()),
&[doc::ErrorIndex { compiler: Compiler { host: a, stage: 1 }, target: a },]
);
assert_eq!(
first(builder.cache.all::<tool::ErrorIndex>()),
&[tool::ErrorIndex { compiler: Compiler { host: a, stage: 1 } }]
);
// Unfortunately rustdoc is built twice. Once from stage1 for compiletest
// (and other things), and once from stage0 for std crates. Ideally it
// would only be built once. If someone wants to fix this, it might be
// worth investigating if it would be possible to test std from stage1.
// Note that the stages here are +1 than what they actually are because
// Rustdoc::run swaps out the compiler with stage minus 1 if --stage is
// not 0.
assert_eq!(
first(builder.cache.all::<tool::Rustdoc>()),
&[
tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } },
tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } },
]
);
}
31 changes: 15 additions & 16 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,7 @@ impl Step for Rustc {
let out = builder.compiler_doc_out(target);
t!(fs::create_dir_all(&out));

// Get the correct compiler for this stage.
let compiler = builder.compiler_for(stage, builder.config.build, target);
let compiler = builder.compiler(stage, builder.config.build);

if !builder.config.compiler_docs {
builder.info("\tskipping - compiler/librustdoc docs disabled");
Expand Down Expand Up @@ -599,8 +598,7 @@ impl Step for Rustdoc {
let out = builder.compiler_doc_out(target);
t!(fs::create_dir_all(&out));

// Get the correct compiler for this stage.
let compiler = builder.compiler_for(stage, builder.config.build, target);
let compiler = builder.compiler(stage, builder.config.build);

if !builder.config.compiler_docs {
builder.info("\tskipping - compiler/librustdoc docs disabled");
Expand Down Expand Up @@ -639,9 +637,10 @@ impl Step for Rustdoc {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ErrorIndex {
target: Interned<String>,
pub compiler: Compiler,
pub target: Interned<String>,
}

impl Step for ErrorIndex {
Expand All @@ -655,26 +654,26 @@ impl Step for ErrorIndex {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(ErrorIndex { target: run.target });
let target = run.target;
// error_index_generator depends on librustdoc. Use the compiler that
// is normally used to build rustdoc for other documentation so that
// it shares the same artifacts.
let compiler =
run.builder.compiler_for(run.builder.top_stage, run.builder.config.build, target);
run.builder.ensure(ErrorIndex { compiler, target });
}

/// Generates the HTML rendered error-index by running the
/// `error_index_generator` tool.
fn run(self, builder: &Builder<'_>) {
let target = self.target;

builder.info(&format!("Documenting error index ({})", target));
let out = builder.doc_out(target);
builder.info(&format!("Documenting error index ({})", self.target));
let out = builder.doc_out(self.target);
t!(fs::create_dir_all(&out));
let compiler = builder.compiler(2, builder.config.build);
let mut index = tool::ErrorIndex::command(builder, compiler);
let mut index = tool::ErrorIndex::command(builder, self.compiler);
index.arg("html");
index.arg(out.join("error-index.html"));
index.arg(crate::channel::CFG_RELEASE_NUM);

// FIXME: shouldn't have to pass this env var
index.env("CFG_BUILD", &builder.config.build);

builder.run(&mut index);
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ impl Step for Llvm {
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
}

// Are we compiling for iOS/tvOS?
if target.contains("apple-ios") || target.contains("apple-tvos") {
// These two defines prevent CMake from automatically trying to add a MacOSX sysroot, which leads to a compiler error.
cfg.define("CMAKE_OSX_SYSROOT", "/");
cfg.define("CMAKE_OSX_DEPLOYMENT_TARGET", "");
// Prevent cmake from adding -bundle to CFLAGS automatically, which leads to a compiler error because "-bitcode_bundle" also gets added.
cfg.define("LLVM_ENABLE_PLUGINS", "OFF");
// Zlib fails to link properly, leading to a compiler error.
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
}

if builder.config.llvm_thin_lto {
cfg.define("LLVM_ENABLE_LTO", "Thin");
if !target.contains("apple") {
Expand Down Expand Up @@ -412,6 +423,14 @@ fn configure_cmake(
if let Some(ref s) = builder.config.llvm_cflags {
cflags.push_str(&format!(" {}", s));
}
// Some compiler features used by LLVM (such as thread locals) will not work on a min version below iOS 10.
if target.contains("apple-ios") {
if target.contains("86-") {
cflags.push_str(" -miphonesimulator-version-min=10.0");
} else {
cflags.push_str(" -miphoneos-version-min=10.0");
}
}
cfg.define("CMAKE_C_FLAGS", cflags);
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {
Expand Down
60 changes: 47 additions & 13 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,11 @@ impl Step for ErrorIndex {
}

fn make_run(run: RunConfig<'_>) {
run.builder
.ensure(ErrorIndex { compiler: run.builder.compiler(run.builder.top_stage, run.host) });
// error_index_generator depends on librustdoc. Use the compiler that
// is normally used to build rustdoc for other tests (like compiletest
// tests in src/test/rustdoc) so that it shares the same artifacts.
let compiler = run.builder.compiler_for(run.builder.top_stage, run.host, run.host);
run.builder.ensure(ErrorIndex { compiler });
}

/// Runs the error index generator tool to execute the tests located in the error
Expand All @@ -1467,22 +1470,23 @@ impl Step for ErrorIndex {
fn run(self, builder: &Builder<'_>) {
let compiler = self.compiler;

builder.ensure(compile::Std { compiler, target: compiler.host });

let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir));
let output = dir.join("error-index.md");

let mut tool = tool::ErrorIndex::command(
builder,
builder.compiler(compiler.stage, builder.config.build),
);
tool.arg("markdown").arg(&output).env("CFG_BUILD", &builder.config.build);
let mut tool = tool::ErrorIndex::command(builder, compiler);
tool.arg("markdown").arg(&output);

builder.info(&format!("Testing error-index stage{}", compiler.stage));
// Use the rustdoc that was built by self.compiler. This copy of
// rustdoc is shared with other tests (like compiletest tests in
// src/test/rustdoc). This helps avoid building rustdoc multiple
// times.
let rustdoc_compiler = builder.compiler(builder.top_stage, builder.config.build);
builder.info(&format!("Testing error-index stage{}", rustdoc_compiler.stage));
let _time = util::timeit(&builder);
builder.run_quiet(&mut tool);
markdown_test(builder, compiler, &output);
builder.ensure(compile::Std { compiler: rustdoc_compiler, target: rustdoc_compiler.host });
markdown_test(builder, rustdoc_compiler, &output);
}
}

Expand Down Expand Up @@ -1797,9 +1801,13 @@ impl Step for CrateRustdoc {

fn run(self, builder: &Builder<'_>) {
let test_kind = self.test_kind;
let target = self.host;

let compiler = builder.compiler(builder.top_stage, self.host);
let target = compiler.host;
// Use the previous stage compiler to reuse the artifacts that are
// created when running compiletest for src/test/rustdoc. If this used
// `compiler`, then it would cause rustdoc to be built *again*, which
// isn't really necessary.
let compiler = builder.compiler_for(builder.top_stage, target, target);
builder.ensure(compile::Rustc { compiler, target });

let mut cargo = tool::prepare_tool_cargo(
Expand All @@ -1825,6 +1833,32 @@ impl Step for CrateRustdoc {
cargo.arg("'-Ctarget-feature=-crt-static'");
}

// This is needed for running doctests on librustdoc. This is a bit of
// an unfortunate interaction with how bootstrap works and how cargo
// sets up the dylib path, and the fact that the doctest (in
// html/markdown.rs) links to rustc-private libs. For stage1, the
// compiler host dylibs (in stage1/lib) are not the same as the target
// dylibs (in stage1/lib/rustlib/...). This is different from a normal
// rust distribution where they are the same.
//
// On the cargo side, normal tests use `target_process` which handles
// setting up the dylib for a *target* (stage1/lib/rustlib/... in this
// case). However, for doctests it uses `rustdoc_process` which only
// sets up the dylib path for the *host* (stage1/lib), which is the
// wrong directory.
//
// It should be considered to just stop running doctests on
// librustdoc. There is only one test, and it doesn't look too
// important. There might be other ways to avoid this, but it seems
// pretty convoluted.
//
// See also https://github.com/rust-lang/rust/issues/13983 where the
// host vs target dylibs for rustdoc are consistently tricky to deal
// with.
let mut dylib_path = dylib_path();
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());

if !builder.config.verbose_tests {
cargo.arg("--quiet");
}
Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ bootstrap_tool!(
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
);

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
pub struct ErrorIndex {
pub compiler: Compiler,
}
Expand All @@ -392,9 +392,9 @@ impl Step for ErrorIndex {
fn make_run(run: RunConfig<'_>) {
// Compile the error-index in the same stage as rustdoc to avoid
// recompiling rustdoc twice if we can.
let stage = if run.builder.top_stage >= 2 { run.builder.top_stage } else { 0 };
run.builder
.ensure(ErrorIndex { compiler: run.builder.compiler(stage, run.builder.config.build) });
let host = run.builder.config.build;
let compiler = run.builder.compiler_for(run.builder.top_stage, host, host);
run.builder.ensure(ErrorIndex { compiler });
}

fn run(self, builder: &Builder<'_>) -> PathBuf {
Expand Down Expand Up @@ -449,7 +449,7 @@ impl Step for RemoteTestServer {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
pub struct Rustdoc {
/// This should only ever be 0 or 2.
/// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here.
Expand Down
13 changes: 12 additions & 1 deletion src/ci/docker/wasm32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ RUN ln `which python3` /usr/bin/python

ENV PATH=$PATH:/emsdk-portable
ENV PATH=$PATH:/emsdk-portable/upstream/emscripten/
ENV PATH=$PATH:/emsdk-portable/node/12.9.1_64bit/bin/

# Rust's build system requires NodeJS to be in the path, but the directory in
# which emsdk stores it contains the version number. This caused breakages in
# the past when emsdk bumped the node version causing the path to point to a
# missing directory.
#
# To avoid the problem this symlinks the latest NodeJs version available to
# "latest", and adds that to the path.
RUN ln -s /emsdk-portable/node/$(ls /emsdk-portable/node | sort -V | tail -n 1) \
/emsdk-portable/node/latest
ENV PATH=$PATH:/emsdk-portable/node/latest/bin/

ENV BINARYEN_ROOT=/emsdk-portable/upstream/
ENV EMSDK=/emsdk-portable
ENV EM_CONFIG=/emsdk-portable/.emscripten
Expand Down
22 changes: 16 additions & 6 deletions src/libcore/alloc/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ pub unsafe trait GlobalAlloc {
#[stable(feature = "global_alloc", since = "1.28.0")]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
let size = layout.size();
let ptr = self.alloc(layout);
// SAFETY: the safety contract for `alloc` must be upheld by the caller.
let ptr = unsafe { self.alloc(layout) };
if !ptr.is_null() {
ptr::write_bytes(ptr, 0, size);
// SAFETY: as allocation succeeded, the region from `ptr`
// of size `size` is guaranteed to be valid for writes.
unsafe { ptr::write_bytes(ptr, 0, size) };
}
ptr
}
Expand Down Expand Up @@ -187,11 +190,18 @@ pub unsafe trait GlobalAlloc {
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
#[stable(feature = "global_alloc", since = "1.28.0")]
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
let new_ptr = self.alloc(new_layout);
// SAFETY: the caller must ensure that the `new_size` does not overflow.
// `layout.align()` comes from a `Layout` and is thus guaranteed to be valid.
let new_layout = unsafe { Layout::from_size_align_unchecked(new_size, layout.align()) };
// SAFETY: the caller must ensure that `new_layout` is greater than zero.
let new_ptr = unsafe { self.alloc(new_layout) };
if !new_ptr.is_null() {
ptr::copy_nonoverlapping(ptr, new_ptr, cmp::min(layout.size(), new_size));
self.dealloc(ptr, layout);
// SAFETY: the previously allocated block cannot overlap the newly allocated block.
// The safety contract for `dealloc` must be upheld by the caller.
unsafe {
ptr::copy_nonoverlapping(ptr, new_ptr, cmp::min(layout.size(), new_size));
self.dealloc(ptr, layout);
}
}
new_ptr
}
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ impl Layout {
#[rustc_const_stable(feature = "alloc_layout", since = "1.28.0")]
#[inline]
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
Layout { size_: size, align_: NonZeroUsize::new_unchecked(align) }
// SAFETY: the caller must ensure that `align` is greater than zero.
Layout { size_: size, align_: unsafe { NonZeroUsize::new_unchecked(align) } }
}

/// The minimum size in bytes for a memory block of this layout.
Expand Down
Loading