cli: replay hotpatch links with the env rustc gave the linker - #5850
Open
aron-intframe wants to merge 1 commit into
Open
aron-intframe wants to merge 1 commit into
aron-intframe wants to merge 1 commit into
Conversation
…ioxusLabs#4911) rustc hands its linker child env vars the rustc process itself never has: `LIB`/`INCLUDE`/`PATH` from MSVC tool discovery on windows, the sysroot tool dirs on `PATH`, `LC_ALL`/`VSLANG`. dx replayed fat/thin links with the env captured by the rustc wrapper, so outside a VS developer prompt `LIB` was missing and rust-lld could not open `kernel32.lib` and friends. Capture `std::env::vars()` in the linker interception next to the link args (`link_env.json`, `DX_LINK_ENV_FILE`) and prefer it when replaying. The linux-only `PATH` patch stays as the fallback for caches without a capture.
This branch has not been deployed
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.
Fixes #4911
Description
dx serve --hot-patchreplays the fat/thin link withenv_clear()plus the env captured by the rustc wrapper. But rustc gives its linker child vars the rustc process never has: on windowsLIB/INCLUDE/PATHfromfind_msvc_tools(rustc_codegen_ssa/back/linker.rs,get_linker), plus the sysroot tool dirs onPATHandLC_ALL/VSLANG. Outside a VS developer promptLIBonly exists there, so the replayedrust-lldcan't openkernel32.lib. Inside the promptLIBis in the shell env, so the wrapper captured it by accident.This captures
std::env::vars()in the linker interception next to the link args (link_env.json,DX_LINK_ENV_FILE) and prefers it for the replay. The linux-onlyPATHre-add stays as the fallback for caches without a capture.Measured on linux with rustc 1.97.1 calling the patched
dxas-Clinker: the captured env hasLC_ALL=C,VSLANG=1033and tworustlib/<host>/binentries onPATHthat the wrapper env lacks. No windows host here, so not verified end to end; the windows playwright hotpatch job is the real check.User-Facing Changes
dx serve --hot-patchshould work from a regular terminal on windows. One more file in the session cache.Tests
3 unit tests in
build/link.rs(replay prefers the captured env, fallback without one, file round trip); the first fails with the old behaviour.cargo test -p dioxus-cli --bin dx164/164, fmt clean, clippy unchanged.