Skip to content

Commit 23beda4

Browse files
authored
Rollup merge of #108581 - jfgoog:include-mingw-linker, r=petrochenkov
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.
2 parents 14260c8 + 848f6f9 commit 23beda4

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
@@ -659,6 +659,10 @@ changelog-seen = 2
659659
# Build compiler with the optimization enabled and -Zvalidate-mir, currently only for `std`
660660
#validate-mir-opts = 3
661661

662+
# Copy the linker, DLLs, and various libraries from MinGW into the rustc toolchain.
663+
# Only applies when the host or target is pc-windows-gnu.
664+
#include-mingw-linker = true
665+
662666
# =============================================================================
663667
# Options for specific targets
664668
#

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ pub struct Config {
190190
pub dist_sign_folder: Option<PathBuf>,
191191
pub dist_upload_addr: Option<String>,
192192
pub dist_compression_formats: Option<Vec<String>>,
193+
pub dist_include_mingw_linker: bool,
193194

194195
// libstd features
195196
pub backtrace: bool, // support for RUST_BACKTRACE
@@ -700,6 +701,7 @@ define_config! {
700701
src_tarball: Option<bool> = "src-tarball",
701702
missing_tools: Option<bool> = "missing-tools",
702703
compression_formats: Option<Vec<String>> = "compression-formats",
704+
include_mingw_linker: Option<bool> = "include-mingw-linker",
703705
}
704706
}
705707

@@ -816,6 +818,7 @@ impl Config {
816818
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
817819
config.deny_warnings = true;
818820
config.bindir = "bin".into();
821+
config.dist_include_mingw_linker = true;
819822

820823
// set by build.rs
821824
config.build = TargetSelection::from_user(&env!("BUILD_TRIPLE"));
@@ -1299,6 +1302,7 @@ impl Config {
12991302
config.dist_compression_formats = t.compression_formats;
13001303
set(&mut config.rust_dist_src, t.src_tarball);
13011304
set(&mut config.missing_tools, t.missing_tools);
1305+
set(&mut config.dist_include_mingw_linker, t.include_mingw_linker)
13021306
}
13031307

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

src/bootstrap/dist.rs

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

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

0 commit comments

Comments
 (0)