From e9474927b7cbb5683f3c5c22e4d06f88337b4a2f Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 27 Jan 2026 14:47:34 +0000 Subject: [PATCH 1/5] Remove -Alinker-messages This lint is allowed by default nowadays. --- src/bootstrap/src/core/builder/cargo.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 7150b2b0d59f2..6849450b391e9 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -331,10 +331,6 @@ impl Cargo { self.rustflags.arg("-Clink-arg=-gz"); } - // Ignore linker warnings for now. These are complicated to fix and don't affect the build. - // FIXME: we should really investigate these... - self.rustflags.arg("-Alinker-messages"); - // Throughout the build Cargo can execute a number of build scripts // compiling C/C++ code and we need to pass compilers, archivers, flags, etc // obtained previously to those build scripts. From 3f62540a797cd33617b8b098e90016b004e36899 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 27 Jan 2026 14:58:24 +0000 Subject: [PATCH 2/5] Only set CFG_COMPILER_HOST_TRIPLE when building rustc --- src/bootstrap/src/core/build_steps/compile.rs | 3 +++ src/bootstrap/src/core/builder/cargo.rs | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 405ab9f6eaa2d..adba8f19894a8 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1378,6 +1378,9 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } } + // The host this new compiler will *run* on. + cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple); + if builder.config.rust_verify_llvm_ir { cargo.env("RUSTC_VERIFY_LLVM_IR", "1"); } diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 6849450b391e9..130159111e7e5 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1288,8 +1288,6 @@ impl Builder<'_> { // // FIXME: should update code to not require this env var - // The host this new compiler will *run* on. - cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple); // The host this new compiler is being *built* on. cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple); From 1331517a47396255c2a7c11efb531fa5d0c4f7c0 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 27 Jan 2026 15:03:43 +0000 Subject: [PATCH 3/5] Unset WINAPI_NO_BUNDLED_LIBRARIES Rustc no longer depends on winapi. Only cg_clif, cg_gcc and rustfmt still use it, none of which are libraries to compile against. And in case of both cg_clif and cg_gcc it never ends up in an artifact we ship. For cg_clif it only shows up when the jit mode is enabled, which is not the case for the version we ship. For cg_gcc it is used by a test executable, which isn't shipped either. --- src/bootstrap/src/core/builder/cargo.rs | 35 ------------------------- 1 file changed, 35 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 130159111e7e5..567fb44113d89 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1294,41 +1294,6 @@ impl Builder<'_> { // Set this for all builds to make sure doc builds also get it. cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel); - // This one's a bit tricky. As of the time of this writing the compiler - // links to the `winapi` crate on crates.io. This crate provides raw - // bindings to Windows system functions, sort of like libc does for - // Unix. This crate also, however, provides "import libraries" for the - // MinGW targets. There's an import library per dll in the windows - // distribution which is what's linked to. These custom import libraries - // are used because the winapi crate can reference Windows functions not - // present in the MinGW import libraries. - // - // For example MinGW may ship libdbghelp.a, but it may not have - // references to all the functions in the dbghelp dll. Instead the - // custom import library for dbghelp in the winapi crates has all this - // information. - // - // Unfortunately for us though the import libraries are linked by - // default via `-ldylib=winapi_foo`. That is, they're linked with the - // `dylib` type with a `winapi_` prefix (so the winapi ones don't - // conflict with the system MinGW ones). This consequently means that - // the binaries we ship of things like rustc_codegen_llvm (aka the rustc_codegen_llvm - // DLL) when linked against *again*, for example with procedural macros - // or plugins, will trigger the propagation logic of `-ldylib`, passing - // `-lwinapi_foo` to the linker again. This isn't actually available in - // our distribution, however, so the link fails. - // - // To solve this problem we tell winapi to not use its bundled import - // libraries. This means that it will link to the system MinGW import - // libraries by default, and the `-ldylib=foo` directives will still get - // passed to the final linker, but they'll look like `-lfoo` which can - // be resolved because MinGW has the import library. The downside is we - // don't get newer functions from Windows, but we don't use any of them - // anyway. - if !mode.is_tool() { - cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1"); - } - // verbose cargo output is very noisy, so only enable it with -vv for _ in 0..self.verbosity.saturating_sub(1) { cargo.arg("--verbose"); From be639943a0665c4ad49993c8b52b8341be8f6bdd Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 27 Jan 2026 15:06:31 +0000 Subject: [PATCH 4/5] Remove a couple of unnecessary stage checks These flags should be available on the bootstrap compiler. --- src/bootstrap/src/core/builder/cargo.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 567fb44113d89..262bb7fc6b799 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1252,13 +1252,7 @@ impl Builder<'_> { // when compiling the standard library, since this might be linked into the final outputs // produced by rustc. Since this mitigation is only available on Windows, only enable it // for the standard library in case the compiler is run on a non-Windows platform. - // This is not needed for stage 0 artifacts because these will only be used for building - // the stage 1 compiler. - if cfg!(windows) - && mode == Mode::Std - && self.config.control_flow_guard - && compiler.stage >= 1 - { + if cfg!(windows) && mode == Mode::Std && self.config.control_flow_guard { rustflags.arg("-Ccontrol-flow-guard"); } @@ -1266,9 +1260,7 @@ impl Builder<'_> { // standard library, since this might be linked into the final outputs produced by rustc. // Since this mitigation is only available on Windows, only enable it for the standard // library in case the compiler is run on a non-Windows platform. - // This is not needed for stage 0 artifacts because these will only be used for building - // the stage 1 compiler. - if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard && compiler.stage >= 1 { + if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard { rustflags.arg("-Zehcont-guard"); } From 257ea3bbee8d2a4d3cc9346863606d86560e06de Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 27 Jan 2026 15:32:06 +0000 Subject: [PATCH 5/5] Remove outdated fixme --- src/bootstrap/src/core/builder/cargo.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 262bb7fc6b799..42502e1b14514 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1277,8 +1277,6 @@ impl Builder<'_> { rustdocflags.arg("--crate-version").arg(&rust_version); // Environment variables *required* throughout the build - // - // FIXME: should update code to not require this env var // The host this new compiler is being *built* on. cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple);