Skip to content

[CI]【Hackathon 10th Spring No.46】Windows C++ compilation guards (1/3)#7327

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

[CI]【Hackathon 10th Spring No.46】Windows C++ compilation guards (1/3)#7327
r-cloudforge wants to merge 12 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-046-win-cpp-guards-part-v2

Conversation

@r-cloudforge
Copy link
Copy Markdown

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

Motivation

FastDeploy's custom_ops/gpu_ops/ C++ source files include POSIX-only headers
(<sys/mman.h>, <sys/ipc.h>, <sys/shm.h>, <sys/msg.h>, <unistd.h>) that
are unavailable on MSVC, preventing compilation on Windows.

Additionally, env.h relies on std::stoi, std::stoul, and std::string
without explicitly including <cstdlib> and <string>. GCC's <iostream>
transitively provides these, but MSVC 14.44 does not.

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

  • Part 1 (this PR): C++ #ifndef _WIN32 guards on POSIX-only includes + env.h portability fix
  • Part 2: 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

  • Added #ifndef _WIN32 / #endif guards around POSIX-only includes in 26 .cu/.cc/.h files
  • Added #include <cstdlib> and #include <string> to env.h for MSVC portability
  • Applied clang-format to all touched files

Files changed: 27 (26 guard additions + 1 include fix)

All guards are _WIN32-only — zero functional change on Linux.

Usage or Command

# Verify no compilation regression on Linux (CI handles this automatically)
cd custom_ops && python setup_ops.py install

On Windows with MSVC + CUDA toolkit:

cl.exe /EHsc /std:c++17 /I<cuda>/include /I gpu_ops/ /E gpu_ops/helper.h

Accuracy Tests

Not applicable — pure preprocessor changes. No functional code modified.

Verified via MSVC 14.44 (VS 2022 Build Tools) preprocess test on Windows Server 2022:
all 27 modified headers parse cleanly with cl.exe /E.

Pipeline Evidence:

Checklist

  • #ifndef _WIN32 guards only wrap POSIX-specific includes
  • No functional behavior change on Linux
  • clang-format applied to all touched files
  • pre-commit hooks pass
  • Tested compilation on MSVC 14.44 (Windows Server 2022)

@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 C++ compilation guards (1/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 04:00 CST

📋 Review 摘要

PR 概述:为 FastDeploy 添加 Windows C++ 编译兼容性支持(Hackathon 10th Spring No.46 Part 1)

变更范围custom_ops/gpu_ops/ 目录下的 28 个文件

影响面 Tag[CI]

📝 PR 规范检查

PR 标题和描述均符合规范,无需修改。

问题

未发现阻塞性问题。

总体评价

本次 PR 作为 Windows 构建支持的第一阶段,正确地通过 #ifndef _WIN32 / #endif 保护了 POSIX-only 的 C++ 头文件,并使用 #ifdef _WIN32 + PD_THROW 对依赖 POSIX IPC/共享内存的函数进行了 Windows 平台隔离。env.h 中添加的 #include <cstdlib>#include <string> 正确解决了 MSVC 14.44 的兼容性问题。所有修改均为平台隔离代码,零功能性变更,不影响 Linux 平台。CI 已通过,代码质量良好。

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