about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorbelovdv <70999565+belovdv@users.noreply.github.com>2023-07-15 18:48:09 +0300
committerbelovdv <70999565+belovdv@users.noreply.github.com>2023-11-29 18:00:03 +0300
commit45e634234690a7d061e133b8cf9d31af34b29a0b (patch)
treed29eeeb405b6a139d4ad0d9d79fd94e81bd36e8b /compiler/rustc_session/src
parentce4727f723144aea42d66c09a0a7e75f8c51b8fd (diff)
downloadrust-45e634234690a7d061e133b8cf9d31af34b29a0b.tar.gz
rust-45e634234690a7d061e133b8cf9d31af34b29a0b.zip
jobserver: check file descriptors
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/session.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 20a67d6d036..515b412315f 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -26,7 +26,7 @@ use rustc_errors::registry::Registry;
 use rustc_errors::{
     error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
     ErrorGuaranteed, FluentBundle, Handler, IntoDiagnostic, LazyFallbackBundle, MultiSpan, Noted,
-    TerminalUrl,
+    SubdiagnosticMessage, TerminalUrl,
 };
 use rustc_macros::HashStable_Generic;
 pub use rustc_span::def_id::StableCrateId;
@@ -1479,6 +1479,11 @@ 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| {
+        handler.early_warn_with_note(err, "the build environment is likely misconfigured")
+    });
+
     let sess = Session {
         target: target_cfg,
         host,
@@ -1762,6 +1767,16 @@ impl EarlyErrorHandler {
     pub fn early_warn(&self, msg: impl Into<DiagnosticMessage>) {
         self.handler.struct_warn(msg).emit()
     }
+
+    #[allow(rustc::untranslatable_diagnostic)]
+    #[allow(rustc::diagnostic_outside_of_impl)]
+    pub fn early_warn_with_note(
+        &self,
+        msg: impl Into<DiagnosticMessage>,
+        note: impl Into<SubdiagnosticMessage>,
+    ) {
+        self.handler.struct_warn(msg).note(note).emit()
+    }
 }
 
 fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {