[Feature]【Hackathon 10th Spring No.46】MSVC/CMake Windows build fix [cf]#7700
[Feature]【Hackathon 10th Spring No.46】MSVC/CMake Windows build fix [cf]#7700ghost wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览当前 CI 尚未完全执行:6个核心 Workflow 处于
2 任务状态汇总2.1 Required 任务:0/0 通过
2.2 可选任务 — 1/2 通过
3 失败详情(仅 required)无 required 失败任务。
|
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-03 22:07:43
📋 Review 摘要
PR 概述:新增 Windows MSVC/CMake 构建支持,包括一键构建脚本 build.bat 及 setup_ops.py 的平台差异化链接参数
变更范围:build.bat(新增)、custom_ops/setup_ops.py
影响面 Tag:[OP] [Feature]
📝 PR 规范检查
标题末尾附有非官方标签 [cf],且 【Hackathon 10th Spring No.46】 为非标准格式;PR 描述中所有 section 内容均为 TODO 占位符,且 Checklist 结构与模板不符,需要补充完整。
标题建议(可直接复制):
[Feature] Add Windows MSVC/CMake build support (build.bat + setup_ops.py cross-platform link args)
PR 描述建议(可直接复制):
## Motivation
在 Windows 平台上使用 MSVC 编译器构建 FastDeploy custom ops 时,原有链接参数 `-lcuda`、`-lnvidia-ml` 为 Linux/GCC 格式,在 Windows 下编译失败。本 PR 修复了跨平台链接参数问题,并新增 Windows 一键构建脚本 `build.bat`。
## Modifications
- `custom_ops/setup_ops.py`:根据 `sys.platform` 区分 Windows(`/DEFAULTLIB:cuda.lib`、`/DEFAULTLIB:nvml.lib`)和 Linux(`-lcuda`、`-lnvidia-ml`)的 CUDA 链接参数
- `build.bat`:新增 Windows 批处理构建脚本,支持构建 custom ops、打包 wheel 和 pip 安装;通过 BUILD_MODE 参数控制范围(0=仅 ops,1=完整构建);支持 `FD_BUILDING_ARCS`、`FD_CPU_USE_BF16` 环境变量
## Usage or Command
在 Developer Command Prompt(已配置 MSVC 编译环境)中执行:
# 完整构建(custom ops + wheel + pip install)
build.bat 1 python
# 仅构建 custom ops
build.bat 0
# 指定 CUDA 架构后仅构建 ops
set FD_BUILDING_ARCS=[90]
build.bat 0
## Accuracy Tests
N/A(构建脚本与链接参数变更,不影响模型精度)
## Checklist
- [x] Add at least a tag in the PR title.
- Tag list: [`[FDConfig]`,`[APIServer]`,`[Engine]`, `[Scheduler]`, `[PD Disaggregation]`, `[Executor]`, `[Graph Optimization]`, `[Speculative Decoding]`, `[RL]`, `[Models]`, `[Quantization]`, `[Loader]`, `[OP]`, `[KVCache]`, `[DataProcessor]`, `[BugFix]`, `[Docs]`, `[CI]`, `[Optimization]`, `[Feature]`, `[Benchmark]`, `[Others]`, `[XPU]`, `[HPU]`, `[GCU]`, `[DCU]`, `[Iluvatar]`, `[Metax]`]
- You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [ ] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] Provide accuracy results.
- [ ] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | build.bat:1 |
@echo off 应置于文件第一行,否则首行 REM 注释会被打印到控制台 |
| 🟡 建议 | build.bat:83 |
wheel 安装 for 循环缺少未匹配任何 .whl 时的保护,可能导致误报成功 |
| 🟡 建议 | custom_ops/setup_ops.py:14 |
模块文档字符串改为 Hackathon 任务引用,移除了有效模块描述,建议恢复 |
总体评价
setup_ops.py 中平台差异化链接参数的修改方向正确,可以解决 Windows MSVC 构建问题;build.bat 结构清晰,功能覆盖基本完整。存在批处理脚本小逻辑缺陷(@echo off 位置、wheel 安装循环无保护)、模块文档字符串退化以及 PR 描述未填充等问题,建议修正后合入。
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist