Skip to content

Commit 848f6f9

Browse files
committed
Add a new config flag, dist.include-mingw-linker.
The flag controls whether to copy the linker, DLLs, and various libraries from MinGW into the rustc toolchain. It applies only when the host or target is pc-windows-gnu. The flag is true by default to preserve existing behavior.
1 parent 31f858d commit 848f6f9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@ changelog-seen = 2
669669
# Build compiler with the optimization enabled and -Zvalidate-mir, currently only for `std`
670670
#validate-mir-opts = 3
671671

672+
# Copy the linker, DLLs, and various libraries from MinGW into the rustc toolchain.
673+
# Only applies when the host or target is pc-windows-gnu.
674+
#include-mingw-linker = true
675+
672676
# =============================================================================
673677
# Options for specific targets
674678
#

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ pub struct Config {
192192
pub dist_sign_folder: Option<PathBuf>,
193193
pub dist_upload_addr: Option<String>,
194194
pub dist_compression_formats: Option<Vec<String>>,
195+
pub dist_include_mingw_linker: bool,
195196

196197
// libstd features
197198
pub backtrace: bool, // support for RUST_BACKTRACE
@@ -704,6 +705,7 @@ define_config! {
704705
src_tarball: Option<bool> = "src-tarball",
705706
missing_tools: Option<bool> = "missing-tools",
706707
compression_formats: Option<Vec<String>> = "compression-formats",
708+
include_mingw_linker: Option<bool> = "include-mingw-linker",
707709
}
708710
}
709711

@@ -821,6 +823,7 @@ impl Config {
821823
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
822824
config.deny_warnings = true;
823825
config.bindir = "bin".into();
826+
config.dist_include_mingw_linker = true;
824827

825828
// set by build.rs
826829
config.build = TargetSelection::from_user(&env!("BUILD_TRIPLE"));
@@ -1311,6 +1314,7 @@ impl Config {
13111314
config.dist_compression_formats = t.compression_formats;
13121315
set(&mut config.rust_dist_src, t.src_tarball);
13131316
set(&mut config.missing_tools, t.missing_tools);
1317+
set(&mut config.dist_include_mingw_linker, t.include_mingw_linker)
13141318
}
13151319

13161320
if let Some(r) = build.rustfmt {

src/bootstrap/dist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl Step for Mingw {
322322
/// without any extra installed software (e.g., we bundle gcc, libraries, etc).
323323
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
324324
let host = self.host;
325-
if !host.ends_with("pc-windows-gnu") {
325+
if !host.ends_with("pc-windows-gnu") || !builder.config.dist_include_mingw_linker {
326326
return None;
327327
}
328328

@@ -378,7 +378,7 @@ impl Step for Rustc {
378378
// anything requiring us to distribute a license, but it's likely the
379379
// install will *also* include the rust-mingw package, which also needs
380380
// licenses, so to be safe we just include it here in all MinGW packages.
381-
if host.ends_with("pc-windows-gnu") {
381+
if host.ends_with("pc-windows-gnu") && builder.config.dist_include_mingw_linker {
382382
make_win_dist(tarball.image_dir(), &tmpdir(builder), host, builder);
383383
tarball.add_dir(builder.src.join("src/etc/third-party"), "share/doc");
384384
}

0 commit comments

Comments
 (0)