Skip to content

Move mingw-w64 CRT objects to rust-mingw component - #163942

Draft
mati865 wants to merge 1 commit into
rust-lang:mainfrom
mati865:push-trqwsuqnokls
Draft

mati865 wants to merge 1 commit into
rust-lang:mainfrom
mati865:push-trqwsuqnokls

Conversation

@mati865

@mati865 mati865 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Since mingw-w64 objects must match mingw-w64 versions, it's better to ship them within a single component.
Previously, when rust-mingw was not installed and -Clink-self-contained was used, this (depending on how mismatched are the components) could cause problems: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Making.20rust-mingw.20component.20more.20rational/near/615203696

There are two ways to address that issue:

  • move mingw-w64 libs from rust-mingw component to rust-std (like we already do with Musl)
  • move mingw-w64 objects from rust-std component to rust-mingw

Based on the feedback in Zulip discussion mentioned above, this PR implements the second solution.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 7, 2026
@mati865

mati865 commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-x86_64-*mingw,

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
Move mingw-w64 CRT objects to rust-mingw component


try-job: dist-x86_64-*mingw
try-job:
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a0138eb (a0138eb7ce9d6c33110a82e4dbb409c8680846c2)
Base parent: 42cfc04 (42cfc04deaa723bc21611f3f9d7c8651be6300df)

@mati865

mati865 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

With this change self-contained mode will always fail outright if rust-mingw is not installed (basically available only on the host toolchains):

$ cargo +a0138eb7ce9d6c33110a82e4dbb409c8680846c2 rustc -- -Clink-self-contained
   Compiling hello v0.1.0 (C:\msys64\home\root\hello)
    Building [                             ] 0/1: hello(bin)
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "crt2.o" "C:\\msys64\\home\\root\\hello\\
target\\debug\\build\\hello/e7dee8bc15a2c771\\out\\rustcaXcR7u\\symbols.o" "<7 object files omitted>" "-Wl,-Bstatic" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib/{libstd-*,libpanic_unwind-*,libobject-*,
libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,libwindows_link-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_
std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-ldbghelp" "-lsynchronization" "-lgcc_eh" "-l:libpthread.a" "-
lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmingwex" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-nostartfiles" "-L" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained" "-o" "C:\\msys
64\\home\\root\\hello\\target\\debug\\build\\hello/e7dee8bc15a2c771\\out\\hello.exe" "-Wl,--gc-sections" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: x86_64-w64-mingw32-gcc: error: no such file or directory: 'crt2.o'


    Building [                             ] 0/1: hello(bin)
error: could not compile `hello` (bin "hello") due to 1 previous error

Without this PR, that command will either:

  • work fine
  • fail to link
  • possibly create broken binary

because of mixing CRT objects shipped with libstd and host-provided libraries.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants