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 9 pull requests #77881

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a4a0342
ci: disabled: riscv: work around QEMU regression
tblah Oct 9, 2020
e0b033e
doc: fix broken link for crate::os::linux::raw::stat
tblah Oct 9, 2020
46f2f02
Move supported_target_features query provider to cg_ssa
bjorn3 Oct 9, 2020
69f45cd
Move save_work_product_index call out of cg_llvm
bjorn3 Oct 10, 2020
f141acf
Move finalize_session_directory call out of cg_llvm
bjorn3 Oct 10, 2020
69f26b7
Use fixed type for CodegenResults
bjorn3 Oct 10, 2020
0d27b76
Take functions by value
bugadani Oct 9, 2020
12a2941
Move llvm_util::time_trace_profiler_finish call to join_codegen
bjorn3 Oct 10, 2020
23c3356
Mention rustdoc in `x.py setup`
jyn514 Oct 10, 2020
aa51449
Fix hotplug_codegen_backend test
bjorn3 Oct 10, 2020
cc0d140
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`
jyn514 Oct 11, 2020
85c0479
Remove unnecessary Clean impl
jyn514 Oct 11, 2020
96b0446
Move `PartialOrd` impl out of rustc
jyn514 Oct 11, 2020
ca5478a
bootstrap: only use compiler-builtins-c if they exist
gburgessiv Oct 11, 2020
01ac5a9
Stabilize slice_select_nth_unstable
jagill Oct 7, 2020
b620e49
Remove dump_incremental_data
bjorn3 Oct 12, 2020
02e6b86
rustdoc: skip allow missing doc in cover. report
r-52 Sep 1, 2020
b31f5d0
Inherit lint level from parents
GuillaumeGomez Oct 8, 2020
22465b3
Apply same treatment to MISSING_DOC_CODE_EXAMPLES
GuillaumeGomez Oct 8, 2020
5d20e1a
Improve lint level handling
GuillaumeGomez Oct 12, 2020
6854440
Extend test to ensure that items inherit lint level from the parent
GuillaumeGomez Oct 12, 2020
25cc75c
build-manifest: accept the Rust version instead of the monorepo path
pietroalbini Oct 9, 2020
2f387e9
bootstrap: add disabled by default build-manifest dist component
pietroalbini Oct 9, 2020
60ae018
bootstrap: add --include-default-paths to ./x.py
pietroalbini Oct 9, 2020
24d04cc
ci: also build the build-manifest component on dist-x86_64-linux
pietroalbini Oct 9, 2020
f3d07b3
build-manifest: allow configuring the number of threads
pietroalbini Oct 12, 2020
cbded3e
build-manifest: use var_os instead of var to check if vars exist
pietroalbini Oct 12, 2020
0b7ee9d
build-manifest: bundle the rustc version in the binary
pietroalbini Oct 12, 2020
19ca234
Rollup merge of #76196 - r-52:r-coverage-allow-missing-docs, r=jyn514
Dylan-DPC Oct 13, 2020
c0d1e29
Rollup merge of #77639 - jagill:stabilize-slice_partition_at_index, r…
Dylan-DPC Oct 13, 2020
233c894
Rollup merge of #77755 - bugadani:perf-calc-dtor, r=ecstatic-morse
Dylan-DPC Oct 13, 2020
cfe390d
Rollup merge of #77759 - tblah:fix_riscv_qemu, r=pietroalbini
Dylan-DPC Oct 13, 2020
37424b5
Rollup merge of #77762 - pietroalbini:dist-build-manifest, r=Mark-Sim…
Dylan-DPC Oct 13, 2020
858c3b3
Rollup merge of #77786 - jyn514:rustdoc, r=Mark-Simulacrum
Dylan-DPC Oct 13, 2020
31c3f51
Rollup merge of #77795 - bjorn3:codegen_backend_interface_refactor, r…
Dylan-DPC Oct 13, 2020
942369c
Rollup merge of #77817 - jyn514:const-since, r=petrochenkov
Dylan-DPC Oct 13, 2020
d93292a
Rollup merge of #77829 - gburgessiv:unused-features-var, r=alexcrichton
Dylan-DPC Oct 13, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ dependencies = [
"anyhow",
"flate2",
"hex 0.4.2",
"num_cpus",
"rayon",
"serde",
"serde_json",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub struct ConstStability {
}

/// The available stability levels.
#[derive(Encodable, Decodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)]
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
#[derive(HashStable_Generic)]
pub enum StabilityLevel {
// Reason for the current stability level and the relevant rust-lang issue
Expand Down
20 changes: 2 additions & 18 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_hir::def_id::DefId;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_middle::ty::query::Providers;
Expand Down Expand Up @@ -352,23 +352,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
}
}

pub fn provide(providers: &mut Providers) {
use rustc_codegen_ssa::target_features::{all_known_features, supported_target_features};
providers.supported_target_features = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
if tcx.sess.opts.actually_rustdoc {
// rustdoc needs to be able to document functions that use all the features, so
// provide them all.
all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
} else {
supported_target_features(tcx.sess).iter().map(|&(a, b)| (a.to_string(), b)).collect()
}
};

provide_extern(providers);
}

pub fn provide_extern(providers: &mut Providers) {
pub fn provide_both(providers: &mut Providers) {
providers.wasm_import_module_map = |tcx, cnum| {
// Build up a map from DefId to a `NativeLib` structure, where
// `NativeLib` internally contains information about
Expand Down
55 changes: 12 additions & 43 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig};
use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::ModuleCodegen;
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{ErrorReported, FatalError, Handler};
use rustc_middle::dep_graph::{DepGraph, WorkProduct};
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
use rustc_middle::ty::{self, TyCtxt};
use rustc_serialize::json;
use rustc_session::config::{self, OptLevel, OutputFilenames, PrintRequest};
use rustc_session::config::{OptLevel, OutputFilenames, PrintRequest};
use rustc_session::Session;
use rustc_span::symbol::Symbol;

use std::any::Any;
use std::ffi::CStr;
use std::fs;
use std::sync::Arc;

mod back {
Expand Down Expand Up @@ -249,11 +248,11 @@ impl CodegenBackend for LlvmCodegenBackend {
}

fn provide(&self, providers: &mut ty::query::Providers) {
attributes::provide(providers);
attributes::provide_both(providers);
}

fn provide_extern(&self, providers: &mut ty::query::Providers) {
attributes::provide_extern(providers);
attributes::provide_both(providers);
}

fn codegen_crate<'tcx>(
Expand All @@ -274,47 +273,27 @@ impl CodegenBackend for LlvmCodegenBackend {
&self,
ongoing_codegen: Box<dyn Any>,
sess: &Session,
dep_graph: &DepGraph,
) -> Result<Box<dyn Any>, ErrorReported> {
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
let (codegen_results, work_products) = ongoing_codegen
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
.join(sess);
if sess.opts.debugging_opts.incremental_info {
rustc_codegen_ssa::back::write::dump_incremental_data(&codegen_results);
}

sess.time("serialize_work_products", move || {
rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)
sess.time("llvm_dump_timing_file", || {
if sess.opts.debugging_opts.llvm_time_trace {
llvm_util::time_trace_profiler_finish("llvm_timings.json");
}
});

sess.compile_status()?;

Ok(Box::new(codegen_results))
Ok((codegen_results, work_products))
}

fn link(
&self,
sess: &Session,
codegen_results: Box<dyn Any>,
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) -> Result<(), ErrorReported> {
let codegen_results = codegen_results
.downcast::<CodegenResults>()
.expect("Expected CodegenResults, found Box<Any>");

if sess.opts.debugging_opts.no_link {
// FIXME: use a binary format to encode the `.rlink` file
let rlink_data = json::encode(&codegen_results).map_err(|err| {
sess.fatal(&format!("failed to encode rlink: {}", err));
})?;
let rlink_file = outputs.with_extension(config::RLINK_EXT);
fs::write(&rlink_file, rlink_data).map_err(|err| {
sess.fatal(&format!("failed to write file {}: {}", rlink_file.display(), err));
})?;
return Ok(());
}

// Run the linker on any artifacts that resulted from the LLVM run.
// This should produce either a finished executable or library.
sess.time("link_crate", || {
Expand All @@ -331,16 +310,6 @@ impl CodegenBackend for LlvmCodegenBackend {
);
});

// Now that we won't touch anything in the incremental compilation directory
// any more, we can finalize it (which involves renaming it)
rustc_incremental::finalize_session_directory(sess, codegen_results.crate_hash);

sess.time("llvm_dump_timing_file", || {
if sess.opts.debugging_opts.llvm_time_trace {
llvm_util::time_trace_profiler_finish("llvm_timings.json");
}
});

Ok(())
}
}
Expand Down
14 changes: 0 additions & 14 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::profiling::TimingGuard;
use rustc_data_structures::profiling::VerboseTimingGuard;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::Emitter;
use rustc_errors::{DiagnosticId, FatalError, Handler, Level};
Expand Down Expand Up @@ -414,7 +413,6 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
let sess = tcx.sess;

let crate_name = tcx.crate_name(LOCAL_CRATE);
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
let no_builtins = tcx.sess.contains_name(&tcx.hir().krate().item.attrs, sym::no_builtins);
let is_compiler_builtins =
tcx.sess.contains_name(&tcx.hir().krate().item.attrs, sym::compiler_builtins);
Expand Down Expand Up @@ -463,7 +461,6 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
OngoingCodegen {
backend,
crate_name,
crate_hash,
metadata,
windows_subsystem,
linker_info,
Expand Down Expand Up @@ -658,15 +655,6 @@ fn produce_final_output_artifacts(
// These are used in linking steps and will be cleaned up afterward.
}

pub fn dump_incremental_data(_codegen_results: &CodegenResults) {
// FIXME(mw): This does not work at the moment because the situation has
// become more complicated due to incremental LTO. Now a CGU
// can have more than two caching states.
// println!("[incremental] Re-using {} out of {} modules",
// codegen_results.modules.iter().filter(|m| m.pre_existing).count(),
// codegen_results.modules.len());
}

pub enum WorkItem<B: WriteBackendMethods> {
/// Optimize a newly codegened, totally unoptimized module.
Optimize(ModuleCodegen<B::Module>),
Expand Down Expand Up @@ -1720,7 +1708,6 @@ impl SharedEmitterMain {
pub struct OngoingCodegen<B: ExtraBackendMethods> {
pub backend: B,
pub crate_name: Symbol,
pub crate_hash: Svh,
pub metadata: EncodedMetadata,
pub windows_subsystem: Option<String>,
pub linker_info: LinkerInfo,
Expand Down Expand Up @@ -1766,7 +1753,6 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
(
CodegenResults {
crate_name: self.crate_name,
crate_hash: self.crate_hash,
metadata: self.metadata,
windows_subsystem: self.windows_subsystem,
linker_info: self.linker_info,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern crate tracing;
extern crate rustc_middle;

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::Lrc;
use rustc_hir::def_id::CrateNum;
use rustc_hir::LangItem;
Expand Down Expand Up @@ -134,7 +133,6 @@ pub struct CodegenResults {
pub modules: Vec<CompiledModule>,
pub allocator_module: Option<CompiledModule>,
pub metadata_module: Option<CompiledModule>,
pub crate_hash: Svh,
pub metadata: rustc_middle::middle::cstore::EncodedMetadata,
pub windows_subsystem: Option<String>,
pub linker_info: back::linker::LinkerInfo,
Expand All @@ -144,6 +142,7 @@ pub struct CodegenResults {
pub fn provide(providers: &mut Providers) {
crate::back::symbol_export::provide(providers);
crate::base::provide_both(providers);
crate::target_features::provide(providers);
}

pub fn provide_extern(providers: &mut Providers) {
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::ty::query::Providers;
use rustc_session::Session;
use rustc_span::symbol::sym;
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -148,3 +150,16 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
_ => &[],
}
}

pub(crate) fn provide(providers: &mut Providers) {
providers.supported_target_features = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
if tcx.sess.opts.actually_rustdoc {
// rustdoc needs to be able to document functions that use all the features, so
// whitelist them all
all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
} else {
supported_target_features(tcx.sess).iter().map(|&(a, b)| (a.to_string(), b)).collect()
}
};
}
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use super::write::WriteBackendMethods;
use super::CodegenObject;
use crate::ModuleCodegen;
use crate::{CodegenResults, ModuleCodegen};

use rustc_ast::expand::allocator::AllocatorKind;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorReported;
use rustc_middle::dep_graph::DepGraph;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
use rustc_middle::ty::query::Providers;
Expand Down Expand Up @@ -80,8 +81,7 @@ pub trait CodegenBackend {
&self,
ongoing_codegen: Box<dyn Any>,
sess: &Session,
dep_graph: &DepGraph,
) -> Result<Box<dyn Any>, ErrorReported>;
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported>;

/// This is called on the returned `Box<dyn Any>` from `join_codegen`
///
Expand All @@ -91,7 +91,7 @@ pub trait CodegenBackend {
fn link(
&self,
sess: &Session,
codegen_results: Box<dyn Any>,
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) -> Result<(), ErrorReported>;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl RustcDefaultCalls {
let codegen_results: CodegenResults = json::decode(&rlink_data).unwrap_or_else(|err| {
sess.fatal(&format!("failed to decode rlink: {}", err));
});
compiler.codegen_backend().link(&sess, Box::new(codegen_results), &outputs)
compiler.codegen_backend().link(&sess, codegen_results, &outputs)
} else {
sess.fatal("rlink must be a file")
}
Expand Down
38 changes: 34 additions & 4 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::passes::{self, BoxedResolver, QueryContext};

use rustc_ast as ast;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_errors::ErrorReported;
use rustc_hir::def_id::LOCAL_CRATE;
Expand All @@ -13,7 +14,8 @@ use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::DepGraph;
use rustc_middle::ty::steal::Steal;
use rustc_middle::ty::{GlobalCtxt, ResolverOutputs, TyCtxt};
use rustc_session::config::{OutputFilenames, OutputType};
use rustc_serialize::json;
use rustc_session::config::{self, OutputFilenames, OutputType};
use rustc_session::{output::find_crate_name, Session};
use rustc_span::symbol::sym;
use std::any::Any;
Expand Down Expand Up @@ -331,6 +333,7 @@ impl<'tcx> Queries<'tcx> {
pub fn linker(&'tcx self) -> Result<Linker> {
let dep_graph = self.dep_graph()?;
let prepare_outputs = self.prepare_outputs()?;
let crate_hash = self.global_ctxt()?.peek_mut().enter(|tcx| tcx.crate_hash(LOCAL_CRATE));
let ongoing_codegen = self.ongoing_codegen()?;

let sess = self.session().clone();
Expand All @@ -340,6 +343,7 @@ impl<'tcx> Queries<'tcx> {
sess,
dep_graph: dep_graph.peek().clone(),
prepare_outputs: prepare_outputs.take(),
crate_hash,
ongoing_codegen: ongoing_codegen.take(),
codegen_backend,
})
Expand All @@ -350,18 +354,31 @@ pub struct Linker {
sess: Lrc<Session>,
dep_graph: DepGraph,
prepare_outputs: OutputFilenames,
crate_hash: Svh,
ongoing_codegen: Box<dyn Any>,
codegen_backend: Lrc<Box<dyn CodegenBackend>>,
}

impl Linker {
pub fn link(self) -> Result<()> {
let codegen_results =
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess, &self.dep_graph)?;
let prof = self.sess.prof.clone();
let (codegen_results, work_products) =
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess)?;

self.sess.compile_status()?;

let sess = &self.sess;
let dep_graph = self.dep_graph;
sess.time("serialize_work_products", || {
rustc_incremental::save_work_product_index(&sess, &dep_graph, work_products)
});

let prof = self.sess.prof.clone();
prof.generic_activity("drop_dep_graph").run(move || drop(dep_graph));

// Now that we won't touch anything in the incremental compilation directory
// any more, we can finalize it (which involves renaming it)
rustc_incremental::finalize_session_directory(&self.sess, self.crate_hash);

if !self
.sess
.opts
Expand All @@ -371,6 +388,19 @@ impl Linker {
{
return Ok(());
}

if sess.opts.debugging_opts.no_link {
// FIXME: use a binary format to encode the `.rlink` file
let rlink_data = json::encode(&codegen_results).map_err(|err| {
sess.fatal(&format!("failed to encode rlink: {}", err));
})?;
let rlink_file = self.prepare_outputs.with_extension(config::RLINK_EXT);
std::fs::write(&rlink_file, rlink_data).map_err(|err| {
sess.fatal(&format!("failed to write file {}: {}", rlink_file.display(), err));
})?;
return Ok(());
}

self.codegen_backend.link(&self.sess, codegen_results, &self.prepare_outputs)
}
}
Expand Down
Loading