Skip to content

Rollup of 8 pull requests #101941

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

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
44506f3
add note for `layout_of` when query depth overflows
SparrowLii Sep 14, 2022
89fd6ae
correct span, add help message and add UI test when query depth overf…
SparrowLii Sep 15, 2022
9286c3c
Update stdarch
wesleywiser Sep 15, 2022
532e3a5
Allow building `rust-analyzer-proc-macro-srv` as a standalone tool
WaffleLapkin Sep 15, 2022
9c3c88c
Use `builder.sysroot(...)` instead of a hack
WaffleLapkin Sep 16, 2022
ccd4383
Add a new component, `rust-json-docs`, to distribute the JSON-formatt…
Sep 14, 2022
1c65997
Create new CSS variables for links color
GuillaumeGomez Sep 16, 2022
5d449a0
Add GUI test for links colors
GuillaumeGomez Sep 16, 2022
9995029
Remove the allow-list for dynamic linking of LLVM tools
chriswailes Sep 13, 2022
b72de9b
rustdoc: clean up CSS for All Items and All Crates lists
notriddle Sep 16, 2022
a87a883
rustdoc: update test case for All Crates page
notriddle Sep 16, 2022
d1291dc
Improve handing of env vars during bootstrap process
chriswailes Sep 13, 2022
cd1802f
Rollup merge of #101781 - chriswailes:dynamic-llvm-on-musl, r=jyn514
matthiaskrgr Sep 17, 2022
32ddc71
Rollup merge of #101783 - chriswailes:env-vars, r=jyn514
matthiaskrgr Sep 17, 2022
9a6aad4
Rollup merge of #101799 - LukeMathWalker:distribute-json-doc, r=jyn514
matthiaskrgr Sep 17, 2022
8b5217e
Rollup merge of #101801 - SparrowLii:query_depth_note, r=estebank
matthiaskrgr Sep 17, 2022
b871940
Rollup merge of #101861 - wesleywiser:update_stdarch, r=Amanieu
matthiaskrgr Sep 17, 2022
647f67f
Rollup merge of #101873 - WaffleLapkin:x-build-proc-macro-srv, r=jyn514
matthiaskrgr Sep 17, 2022
16823e2
Rollup merge of #101918 - notriddle:notriddle/all, r=GuillaumeGomez
matthiaskrgr Sep 17, 2022
0840044
Rollup merge of #101934 - GuillaumeGomez:theme-links-cleanup, r=notri…
matthiaskrgr Sep 17, 2022
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
8 changes: 6 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
]

[[package]]
name = "chalk-derive"
Expand Down Expand Up @@ -4613,7 +4617,7 @@ version = "0.0.0"
dependencies = [
"addr2line 0.16.0",
"alloc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"compiler_builtins",
"core",
"dlmalloc",
Expand All @@ -4637,7 +4641,7 @@ dependencies = [
name = "std_detect"
version = "0.1.5"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"compiler_builtins",
"libc",
"rustc-std-workspace-alloc",
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/query_system.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ query_system_cycle_recursive_trait_alias = trait aliases cannot be recursive
query_system_cycle_which_requires = ...which requires {$desc}...

query_system_query_overflow = queries overflow the depth limit!
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)

query_system_layout_of_depth = query depth increased by {$depth} when {$desc}
29 changes: 27 additions & 2 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ use rustc_query_system::query::{
force_query, QueryConfig, QueryContext, QueryDescription, QueryJobId, QueryMap,
QuerySideEffects, QueryStackFrame,
};
use rustc_query_system::Value;
use rustc_query_system::{LayoutOfDepth, QueryOverflow, Value};
use rustc_serialize::Decodable;
use rustc_session::Limit;
use rustc_span::def_id::LOCAL_CRATE;
use std::any::Any;
use std::num::NonZeroU64;
use thin_vec::ThinVec;
Expand Down Expand Up @@ -109,7 +111,7 @@ impl QueryContext for QueryCtxt<'_> {
// when accessing the `ImplicitCtxt`.
tls::with_related_context(**self, move |current_icx| {
if depth_limit && !self.recursion_limit().value_within_limit(current_icx.query_depth) {
self.depth_limit_error();
self.depth_limit_error(token);
}

// Update the `ImplicitCtxt` to point to our new query job.
Expand All @@ -127,6 +129,29 @@ impl QueryContext for QueryCtxt<'_> {
})
})
}

fn depth_limit_error(&self, job: QueryJobId) {
let mut span = None;
let mut layout_of_depth = None;
if let Some(map) = self.try_collect_active_jobs() {
if let Some((info, depth)) = job.try_find_layout_root(map) {
span = Some(info.job.span);
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
}
}

let suggested_limit = match self.recursion_limit() {
Limit(0) => Limit(2),
limit => limit * 2,
};

self.sess.emit_fatal(QueryOverflow {
span,
layout_of_depth,
suggested_limit,
crate_name: self.crate_name(LOCAL_CRATE),
});
}
}

impl<'tcx> QueryCtxt<'tcx> {
Expand Down
20 changes: 18 additions & 2 deletions compiler/rustc_query_system/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rustc_errors::AddSubdiagnostic;
use rustc_span::Span;
use rustc_session::Limit;
use rustc_span::{Span, Symbol};

pub struct CycleStack {
pub span: Span,
Expand Down Expand Up @@ -76,5 +77,20 @@ pub struct IncrementCompilation {
}

#[derive(SessionDiagnostic)]
#[help]
#[diag(query_system::query_overflow)]
pub struct QueryOverflow;
pub struct QueryOverflow {
#[primary_span]
pub span: Option<Span>,
#[subdiagnostic]
pub layout_of_depth: Option<LayoutOfDepth>,
pub suggested_limit: Limit,
pub crate_name: Symbol,
}

#[derive(SessionSubdiagnostic)]
#[note(query_system::layout_of_depth)]
pub struct LayoutOfDepth {
pub desc: String,
pub depth: usize,
}
2 changes: 2 additions & 0 deletions compiler/rustc_query_system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ pub mod query;
mod values;

pub use error::HandleCycleError;
pub use error::LayoutOfDepth;
pub use error::QueryOverflow;
pub use values::Value;
21 changes: 20 additions & 1 deletion compiler/rustc_query_system/src/query/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl QueryJobId {
}
}

#[derive(Clone)]
pub struct QueryJobInfo {
pub query: QueryStackFrame,
pub job: QueryJob,
Expand Down Expand Up @@ -116,10 +117,10 @@ impl QueryJob {
}
}

#[cfg(not(parallel_compiler))]
impl QueryJobId {
#[cold]
#[inline(never)]
#[cfg(not(parallel_compiler))]
pub(super) fn find_cycle_in_stack(
&self,
query_map: QueryMap,
Expand Down Expand Up @@ -156,6 +157,24 @@ impl QueryJobId {

panic!("did not find a cycle")
}

#[cold]
#[inline(never)]
pub fn try_find_layout_root(&self, query_map: QueryMap) -> Option<(QueryJobInfo, usize)> {
let mut last_layout = None;
let mut current_id = Some(*self);
let mut depth = 0;

while let Some(id) = current_id {
let info = query_map.get(&id).unwrap();
if info.query.name == "layout_of" {
depth += 1;
last_layout = Some((info.clone(), depth));
}
current_id = info.job.parent;
}
last_layout
}
}

#[cfg(parallel_compiler)]
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_query_system/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use self::caches::{
mod config;
pub use self::config::{QueryConfig, QueryDescription, QueryVTable};

use crate::dep_graph::{DepContext, DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
use rustc_data_structures::sync::Lock;
use rustc_errors::Diagnostic;
use rustc_hir::def::DefKind;
Expand Down Expand Up @@ -123,7 +123,5 @@ pub trait QueryContext: HasDepContext {
compute: impl FnOnce() -> R,
) -> R;

fn depth_limit_error(&self) {
self.dep_context().sess().emit_fatal(crate::error::QueryOverflow);
}
fn depth_limit_error(&self, job: QueryJobId);
}
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["dylib", "rlib"]

[dependencies]
alloc = { path = "../alloc" }
cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
Expand Down
15 changes: 11 additions & 4 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,19 +732,26 @@ def build_bootstrap(self, color):
(os.pathsep + env["LIBRARY_PATH"]) \
if "LIBRARY_PATH" in env else ""

# Export Stage0 snapshot compiler related env variables
build_section = "target.{}".format(self.build)
host_triple_sanitized = self.build.replace("-", "_")
var_data = {
"CC": "cc", "CXX": "cxx", "LD": "linker", "AR": "ar", "RANLIB": "ranlib"
}
for var_name, toml_key in var_data.items():
toml_val = self.get_toml(toml_key, build_section)
if toml_val != None:
env["{}_{}".format(var_name, host_triple_sanitized)] = toml_val

# preserve existing RUSTFLAGS
env.setdefault("RUSTFLAGS", "")
build_section = "target.{}".format(self.build)
target_features = []
if self.get_toml("crt-static", build_section) == "true":
target_features += ["+crt-static"]
elif self.get_toml("crt-static", build_section) == "false":
target_features += ["-crt-static"]
if target_features:
env["RUSTFLAGS"] += " -C target-feature=" + (",".join(target_features))
target_linker = self.get_toml("linker", build_section)
if target_linker is not None:
env["RUSTFLAGS"] += " -C linker=" + target_linker
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
env["RUSTFLAGS"] += " -Wsemicolon_in_expressions_from_macros"
if self.get_toml("deny-warnings", "rust") != "false":
Expand Down
14 changes: 8 additions & 6 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ impl<'a> Builder<'a> {
Kind::Dist => describe!(
dist::Docs,
dist::RustcDocs,
dist::JsonDocs,
dist::Mingw,
dist::Rustc,
dist::Std,
Expand Down Expand Up @@ -1940,25 +1941,26 @@ impl<'a> Builder<'a> {
_ => s.display().to_string(),
}
};
let triple_underscored = target.triple.replace("-", "_");
let cc = ccacheify(&self.cc(target));
cargo.env(format!("CC_{}", target.triple), &cc);
cargo.env(format!("CC_{}", triple_underscored), &cc);

let cflags = self.cflags(target, GitRepo::Rustc, CLang::C).join(" ");
cargo.env(format!("CFLAGS_{}", target.triple), &cflags);
cargo.env(format!("CFLAGS_{}", triple_underscored), &cflags);

if let Some(ar) = self.ar(target) {
let ranlib = format!("{} s", ar.display());
cargo
.env(format!("AR_{}", target.triple), ar)
.env(format!("RANLIB_{}", target.triple), ranlib);
.env(format!("AR_{}", triple_underscored), ar)
.env(format!("RANLIB_{}", triple_underscored), ranlib);
}

if let Ok(cxx) = self.cxx(target) {
let cxx = ccacheify(&cxx);
let cxxflags = self.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" ");
cargo
.env(format!("CXX_{}", target.triple), &cxx)
.env(format!("CXXFLAGS_{}", target.triple), cxxflags);
.env(format!("CXX_{}", triple_underscored), &cxx)
.env(format!("CXXFLAGS_{}", triple_underscored), cxxflags);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ mod defaults {
fn doc_default() {
let mut config = configure("doc", &["A"], &["A"]);
config.compiler_docs = true;
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false };
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false, json: false };
let mut cache = run_build(&[], config);
let a = TargetSelection::from_user("A");

Expand Down Expand Up @@ -587,7 +587,7 @@ mod dist {
fn doc_ci() {
let mut config = configure(&["A"], &["A"]);
config.compiler_docs = true;
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false };
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false, json: false };
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), &[]);
Expand Down
39 changes: 39 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,45 @@ impl Step for Docs {
}
}

#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct JsonDocs {
pub host: TargetSelection,
}

impl Step for JsonDocs {
type Output = Option<GeneratedTarball>;
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let default = run.builder.config.docs;
run.alias("rust-json-docs").default_condition(default)
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(JsonDocs { host: run.target });
}

/// Builds the `rust-json-docs` installer component.
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
// This prevents JSON docs from being built for "dist" or "install"
// on the stable/beta channels. The JSON format is not stable yet and
// should not be included in stable/beta toolchains.
if !builder.build.unstable_features() {
return None;
}

let host = self.host;
builder.ensure(crate::doc::JsonStd { stage: builder.top_stage, target: host });

let dest = "share/doc/rust/json";

let mut tarball = Tarball::new(builder, "rust-json-docs", &host.triple);
tarball.set_product_name("Rust Documentation In JSON Format");
tarball.add_bulk_dir(&builder.json_doc_out(host), dest);
Some(tarball.generate())
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustcDocs {
pub host: TargetSelection,
Expand Down
Loading