Skip to content

[CI] add C++20 compile probe#79445

Open
gouzil wants to merge 1 commit into
PaddlePaddle:developfrom
gouzil:codex/cxx20-common-probe
Open

[CI] add C++20 compile probe#79445
gouzil wants to merge 1 commit into
PaddlePaddle:developfrom
gouzil:codex/cxx20-common-probe

Conversation

@gouzil

@gouzil gouzil commented Jul 8, 2026

Copy link
Copy Markdown
Member

PR Category

Environment Adaptation

PR Types

Devs

Description

本 PR 在 paddle/common/enforce.cc 增加一个最小 C++20 编译探针:

  • 使用 consteval,这是 C++20 才支持的语言特性;static_assert 只是把该探针真正实例化使用起来。
  • paddle/common/enforce.cc 会被编入 commoncommon_static,用于覆盖 Paddle 公共编译链路。
  • 目标是在 CI 或不同构建选项仍以 C++17、或工具链尚未完整支持 C++20 时,尽早暴露适配问题。

该改动不引入运行时逻辑,不改变现有错误处理行为,只用于编译期验证。

验证:

  • prek
  • ninja -C build common common_static -j8
  • 本地确认同一探针在 -std=c++20 下通过,在 -std=c++17 下因 consteval 编译失败

是否引起精度变化

否。该 PR 只新增编译期探针,不涉及算子实现、数值计算或运行时执行路径。

Copilot AI review requested due to automatic review settings July 8, 2026 16:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a minimal C++20 compile-time probe to paddle/common/enforce.cc to surface toolchain / build-flag mismatches early in CI by requiring a C++20-only language feature to compile.

Changes:

  • Add a consteval-based compile probe plus static_assert in paddle/common/enforce.cc to force instantiation at compile time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread paddle/common/enforce.cc
Comment on lines +26 to +30
// C++20 compile probe: consteval is C++20-only, and this file is built into
// common and common_static.
consteval bool PaddleCxx20CompileProbe() { return true; }
static_assert(PaddleCxx20CompileProbe());

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已完成初审。发现一个会影响现有 C++17 fallback 构建路径的阻塞问题,具体证据和建议已放在行级评论里;修复后请提交新的 commit 以便复查。

当前还有部分检查仍在运行中,后续也请以完整 CI 结果为准。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment thread paddle/common/enforce.cc
namespace {
// C++20 compile probe: consteval is C++20-only, and this file is built into
// common and common_static.
consteval bool PaddleCxx20CompileProbe() { return true; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 优先级:P1

这里无条件使用 consteval 会破坏仓库当前仍显式保留的 C++17 构建路径。cmake/flags.cmake 里 GCC < 11 仍会追加 -std=c++17,Windows 分支也设置 CMAKE_CXX_STANDARD 17;同时 paddle/common/CMakeLists.txt 会把本文件编入 commoncommon_static。在这些路径下,本行会直接语法失败(例如 c++ -std=c++17 -I. -fsyntax-only paddle/common/enforce.cc 会报 consteval does not name a type),导致现有受支持构建无法通过。

处理要求:请针对该评论修复并提交新的 commit。

请在同一个 PR 中先统一构建策略,再保留这个探针。可选方向之一是正式移除这些 C++17 fallback 并让配置阶段直接失败,例如:

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
   CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
  message(FATAL_ERROR "GCC >= 11 is required for the C++20 baseline.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")

如果 GCC < 11 / Windows 的 C++17 路径还需要继续保留,则这个探针不能无条件放在会被这些路径编译的公共源文件中,需要先加条件或改放到只覆盖 C++20 目标的构建检查里。

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Paddle-CI-Agent | pr_review | 2026-07-09 00:39:31

📋 Review 摘要

PR 概述:在 enforce.cc 中增加 C++20-only consteval 编译探针,覆盖 common / common_static 编译链路。
变更范围paddle/common/enforce.cc
影响面 TagEnvironment Adaptation Execute Infrastructure

问题

级别 文件 概述
🔴 Bug paddle/common/enforce.cc:28 无条件 C++20 探针与 CMake 保留的 C++17 fallback 冲突,GCC < 11 / Windows 构建会在 common 编译阶段失败

📝 PR 规范检查

描述结构符合模板;标题 Tag [CI] 不在当前模板枚举中,建议改为与本 PR 影响面一致的官方 Tag。

标题建议(可直接复制):

  • [Environment Adaptation] add C++20 compile probe

总体评价

该探针能覆盖公共编译目标,但当前实现会使构建系统仍显式允许的 C++17 fallback 路径失效。需要先同步更新 CMake 工具链基线声明,或保留这些 fallback 的可编译性。

Comment thread paddle/common/enforce.cc
namespace {
// C++20 compile probe: consteval is C++20-only, and this file is built into
// common and common_static.
consteval bool PaddleCxx20CompileProbe() { return true; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug 这里无条件使用 consteval,会让仓库仍显式配置为 C++17 的构建路径直接失败。

paddle/common/enforce.cc 会进入 commoncommon_static,但 cmake/flags.cmake 目前仍对 GCC < 11 走 -std=c++17 fallback,并在 WIN32 下设置 CMAKE_CXX_STANDARD 17。因此这些被 CMake 接受的配置会在编译本文件时失败,而不是按构建系统声明的兼容路径继续工作。

建议修复方式:如果 Paddle 基线已经切到 C++20,请同步修改 cmake/flags.cmake,删除这些 C++17 fallback 或在 configure 阶段对 GCC < 11 / 当前 Windows 工具链给出明确 FATAL_ERROR;如果这些 fallback 仍需保留,则不要在公共源文件中放置无条件 C++20-only 代码。

@paddle-bot paddle-bot Bot added the contributor External developers label Jul 8, 2026
@paddle-bot

paddle-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@PaddlePaddle-bot

PaddlePaddle-bot commented Jul 15, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-17 05:56:10 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 2315e8b | Merge base: 034a838 (branch: develop)


1 Required任务 : 29/38 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
88(20) 68 50 7 0 0 11
任务 错误类型 置信度 日志
Windows-GPU / Build and test PR问题:C++20 探针进入 C++17 构建 Job
Windows-Inference / Build and test PR问题:Inference 矩阵仍按 C++17 构建 Job
Windows-OPENBLAS / Build and test PR问题:OPENBLAS Windows 未启用 C++20 Job
Linux-build / Build PR问题:Linux build 未满足 C++20 Job
PR-CI-Inference / Build PR问题:PR-CI-Inference 未启用 C++20 Job
Fleet Unit test (single card) 不稳定问题:Fleet 单卡测试超时 Job
Linux-DCU / Build 未知:Linux-DCU 日志获取失败 Job

2 失败详情

🔴 Windows-GPU / Build and test — PR问题:C++20 探针进入 C++17 构建(置信度: 高)

失败用例: 构建阶段

用例 错误摘要
paddle/common/enforce.cc MSVC 以 -std:c++17 编译,无法识别 PR 新增的 C++20 consteval

关键日志:

FAILED: paddle/common/CMakeFiles/common.dir/enforce.cc.obj
... cl.exe ... -std:c++17 ... -c ..\paddle\common\enforce.cc
..\paddle\common\enforce.cc(28): error C2144: syntax error: 'bool' should be preceded by ';'
..\paddle\common\enforce.cc(29): error C2131: expression did not evaluate to a constant
  • 根因摘要: C++20 探针进入 C++17 构建
    PR 在 paddle/common/enforce.cc:28-29 新增 consteval 探针,但该 Windows GPU 矩阵仍使用 C++17 编译选项构建 common/common_static,因此编译器无法解析该 C++20-only 语法。失败与本 PR 改动直接相关。

修复建议:

  1. 将该 CI/CMake 链路的 C++ 标准统一切到 C++20,或在所有 required 构建完成 C++20 迁移前移除/条件保护该探针。

关联变更: paddle/common/enforce.cc:28-29

🔴 Windows-Inference / Build and test — PR问题:Inference 矩阵仍按 C++17 构建(置信度: 高)

失败用例: 构建阶段

用例 错误摘要
paddle/common/enforce.cc Inference Windows 构建仍传入 -std:c++17consteval 探针编译失败

关键日志:

FAILED: paddle/common/CMakeFiles/common.dir/enforce.cc.obj
... cl.exe ... -std:c++17 ... -c ..\paddle\common\enforce.cc
..\paddle\common\enforce.cc(28): error C2144: syntax error: 'bool' should be preceded by ';'
..\paddle\common\enforce.cc(29): note: see usage of '`anonymous-namespace'::PaddleCxx20CompileProbe'
  • 根因摘要: Inference 矩阵仍按 C++17 编译
    本 job 的失败点与 PR 新增探针完全重合:enforce.cc 被编入 commoncommon_static,但 Windows Inference 构建没有启用 C++20,导致新增 consteval 无法通过编译。

修复建议:

  1. 补齐 Windows Inference 构建的 C++20 编译配置,或让探针只在确认 C++20 的配置下启用。

关联变更: paddle/common/enforce.cc:28-29

🔴 Windows-OPENBLAS / Build and test — PR问题:OPENBLAS Windows 未启用 C++20(置信度: 高)

失败用例: 构建阶段

用例 错误摘要
paddle/common/enforce.cc MSVC 2017 OPENBLAS 矩阵使用 -std:c++17,无法编译 consteval

关键日志:

FAILED: paddle/common/CMakeFiles/common.dir/enforce.cc.obj
... cl.exe ... -std:c++17 ... -c ..\paddle\common\enforce.cc
..\paddle\common\enforce.cc(28): error C4430: missing type specifier - int assumed
..\paddle\common\enforce.cc(29): error C2131: expression did not evaluate to a constant
  • 根因摘要: OPENBLAS Windows 链路未启用 C++20
    该矩阵同样在 paddle/common/enforce.cc 的新探针处失败,且日志显示编译命令仍是 C++17。该失败不是环境下载或 runner 异常,而是 PR 新增 C++20 语法与当前 required 编译配置不匹配。

修复建议:

  1. 若目标是强制 C++20,请同步升级 OPENBLAS Windows required 构建链路;否则不要在公共源文件中无条件使用 C++20-only 语法。

关联变更: paddle/common/enforce.cc:28-29

🔴 Linux-build / Build — PR问题:Linux build 未满足 C++20(置信度: 高)

失败用例: 构建阶段

用例 错误摘要
paddle/common/enforce.cc Linux build 中 consteval 不是可识别类型,后续 static_assert 找不到函数

关键日志:

/paddle/paddle/common/enforce.cc:28:1: error: ‘consteval’ does not name a type; did you mean ‘constexpr’?
consteval bool PaddleCxx20CompileProbe() { return true; }
/paddle/paddle/common/enforce.cc:29:15: error: ‘PaddleCxx20CompileProbe’ was not declared in this scope
static_assert(PaddleCxx20CompileProbe());
  • 根因摘要: Linux build 也未满足 C++20 探针要求
    Linux required build 在同一新增代码处失败,说明 C++20 探针覆盖到的公共编译链路仍未全部以 C++20 构建。该失败由 PR 新增代码直接触发。

修复建议:

  1. 先完成 Linux required build 的 C++20 标准配置/工具链适配,再保留该探针;或将探针改为配置期检查,避免直接破坏当前 required 构建。

关联变更: paddle/common/enforce.cc:28-29

🔴 PR-CI-Inference / Build — PR问题:PR-CI-Inference 未启用 C++20(置信度: 高)

失败用例: 构建阶段

用例 错误摘要
paddle/common/enforce.cc Inference build 未以 C++20 编译,无法识别新增 consteval 探针

关键日志:

/paddle/paddle/common/enforce.cc:28:1: error: ‘consteval’ does not name a type; did you mean ‘constexpr’?
consteval bool PaddleCxx20CompileProbe() { return true; }
/paddle/paddle/common/enforce.cc:29:15: error: ‘PaddleCxx20CompileProbe’ was not declared in this scope
static_assert(PaddleCxx20CompileProbe());
make[2]: *** [paddle/common/CMakeFiles/common.dir/build.make:95: paddle/common/CMakeFiles/common.dir/enforce.cc.o] Error 1
  • 根因摘要: PR-CI-Inference 仍按非 C++20 构建
    PR 仅在 paddle/common/enforce.cc 新增 C++20-only 的 consteval 探针;该文件会被编入 common,而本 job 的构建日志在同一新增行直接失败,说明该 required inference 构建链路尚未启用 C++20。

修复建议:

  1. 将 PR-CI-Inference build 的 C++ 标准和工具链配置补齐到 C++20;或在所有 required 构建完成迁移前,将该探针移到配置期检查/条件编译,避免公共源文件无条件使用 C++20-only 语法。

关联变更: paddle/common/enforce.cc:28-29

🟡 Fleet Unit test (single card) — 不稳定问题:Fleet 单卡测试超时(置信度: 中)

失败用例: tests/single_card_tests/model/test_gpt_model_mtp_fp8_quant_weight.py

用例 错误摘要
test_gpt_model_mtp_fp8_quant_weight.py 单卡测试步骤运行到 60 分钟上限被 GitHub Actions 终止

关键日志:

Running single card test: tests/single_card_tests/model/test_gpt_model_mtp_fp8_quant_weight.py
collected 17 items
tests/single_card_tests/model/test_gpt_model_mtp_fp8_quant_weight.py ...
##[error]The action 'Single card test' has timed out after 60 minutes.
  • 根因摘要: Fleet 单卡测试超时
    PR 只修改 paddle/common/enforce.cc 的编译期探针,未改 Fleet 测试或模型代码;该 job 前置安装完成,超时发生在单卡测试执行阶段。当前证据未显示它与 PR 变更直接相关,更像独立的长耗时/偶发 hang。

修复建议:

  1. 已知不稳定,请 rerun;若重跑仍复现,再单独排查 test_gpt_model_mtp_fp8_quant_weight.py 的耗时或卡死点。

关联变更: 未发现与本 PR 直接相关的变更

⚪ Linux-DCU / Build — 未知:Linux-DCU 日志获取失败(置信度: 低)

失败用例: 构建阶段

用例 错误摘要
Run build 深度日志获取失败,无法提取具体编译错误

关键日志:

(日志获取失败,无法提取错误信息)
  • 根因摘要: 分析不可用
    该 job 最新 attempt 仍在 Run build 步骤失败,但 fetch_ci_logs(quick=false, job_id=86049738347) 未返回 log_file_path 或有效 error_snippet。同 PR 其他多个 build job 已确认因 paddle/common/enforce.cc:28-29 的 C++20 consteval 探针在非 C++20 构建链路中失败;本 job 是否同因需要后续补充日志确认。

修复建议:

  1. 分析省略/待后续深挖;优先补取该 job 的完整构建日志后再定性。若日志显示同样的 consteval 编译错误,则按 C++20 构建配置不完整处理。

关联变更: paddle/common/enforce.cc:28-29(推测相关,缺少本 job 日志确认)

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.

4 participants