Skip to content

[CI]【Hackathon 10th Spring No.46】Windows build system guards (2/3)#7328

Open
r-cloudforge wants to merge 12 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-046-win-build-system-part-v2
Open

[CI]【Hackathon 10th Spring No.46】Windows build system guards (2/3)#7328
r-cloudforge wants to merge 12 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-046-win-build-system-part-v2

Conversation

@r-cloudforge
Copy link
Copy Markdown

@r-cloudforge r-cloudforge commented Apr 10, 2026

Motivation

FastDeploy's custom_ops/setup_ops.py unconditionally passes -lcuda and
-lcudart linker flags, which are GCC/Linux-style and invalid on MSVC
(Windows uses .lib linking via the CUDA Toolkit paths).

Additionally, build.sh exists for Linux but there is no Windows equivalent.

This is Part 2 of 3 for 【Hackathon 10th Spring No.46】(Windows Build Support):

  • Part 1: C++ #ifndef _WIN32 guards on POSIX-only includes
  • Part 2 (this PR): Build system — setup_ops.py platform-conditional link args + build.bat
  • Part 3: Python runtime — platform guards for /dev/shm, os.killpg, os.setsid, fork

Modifications

  • setup_ops.py: Wrapped -lcuda and -lcudart flags in
    sys.platform != "win32" check. On Windows, MSVC finds CUDA libraries
    via CUDA_PATH environment variable without explicit -l flags.
  • build.bat (new): Windows-native build script matching build.sh
    structure. Supports BUILD_MODE=0 (custom_ops only) and BUILD_MODE=1
    (full wheel build). Uses setlocal EnableDelayedExpansion for proper
    error handling.

Usage or Command

:: Build custom_ops only (default)
set BUILD_MODE=0
build.bat

:: Full wheel build
set BUILD_MODE=1
build.bat

On Linux, no change — the sys.platform check is only active on Windows.

Accuracy Tests

Not applicable — build system changes only.

Verified on Windows Server 2022 with MSVC 14.44:
python setup_ops.py install parses correctly (full build requires CUDA toolkit).

Pipeline Evidence:

Checklist

  • sys.platform guard only affects Windows
  • No functional change on Linux
  • build.bat mirrors build.sh structure
  • pre-commit hooks pass

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


cloudforge1 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 10, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Apr 10, 2026
@r-cloudforge r-cloudforge changed the title test [CI]【Hackathon 10th Spring No.46】Windows build system guards (2/3) Apr 10, 2026
Copy link
Copy Markdown

@fastdeploy-bot fastdeploy-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Code Review | 2026-04-11

📋 Review 摘要

PR 概述: 为 Windows 添加构建系统支持,修复 CUDA 链接参数的平台兼容性问题

变更范围: custom_ops/setup_ops.pybuild.bat

影响面 Tag: [CI]

📝 PR 规范检查

PR 标题和描述整体符合规范,仅有一处疑问:

❓ 疑问 - PR 描述与实际变更不一致

PR 描述中提到:

FastDeploy's custom_ops/setup_ops.py unconditionally passes -lcuda and -lcudart linker flags

但根据 diff,实际原参数是 -lcuda-lnvidia-ml,而非 -lcudart。请确认描述是否需要更新。

问题

级别 文件 概述
🟡 建议 build.bat:16 缺少关键环境变量传递
🟡 建议 build.bat:16 缺少 Python 版本检查
🟡 建议 build.bat:16 缺少帮助信息

总体评价

setup_ops.py 的平台条件判断是正确的修复,解决了 Windows MSVC 无法解析 GCC 风格链接参数的问题。build.bat 提供了基础的 Windows 构建支持,但相比 build.sh 功能较为简化,建议进一步完善以保持跨平台功能对等性。

REM See the License for the specific language governing permissions and
REM limitations under the License.

REM FastDeploy Windows build script
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 缺少关键环境变量传递

build.bat 调用 setup_ops.py install 时没有传递 FD_BUILDING_ARCSFD_CPU_USE_BF16 环境变量。与 build.sh 不一致,Windows 用户无法自定义 CUDA 架构或启用 CPU BF16。

建议添加类似 build.sh 的环境变量支持。

REM See the License for the specific language governing permissions and
REM limitations under the License.

REM FastDeploy Windows build script
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 缺少 Python 版本检查

build.sh 有 Python 版本检查(确保 >= 3.9),build.bat 缺少此检查。

建议添加版本验证以避免兼容性问题。

REM See the License for the specific language governing permissions and
REM limitations under the License.

REM FastDeploy Windows build script
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 缺少帮助信息

build.sh 有完整的 show_help() 函数,build.bat 只有简单的头部注释。

建议添加 /?-h 支持,输出详细的参数说明和示例。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants