Skip to content

Commit f93254b

Browse files
authored
fix: add +crt-static to Windows rustflags to eliminate vcruntime140.dll dependency (#407)
The Windows-specific `[target.'cfg(target_os = "windows")']` rustflags sections in `.cargo/config.toml.disabled` were **overriding** the global `[build].rustflags`, silently dropping `-Ctarget-feature=+crt-static`. This caused the shipped `pet.exe` to dynamically link `VCRUNTIME140.dll` and several UCRT DLLs, breaking Python environment detection on enterprise machines without the VC++ Redistributable installed. **Changes:** - Add `-Ctarget-feature=+crt-static` to both Windows target-specific `rustflags` sections - Narrow the global `[build]` section to `cfg(target_os = \"linux\")` to avoid ambiguity **Verified locally:** rebuilt `pet.exe` with the fix — `VCRUNTIME140.dll` and all `api-ms-win-crt-*` imports are eliminated. Fixes #406
1 parent 130b29f commit f93254b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

.cargo/config.toml.disabled

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
# [registries.ms-crates-io]
55
# index = "sparse+https://pkgs.dev.azure.com/vscode/_packaging/crates/Cargo/index/"
66

7-
# Windows: -Ctarget-feature=+crt-static: Statically link the CRT (required to link the spectre-mitigated CRT).
8-
# Other: -Ctarget-feature=+crt-static: Statically link the CRT
9-
[build]
7+
# Linux: -Ctarget-feature=+crt-static: Statically link the CRT.
8+
[target.'cfg(target_os = "linux")']
109
rustflags = ["-Ctarget-feature=+crt-static"]
1110

1211
# -Cehcont_guard: Enable EH Continuation Metadata (https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-eh-continuation-metadata).
1312
# -Ccontrol-flow-guard: Enable Control Flow Guard, needed for OneBranch's post-build analysis (https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard).
1413
# -Ctarget-feature=+crt-static: Statically link the CRT (required to link the spectre-mitigated CRT).
1514
[target.'cfg(target_os = "windows")']
16-
rustflags = ["-Cehcont_guard", "-Ccontrol-flow-guard"]
15+
rustflags = ["-Ctarget-feature=+crt-static", "-Cehcont_guard", "-Ccontrol-flow-guard"]
1716

1817
# -Clink-args=/DYNAMICBASE /CETCOMPAT: Enable "shadow stack" (https://learn.microsoft.com/en-us/cpp/build/reference/cetcompat)
1918
[target.'cfg(all(target_os = "windows", any(target_arch = "i686", target_arch = "x86_64")))']
20-
rustflags = ["-Clink-args=/DYNAMICBASE /CETCOMPAT"]
19+
rustflags = ["-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]

0 commit comments

Comments
 (0)