mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
1. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
This commit is contained in:
parent
370c91100c
commit
dabedb711f
@ -52,7 +52,7 @@ fn default_client() -> Client {
|
||||
|
||||
static GLOBAL_CLIENT_CHECKED: OnceLock<Client> = OnceLock::new();
|
||||
|
||||
pub fn check(report_warning: impl FnOnce(&'static str)) {
|
||||
pub fn initialize_checked(report_warning: impl FnOnce(&'static str)) {
|
||||
let client_checked = match &*GLOBAL_CLIENT {
|
||||
Ok(client) => client.clone(),
|
||||
Err(e) => {
|
||||
|
@ -316,6 +316,10 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||
// Set parallel mode before thread pool creation, which will create `Lock`s.
|
||||
rustc_data_structures::sync::set_dyn_thread_safe_mode(config.opts.unstable_opts.threads > 1);
|
||||
|
||||
// Check jobserver before run_in_thread_pool_with_globals, which call jobserver::acquire_thread
|
||||
let early_handler = EarlyErrorHandler::new(config.opts.error_format);
|
||||
early_handler.initialize_checked_jobserver();
|
||||
|
||||
util::run_in_thread_pool_with_globals(
|
||||
config.opts.edition,
|
||||
config.opts.unstable_opts.threads,
|
||||
|
@ -27,6 +27,8 @@ use std::sync::Arc;
|
||||
|
||||
fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
|
||||
let mut early_handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
early_handler.initialize_checked_jobserver();
|
||||
|
||||
let registry = registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&mut early_handler, &matches);
|
||||
let temps_dir = sessopts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
|
||||
|
@ -1474,17 +1474,6 @@ pub fn build_session(
|
||||
let asm_arch =
|
||||
if target_cfg.allow_asm { InlineAsmArch::from_str(&target_cfg.arch).ok() } else { None };
|
||||
|
||||
// Check jobserver before getting `jobserver::client`.
|
||||
jobserver::check(|err| {
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
parse_sess
|
||||
.span_diagnostic
|
||||
.struct_warn(err)
|
||||
.note("the build environment is likely misconfigured")
|
||||
.emit()
|
||||
});
|
||||
|
||||
let sess = Session {
|
||||
target: target_cfg,
|
||||
host,
|
||||
@ -1792,6 +1781,18 @@ impl EarlyErrorHandler {
|
||||
pub fn early_warn(&self, msg: impl Into<DiagnosticMessage>) {
|
||||
self.handler.struct_warn(msg).emit()
|
||||
}
|
||||
|
||||
pub fn initialize_checked_jobserver(&self) {
|
||||
// initialize jobserver before getting `jobserver::client` and `build_session`.
|
||||
jobserver::initialize_checked(|err| {
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
self.handler
|
||||
.struct_warn(err)
|
||||
.note("the build environment is likely misconfigured")
|
||||
.emit()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
|
||||
|
@ -4,5 +4,3 @@ warning: failed to connect to jobserver from environment variable `MAKEFLAGS="--
|
||||
|
||||
error: no input filename given
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
@ -2,5 +2,3 @@ warning: failed to connect to jobserver from environment variable `MAKEFLAGS="--
|
||||
|
|
||||
= note: the build environment is likely misconfigured
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user