Repository navigation
fix(desktop): 打包和 make core 经 desktop-go.sh 选择 Core 目标,修复 Windows 上的 MSVC 报错 - #1834
Merged
Merged
Conversation
…MSVC 报错 package-desktop.sh 为嵌入 lithe-mcp 直接调用 build-desktop-core.sh --release, make core 直接调用 build-desktop-core.sh --debug。build-desktop-core.sh 在 LITHE_CORE_TARGET 为空时取 rustc 主机目标,Windows 上 rustc 默认是 x86_64-pc-windows-msvc,于是 mingw32-make package 报 "cgo cannot link the MSVC .lib archive" 后退出;arm64 主机打 amd64 macOS 包时 嵌入的 helper 也是 arm64。 - desktop-go.sh 新增 --print-core-stage:按 GOOS/GOARCH 映射的目标暂存 Core, 只输出暂存目录;参数检查放在 Core 构建之前。 - package-desktop.sh 和 make core 改用该模式,与打包、开发构建同一目标。 - 新增 scripts/desktop/package-desktop.test.mjs 回归测试(修复前 3 项均失败), 并加入 Desktop CI 的脚本测试。 - 功能矩阵 ide-mcp-connection 补充证据与验证说明。
xiaoyumuxi
marked this pull request as ready for review
November 12, 2026 13:59
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.
关联 Issue / Linked issue
make core入口,不完成该 Issue)PR 类型 / Type
改动说明 / What changes
背景 / Why
在 Windows 上运行
mingw32-make package打 Viva 桌面端安装包时,命令直接报错退出:打包脚本为了把
lithe-mcp辅助程序嵌进客户端,直接调用build-desktop-core.sh --release,绕过了desktop-go.sh。build-desktop-core.sh在LITHE_CORE_TARGET为空时会使用 rustc 的主机目标,而 rustup 在 Windows 上默认装的是x86_64-pc-windows-msvc,脚本检测到 MSVC 后拒绝构建。desktop-go.sh本来负责把 GOOS/GOARCH 映射到 Core 目标(Windows 为x86_64-pc-windows-gnu),客户端本体的构建走它,所以目标是对的,出问题的只有辅助程序这一步。同一原因还有两个表现:
make package ARCH=amd64能打出包,但嵌入的lithe-mcp是 arm64 版本,Intel Mac 上 IDE 连接用的辅助程序无法运行。make core也直接调用build-desktop-core.sh --debug,在 Windows 上报同样的错误。.github/workflows/desktop-release.yml里的 Windows 发版任务(windows-2022)和 darwin amd64 发版任务(macos-26,arm64 runner)都没有设置LITHE_CORE_TARGET,所以第一次推desktop-v*标签时会遇到同样的问题:Windows 包打不出来,amd64 macOS 包嵌入了 arm64 的辅助程序。这个工作流还不在 main 上,没有运行过,所以问题还没暴露。改动 / Changes
scripts/desktop/desktop-go.sh--print-core-stage模式:沿用已有的 GOOS/GOARCH → Core 目标映射、LITHE_DESKTOP_CORE_PROFILE和MACOSX_DEPLOYMENT_TARGET设置,暂存 Core 后只把暂存目录输出到 stdout 然后退出,不运行 Go。build-desktop-core.sh(它默认取 rustc 主机目标)。scripts/desktop/package-desktop.sh:暂存 lithe-mcp 的那一步从build-desktop-core.sh --release改为GOARCH="$ARCH" LITHE_DESKTOP_CORE_PROFILE=release desktop-go.sh --print-core-stage,辅助程序和安装包使用同一个目标与 profile;同步更新注释。desktop/Makefile:make core改为desktop-go.sh --print-core-stage(profile 仍是 debug),并加注释说明原因。新增
scripts/desktop/package-desktop.test.mjs:在临时目录中运行真实的package-desktop.sh、desktop-go.sh和desktop/Makefile。go、rustc和build-desktop-core.sh用假程序代替,其中假的build-desktop-core.sh保留真实脚本的目标规则(优先LITHE_CORE_TARGET,否则取 rustc 主机目标,遇到 MSVC 拒绝)。共三个用例:x86_64-pc-windows-gnu --release,嵌入的辅助程序属于 GNU 目标。--arch amd64包:只暂存x86_64-apple-darwin --release,嵌入的是 x86_64 辅助程序。make core:只暂存x86_64-pc-windows-gnu --debug,stdout 只有暂存目录。每个子进程都通过
write-stable-tests的runProcess启动,超时 60 秒,并断言没有超时、进程树已结束;临时目录在finally中删除。.github/workflows/desktop-ci.yml:在 Linux 任务的 “Run script tests” 中加入这个测试。Draft PR 也会运行它。shared/platform-feature-matrix/features/ide-mcp-connection.json:两端 evidence 补上package-desktop.sh和新测试;notes 写明辅助程序按desktop-go.sh的目标映射构建;verification 写入新测试的验证内容。两端的实现状态和验证状态不变(partial/pending)。不在本 PR 范围内 / Out of scope
mingw32-make package,见下方“未能执行的检查”。docs/development/desktop-getting-started.md中关于这个 MSVC 报错的排查说明没有改。修复后,直接运行build-desktop-core.sh时这个报错依然会出现,原有说明仍然准确。类型专属:fix
复现与根因
x86_64-pc-windows-msvc,已rustup target add x86_64-pc-windows-gnu,MinGW-w64 已在 PATH 中。cd desktop && mingw32-make package。cgo cannot link the MSVC .lib archive for x86_64-pc-windows-msvc; use x86_64-pc-windows-gnu for Windows.,Error 2退出,没有生成安装包。dist/desktop/windows-amd64/生成lithe-<version>-windows-amd64-setup.exe和 zip,嵌入的 lithe-mcp 为 GNU 目标。make package ARCH=amd64,安装包能生成,但嵌入的 lithe-mcp 是 arm64 版本;Windows 上运行make core报同样的 MSVC 错误。package-desktop.sh的build-desktop-core.sh --release和 Makefilecore目标的build-desktop-core.sh --debug(用git log -S确认)。这两处绕过了desktop-go.sh的目标映射,回到 rustc 主机默认目标。make core失败);macOS 上跨架构打包(arm64 主机打 amd64 包时嵌入了错误架构的辅助程序);Desktop Release 工作流的 Windows 和 darwin amd64 任务。Linux 本机架构打包不受影响,因为主机目标和映射目标一致。检查项
scripts/desktop/package-desktop.test.mjs。修复前 3 项全部失败:Windows 打包用例和make core用例输出上面的 MSVC 报错并 exit 2;arm64 主机打 amd64 包的用例中,暂存记录里多出aarch64-apple-darwin --release,嵌入的辅助程序不是 x86_64。修复后 3 项全部通过(约 2.6 秒)。build-desktop-core.sh的只有desktop-go.sh(本来就会先设置目标)、package-desktop.sh和desktop/Makefile。CI 中其余引用只用于bash -n、ShellCheck 和 cache key 的 hashFiles。desktop_go_test.go和desktop-core-cache.test.mjs用自己的假脚本,已重新运行并通过。scripts/ci/desktop-release/package-release.sh通过package-desktop.sh间接受益,不需要改。.agents/notes/implemented/bug-fix/记录:约束(需要暂存 Core 时走desktop-go.sh --print-core-stage,不要直接调用build-desktop-core.sh)已写进desktop-go.sh文件头和两个调用点的注释,并由 CI 中的回归测试守住,没有另写 Note。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/ide-mcp-connection.json:两端的 evidence、notes、verification 已补充;实现状态和验证状态保持partial/pending(没有在两端实机验证)./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(validated 217 platform capabilities)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD(matrix change gate passed).artifacts/下生成的矩阵视图统一日志系统 / Structured logging
N/A:只改了构建、打包脚本和 Makefile,没有改动运行时的生命周期、用户操作或失败路径。
界面文案 / i18n
N/A:没有新增或修改用户可见文案。新增的
Usage: … --print-core-stage是开发者命令行的 stderr 输出,不属于界面文案。两项 i18n 检查仍已运行并通过。逻辑归属 / Logic placement
N/A:没有业务逻辑,只是构建脚本改为复用已有的目标映射。
性能与内存 / Performance and memory
N/A:没有改动运行时功能、启动路径或依赖。打包时 Core 仍然只为一个目标构建一次。
设置 / Settings
N/A:没有涉及设置。
插件契约 / Plugin contract
N/A:没有改动插件契约、能力版本或宿主方法,
PINNED_CORE_REVISION不变。发行包与资源 / Bundle and resources
desktop/internal/idehelp/lithe-mcp.bin仍然只在打包时生成,结束后由 trap 删除,运行时的安装位置不变。已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh(模板里写的scripts/macos/verify/…已不存在,桌面端对应的脚本是这个),结果通过scripts/resources/worktree-resources.json等:没有新增资源路径、缓存变量或下载入口。Core 的暂存位置和缓存规则不变,只是辅助程序这一步现在使用正确的目标无用代码与重构 / Dead code and refactoring
build-desktop-core.sh仍由desktop-go.sh调用)验证 / Verification
node --test scripts/desktop/package-desktop.test.mjs(修复前)node --test scripts/desktop/package-desktop.test.mjs(修复后)node --test scripts/desktop/desktop-core-cache.test.mjsbash scripts/desktop/desktop-go.sh test ./internal/core/ -run 'TestDesktopGoFindsWindowsCargoImportLibraries|TestBuildDesktopCoreChecksOutFreshPinnedRevision' -count=1make -s core(固定 Core 修订 47c9859d2f43)bash -n与shellcheck -S warning(desktop-go.sh、package-desktop.sh)actionlint .github/workflows/desktop-ci.yml./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/preview./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEADnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./scripts/desktop/verify/verify-runtime-bundle-immutability.sh未能执行的检查和原因:
mingw32-make package。本机的 Parallels 虚拟机是 ARM64,当前状态为 invalid,而 Windows 打包只支持 amd64。Windows 行为目前只由回归测试中的模拟覆盖。需要在 x64 Windows 上运行cd desktop && mingw32-make package NO_SIGN=1,确认生成 setup.exe/zip,并确认安装后 IDE 连接能启动 lithe-mcp。make package(含签名、dmg),也没有在 Intel Mac 上验证 amd64 包里的 lithe-mcp 能运行。提交前确认 / Final checks
preview(b43c05ad5)创建;目标分支:preview.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图make core和测试的子进程都已结束,没有进程残留