Derive dlltool path from the linker for Windows-GNU builds - #4206
Open
rdesgroppes wants to merge 1 commit into
Open
Derive dlltool path from the linker for Windows-GNU builds#4206rdesgroppes wants to merge 1 commit into
dlltool path from the linker for Windows-GNU builds#4206rdesgroppes wants to merge 1 commit into
Conversation
`rustc` on Windows-GNU shells out to `dlltool` to synthesize import libraries: for `#[link(... kind = "raw-dylib")]` declarations in any crate (`windows-sys` 0.61+ is the common case), and for the `*.dll.a` companion that `cdylib` crates emit alongside their `.dll`. `cc_toolchain` has no action/tool slot for `dlltool`, since `gcc` used as a linker runs it internally, but `rustc` drives the linker directly and so needs an explicit `--codegen dlltool=` pointer, which previously had to be supplied by hand via `extra_rustc_flags` on every target. Every MinGW toolchain, whether a native Windows distribution (winlibs, MSYS2 mingw64, llvm-mingw) or a Unix cross toolchain, ships `dlltool` right next to the linker with the same naming convention (`.exe`/`.EXE` suffix or none), so derive its path from the `cc_toolchain`'s own linker tool path instead. A user-supplied `-Cdlltool=` via `extra_rustc_flags` still wins, since `rustc` honors the last `-C<key>=` for a given key. This adds no new `constraint_value` nor `config_setting` and does not affect toolchain auto-registration or resolution: `target_abi` is already parsed from the target triple on the resolved `rust_toolchain`, the same field `portable_link_flags` and `symlink_for_ambiguous_lib` key off of a few lines below. Assisted-by: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rustcon Windows-GNU shells out todlltoolto synthesize import libraries: for#[link(... kind = "raw-dylib")]declarations in any crate (windows-sys0.61+ is the common case), and for the*.dll.acompanion thatcdylibcrates emit alongside their.dll.cc_toolchainhas no action/tool slot fordlltool, sincegccused as a linker runs it internally, butrustcdrives the linker directly and so needs an explicit--codegen dlltool=pointer, which previously had to be supplied by hand viaextra_rustc_flagson every target.Every MinGW toolchain, whether a native Windows distribution (winlibs, MSYS2 mingw64, llvm-mingw) or a Unix cross toolchain, ships
dlltoolright next to the linker with the same naming convention (.exe/.EXEsuffix or none), so derive its path from thecc_toolchain's own linker tool path instead.A user-supplied
-Cdlltool=viaextra_rustc_flagsstill wins, sincerustchonors the last-C<key>=for a given key.This adds no new
constraint_valuenorconfig_settingand does not affect toolchain auto-registration or resolution:target_abiis already parsed from the target triple on the resolvedrust_toolchain, the same fieldportable_link_flagsandsymlink_for_ambiguous_libkey off of a few lines below.Assisted-by: Claude