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 14 pull requests #76540

Merged
merged 35 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3b4a346
Fix incorrect wording for `verbose-tests`
jyn514 Aug 31, 2020
d983873
Document the defaults for `codegen-units`
jyn514 Aug 31, 2020
41c1382
Mention why you'd want codegen-units = 0 (other than running out of RAM)
jyn514 Aug 31, 2020
9f268de
Address review comments
jyn514 Aug 31, 2020
ba664c2
Codegen defaults come from rustc, not cargo
jyn514 Sep 1, 2020
7ec1de0
Clarify message about unresolved use
kornelski Aug 27, 2020
9046a93
Improved the MIR spanview output
richkadel Sep 4, 2020
3740b00
Add align to rustc-attrs unstable book
pickfire Sep 7, 2020
3a3a085
Unstable book rust-attrs does not work on generics
pickfire Sep 8, 2020
0c9bf13
Add a script to automatically update Rust/Clang versions
jyn514 Sep 8, 2020
f64ddc6
triagebot: enable github releases synchronization
pietroalbini Sep 8, 2020
c8262fd
Add missed spaces to GCC-WARNING.txt
artemmukhin Sep 8, 2020
c3c84ad
Convert MAXIMUM_ZST_CAPACITY to be calculated in a
moonheart08 Sep 8, 2020
e02952c
Update library/alloc/src/collections/vec_deque.rs
moonheart08 Sep 8, 2020
0aaf56f
Remove a stray ignore-tidy-undocumented-unsafe
moonheart08 Sep 8, 2020
c66789d
Capitalize safety comments
Flying-Toast Sep 9, 2020
2799aec
Capitalize safety comments
Flying-Toast Sep 9, 2020
c81b43d
Add `-Z combine_cgu` flag
Sep 9, 2020
8b39250
Fix non-determinism in generated format string.
jumbatm Sep 9, 2020
be28b62
remove redundant clones
matthiaskrgr Sep 9, 2020
0016405
Remove unused PlaceContext::NonUse(NonUseContext::Coverage)
tmiasko Sep 9, 2020
07dbe49
Rollup merge of #75094 - 0dvictor:cgu, r=oli-obk
tmandry Sep 9, 2020
5ea5551
Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasper
tmandry Sep 9, 2020
b4b8a52
Rollup merge of #76141 - jyn514:config.toml, r=Mark-Simulacrum
tmandry Sep 9, 2020
bab0968
Rollup merge of #76313 - richkadel:mir-spanview-2, r=wesleywiser
tmandry Sep 9, 2020
d0c2a2d
Rollup merge of #76430 - pickfire:patch-7, r=steveklabnik
tmandry Sep 9, 2020
df84ac7
Rollup merge of #76465 - jyn514:auto-versioning, r=elichai
tmandry Sep 9, 2020
09bfb7e
Rollup merge of #76473 - ortem:fix-gcc-warning, r=jonas-schievink
tmandry Sep 9, 2020
0d20cf8
Rollup merge of #76481 - moonheart08:vec_deque_constify, r=sfackler
tmandry Sep 9, 2020
342b406
Rollup merge of #76493 - moonheart08:unique-quick, r=jyn514
tmandry Sep 9, 2020
c18fa46
Rollup merge of #76504 - Flying-Toast:master, r=lcnr
tmandry Sep 9, 2020
98f59bc
Rollup merge of #76515 - jumbatm:issue76496-reproducibility-regressio…
tmandry Sep 9, 2020
09a364e
Rollup merge of #76516 - pietroalbini:github-releases, r=Mark-Simulacrum
tmandry Sep 9, 2020
09c6149
Rollup merge of #76522 - matthiaskrgr:redundant_clone, r=jonas-schievink
tmandry Sep 9, 2020
32714eb
Rollup merge of #76523 - tmiasko:non-use-context-coverage, r=wesleywiser
tmandry Sep 9, 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
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ fn fat_lto(
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: serialized_bitcode })
}

struct Linker<'a>(&'a mut llvm::Linker<'a>);
crate struct Linker<'a>(&'a mut llvm::Linker<'a>);

impl Linker<'a> {
fn new(llmod: &'a llvm::Module) -> Self {
crate fn new(llmod: &'a llvm::Module) -> Self {
unsafe { Linker(llvm::LLVMRustLinkerNew(llmod)) }
}

fn add(&mut self, bytecode: &[u8]) -> Result<(), ()> {
crate fn add(&mut self, bytecode: &[u8]) -> Result<(), ()> {
unsafe {
if llvm::LLVMRustLinkerAdd(
self.0,
Expand Down
25 changes: 25 additions & 0 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,31 @@ unsafe fn add_sanitizer_passes(config: &ModuleConfig, passes: &mut Vec<&'static
}
}

pub(crate) fn link(
cgcx: &CodegenContext<LlvmCodegenBackend>,
diag_handler: &Handler,
mut modules: Vec<ModuleCodegen<ModuleLlvm>>,
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
use super::lto::{Linker, ModuleBuffer};
// Sort the modules by name to ensure to ensure deterministic behavior.
modules.sort_by(|a, b| a.name.cmp(&b.name));
let (first, elements) =
modules.split_first().expect("Bug! modules must contain at least one module.");

let mut linker = Linker::new(first.module_llvm.llmod());
for module in elements {
let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_link_module", format!("{:?}", module.name));
let buffer = ModuleBuffer::new(module.module_llvm.llmod());
linker.add(&buffer.data()).map_err(|()| {
let msg = format!("failed to serialize module {:?}", module.name);
llvm_err(&diag_handler, &msg)
})?;
}
drop(linker);
Ok(modules.remove(0))
}

pub(crate) unsafe fn codegen(
cgcx: &CodegenContext<LlvmCodegenBackend>,
diag_handler: &Handler,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ impl WriteBackendMethods for LlvmCodegenBackend {
llvm::LLVMRustPrintPassTimings();
}
}
fn run_link(
cgcx: &CodegenContext<Self>,
diag_handler: &Handler,
modules: Vec<ModuleCodegen<Self::Module>>,
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
back::write::link(cgcx, diag_handler, modules)
}
fn run_fat_lto(
cgcx: &CodegenContext<Self>,
modules: Vec<FatLTOInput<Self>>,
Expand Down
59 changes: 47 additions & 12 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {

enum WorkItemResult<B: WriteBackendMethods> {
Compiled(CompiledModule),
NeedsLink(ModuleCodegen<B::Module>),
NeedsFatLTO(FatLTOInput<B>),
NeedsThinLTO(String, B::ThinBuffer),
}
Expand Down Expand Up @@ -801,31 +802,28 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
None
};

Ok(match lto_type {
ComputedLtoType::No => {
let module = unsafe { B::codegen(cgcx, &diag_handler, module, module_config)? };
WorkItemResult::Compiled(module)
}
match lto_type {
ComputedLtoType::No => finish_intra_module_work(cgcx, module, module_config),
ComputedLtoType::Thin => {
let (name, thin_buffer) = B::prepare_thin(module);
if let Some(path) = bitcode {
fs::write(&path, thin_buffer.data()).unwrap_or_else(|e| {
panic!("Error writing pre-lto-bitcode file `{}`: {}", path.display(), e);
});
}
WorkItemResult::NeedsThinLTO(name, thin_buffer)
Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer))
}
ComputedLtoType::Fat => match bitcode {
Some(path) => {
let (name, buffer) = B::serialize_module(module);
fs::write(&path, buffer.data()).unwrap_or_else(|e| {
panic!("Error writing pre-lto-bitcode file `{}`: {}", path.display(), e);
});
WorkItemResult::NeedsFatLTO(FatLTOInput::Serialized { name, buffer })
Ok(WorkItemResult::NeedsFatLTO(FatLTOInput::Serialized { name, buffer }))
}
None => WorkItemResult::NeedsFatLTO(FatLTOInput::InMemory(module)),
None => Ok(WorkItemResult::NeedsFatLTO(FatLTOInput::InMemory(module))),
},
})
}
}

fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
Expand Down Expand Up @@ -870,13 +868,26 @@ fn execute_lto_work_item<B: ExtraBackendMethods>(
cgcx: &CodegenContext<B>,
mut module: lto::LtoModuleCodegen<B>,
module_config: &ModuleConfig,
) -> Result<WorkItemResult<B>, FatalError> {
let module = unsafe { module.optimize(cgcx)? };
finish_intra_module_work(cgcx, module, module_config)
}

fn finish_intra_module_work<B: ExtraBackendMethods>(
cgcx: &CodegenContext<B>,
module: ModuleCodegen<B::Module>,
module_config: &ModuleConfig,
) -> Result<WorkItemResult<B>, FatalError> {
let diag_handler = cgcx.create_diag_handler();

unsafe {
let module = module.optimize(cgcx)?;
let module = B::codegen(cgcx, &diag_handler, module, module_config)?;
if !cgcx.opts.debugging_opts.combine_cgu
|| module.kind == ModuleKind::Metadata
|| module.kind == ModuleKind::Allocator
{
let module = unsafe { B::codegen(cgcx, &diag_handler, module, module_config)? };
Ok(WorkItemResult::Compiled(module))
} else {
Ok(WorkItemResult::NeedsLink(module))
}
}

Expand All @@ -891,6 +902,10 @@ pub enum Message<B: WriteBackendMethods> {
thin_buffer: B::ThinBuffer,
worker_id: usize,
},
NeedsLink {
module: ModuleCodegen<B::Module>,
worker_id: usize,
},
Done {
result: Result<CompiledModule, Option<WorkerFatalError>>,
worker_id: usize,
Expand Down Expand Up @@ -1178,6 +1193,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
let mut compiled_modules = vec![];
let mut compiled_metadata_module = None;
let mut compiled_allocator_module = None;
let mut needs_link = Vec::new();
let mut needs_fat_lto = Vec::new();
let mut needs_thin_lto = Vec::new();
let mut lto_import_only_modules = Vec::new();
Expand Down Expand Up @@ -1434,6 +1450,10 @@ fn start_executing_work<B: ExtraBackendMethods>(
}
}
}
Message::NeedsLink { module, worker_id } => {
free_worker(worker_id);
needs_link.push(module);
}
Message::NeedsFatLTO { result, worker_id } => {
assert!(!started_lto);
free_worker(worker_id);
Expand Down Expand Up @@ -1462,6 +1482,18 @@ fn start_executing_work<B: ExtraBackendMethods>(
}
}

let needs_link = mem::take(&mut needs_link);
if !needs_link.is_empty() {
assert!(compiled_modules.is_empty());
let diag_handler = cgcx.create_diag_handler();
let module = B::run_link(&cgcx, &diag_handler, needs_link).map_err(|_| ())?;
let module = unsafe {
B::codegen(&cgcx, &diag_handler, module, cgcx.config(ModuleKind::Regular))
.map_err(|_| ())?
};
compiled_modules.push(module);
}

// Drop to print timings
drop(llvm_start_time);

Expand Down Expand Up @@ -1521,6 +1553,9 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
Some(Ok(WorkItemResult::Compiled(m))) => {
Message::Done::<B> { result: Ok(m), worker_id }
}
Some(Ok(WorkItemResult::NeedsLink(m))) => {
Message::NeedsLink::<B> { module: m, worker_id }
}
Some(Ok(WorkItemResult::NeedsFatLTO(m))) => {
Message::NeedsFatLTO::<B> { result: m, worker_id }
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
type ThinData: Send + Sync;
type ThinBuffer: ThinBufferMethods;

/// Merge all modules into main_module and returning it
fn run_link(
cgcx: &CodegenContext<Self>,
diag_handler: &Handler,
modules: Vec<ModuleCodegen<Self::Module>>,
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
/// Performs fat LTO by merging all modules into a single one and returning it
/// for further optimization.
fn run_fat_lto(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/temp_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct MaybeTempDir {

impl Drop for MaybeTempDir {
fn drop(&mut self) {
// Safety: We are in the destructor, and no further access will
// SAFETY: We are in the destructor, and no further access will
// occur.
let dir = unsafe { ManuallyDrop::take(&mut self.dir) };
if self.keep {
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_error_codes/src/error_codes/E0433.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
An undeclared type or module was used.
An undeclared crate, module, or type was used.

Erroneous code example:

```compile_fail,E0433
let map = HashMap::new();
// error: failed to resolve: use of undeclared type or module `HashMap`
// error: failed to resolve: use of undeclared type `HashMap`
```

Please verify you didn't misspell the type/module's name or that you didn't
forget to import it:


```
use std::collections::HashMap; // HashMap has been imported.
let map: HashMap<u32, u32> = HashMap::new(); // So it can be used!
```

If you've expected to use a crate name:

```compile_fail
use ferris_wheel::BigO;
// error: failed to resolve: use of undeclared crate or module `ferris_wheel`
```

Make sure the crate has been added as a dependency in `Cargo.toml`.

To use a module from your current crate, add the `crate::` prefix to the path.
11 changes: 6 additions & 5 deletions compiler/rustc_macros/src/session_diagnostic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#![deny(unused_must_use)]
use quote::format_ident;
use quote::quote;

use proc_macro::Diagnostic;
use quote::{format_ident, quote};
use syn::spanned::Spanned;

use std::collections::{HashMap, HashSet};
use std::collections::{BTreeSet, HashMap};

/// Implements #[derive(SessionDiagnostic)], which allows for errors to be specified as a struct, independent
/// from the actual diagnostics emitting code.
Expand Down Expand Up @@ -577,7 +575,10 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
/// ```
/// This function builds the entire call to format!.
fn build_format(&self, input: &String, span: proc_macro2::Span) -> proc_macro2::TokenStream {
let mut referenced_fields: HashSet<String> = HashSet::new();
// This set is used later to generate the final format string. To keep builds reproducible,
// the iteration order needs to be deterministic, hence why we use a BTreeSet here instead
// of a HashSet.
let mut referenced_fields: BTreeSet<String> = BTreeSet::new();

// At this point, we can start parsing the format string.
let mut it = input.chars().peekable();
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,6 @@ pub enum NonUseContext {
StorageDead,
/// User type annotation assertions for NLL.
AscribeUserTy,
/// Coverage code region and counter metadata.
Coverage,
/// The data of an user variable, for debug info.
VarDebugInfo,
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/borrow_check/def_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
PlaceContext::MutatingUse(MutatingUseContext::Drop) =>
Some(DefUse::Drop),

// Coverage and debug info are neither def nor use.
PlaceContext::NonUse(NonUseContext::Coverage) |
// Debug info is neither def nor use.
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
}
}
1 change: 0 additions & 1 deletion compiler/rustc_mir/src/dataflow/impls/init_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ where
PlaceContext::NonUse(
NonUseContext::StorageLive
| NonUseContext::AscribeUserTy
| NonUseContext::Coverage
| NonUseContext::VarDebugInfo,
)
| PlaceContext::NonMutatingUse(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/instrument_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
for coverage_region in coverage_regions {
span_viewables.push(SpanViewable {
span: coverage_region.span,
title: format!("{}", coverage_region.blocks[0].index()),
id: format!("{}", coverage_region.blocks[0].index()),
tooltip: self.make_tooltip_text(coverage_region),
});
}
Expand Down
Loading