Skip to content

【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3)#7502

Open
bobby-cloudforge wants to merge 1 commit intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-046-win-build-system-1
Open

【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3)#7502
bobby-cloudforge wants to merge 1 commit intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-046-win-build-system-1

Conversation

@bobby-cloudforge
Copy link
Copy Markdown

@bobby-cloudforge bobby-cloudforge commented Apr 20, 2026

Motivation

FastDeploy's custom_ops/setup_ops.py unconditionally passes -lcuda and
-lnvidia-ml 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 -lnvidia-ml 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

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Apr 20, 2026

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label Apr 20, 2026
@bobby-cloudforge bobby-cloudforge changed the title 【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3) 【Hackathon 10th Spring No.46】[Build] Windows build system -part Apr 20, 2026
PaddlePaddle-bot

This comment was marked as outdated.

@bobby-cloudforge bobby-cloudforge changed the title 【Hackathon 10th Spring No.46】[Build] Windows build system -part [CI]【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3) Apr 20, 2026
@bobby-cloudforge bobby-cloudforge changed the title [CI]【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3) 【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3) Apr 20, 2026
Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-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-20 18:42:10\n\n## 📋 Review 摘要\n\nPR 概述:为 Windows 平台添加构建支持,包括 setup_ops.py 平台条件链接参数和 build.bat 构建脚本\n变更范围custom_ops/setup_ops.pybuild.bat\n影响面 TagOP Docs/CI\n\n### 📝 PR 规范检查\n\nPR 标题缺少官方 Tag 前缀。当前标题:「【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3)」\n\n标题建议(可直接复制):\n- [Feature] Add Windows build system support (Part 2/3)\n\n另外,PR 描述中 Motivation 部分提到原代码 "unconditionally passes -lcuda and -lcudart linker flags",但实际原代码是 -lcuda-lnvidia-ml(非 -lcudart),建议修正描述以避免误导 reviewer。\n\n### 问题\n\n未发现阻塞性问题。\n\n### 总体评价\n\n代码变更整体合理:setup_ops.py 的平台判断逻辑正确(sys 模块已在文件头部导入,Windows 使用 /DEFAULTLIB: MSVC 语法对应 Linux 的 -l 标志);build.bat 结构清晰,错误处理到位(使用 enabledelayedexpansion + !ERRORLEVEL!),TODO 注释明确标注了后续需要补充的步骤(init/cleanup/copy_ops 等)。作为 Part 2/3 的增量 PR,范围适当。"

@bobby-cloudforge
Copy link
Copy Markdown
Author

Re: review 4139266332

  1. PR title tag: Hackathon PRs follow the 【Hackathon 10th Spring No.XX】 format per submission guidelines — [Feature] is for non-hackathon work.

  2. -lcudart-lnvidia-ml: Good catch — PR description corrected. The actual flags in setup_ops.py:571 are -lcuda and -lnvidia-ml.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants