From f770d563321c2a74bc8f0b34436242e0c111cd01 Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Tue, 26 Nov 2024 22:58:19 +1000 Subject: [PATCH] Fix msvc stdout not shown on error (#1303) * Fix msvc stdout not shown on error Fixed #1260 * Fix clippy lint * Call disable_localization unconditionally * Call disable_localization in try_get_compiler` * Set localization env based on msvc * Fix setting env * Fix fmt * Fix confusing wording in comment --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 187eb705..da1b91be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1950,6 +1950,19 @@ impl Build { cmd.push_cc_arg(warnings_to_errors_flag); } + // Copied from + // + // Disables non-English messages from localized linkers. + // Such messages may cause issues with text encoding on Windows + // and prevent inspection of msvc output in case of errors, which we occasionally do. + // This should be acceptable because other messages from rustc are in English anyway, + // and may also be desirable to improve searchability of the compiler diagnostics. + if matches!(cmd.family, ToolFamily::Msvc { clang_cl: false }) { + cmd.env.push(("VSLANG".into(), "1033".into())); + } else { + cmd.env.push(("LC_ALL".into(), "C".into())); + } + Ok(cmd) }