Repository navigation
fix(packaging): statically link the MSVC runtime on Windows - #112
Merged
Merged
Conversation
snap-desk.exe imported VCRUNTIME140.dll, so it failed to start on Windows without the Visual C++ redistributable (clean installs, Windows Sandbox, the WinGet validation VM). This is why the WinGet submission was labelled Validation-Executable-Error. Link the C runtime statically for MSVC targets via .cargo/config.toml, and have the packaging script read the PE import table of the built executable and stop if it still depends on vcruntime/msvcp DLLs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
问题
snap-desk.exe动态链接 MSVC C 运行库,会导入VCRUNTIME140.dll。没装 Visual C++ 运行库的 Windows(干净系统、Windows 沙盒、WinGet 验证机)上,主程序一启动就报找不到 DLL:Validation-Executable-Error:验证机装完后无法运行主程序。本机安装的 0.3.2 实测导入表里有
vcruntime140.dll;翻译 worker 已经是静态链接的,没有这个依赖。改动
.cargo/config.toml:MSVC 目标加-C target-feature=+crt-static。cc 编译的 C 依赖(内置 SQLite)会随之改用/MT;Windows 上 onnxruntime 是运行时加载(load-dynamic),不参与链接。scripts/package-gpui.mjs:Windows 构建后读取主程序的 PE 导入表,仍依赖vcruntime*/msvcp*时停止打包,防止以后被改回动态链接(比如有人设置了RUSTFLAGS,会覆盖配置里的 rustflags)。scripts/package-gpui.test.mjs:导入表解析测试(手工构造的最小 PE + Windows 上的真实node.exe)。评审注意
cargo install cargo-packager,也会读到这份配置;它在 Windows 上没有预编译的原生库,静态链接没有影响。onnxruntime.dll(本地 OCR)仍依赖 VC++ 运行库,加载失败时会提示用户安装,不在本 PR 范围内。验证
npm test38 项通过;用导入表检查扫描本机 0.3.2 主程序能识别出vcruntime140.dll,扫描翻译 worker 结果为空。cargo test)和 Windows 测试包构建(打包时执行导入表检查)验证。🤖 Generated with Claude Code