Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .agents/docs/2026-12-04-windows-msvc-ci-adaptations-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
subject: ci
status: active
---

# Windows 原生 MSVC(`msvc@system`)CI 适配记录

来源:PR #16(分支 `ci/windows-msvc-system`)在 `Build and Tests` 工作流中新增
`windows-msvc-x86_64`(`msvc@system`,通过 `setup-msvc-dev` 固定 MSVC 14.52 +
Windows SDK 10.0.26100.0)。

## 背景

此前 Windows CI 仅覆盖 `windows-llvm-msvc`(`clang-cl` / `llvm@23.1.3`)。虽然
`clang-cl` 与原生 `cl.exe` 共用 Windows SDK、MSVC STL 与 MSVC ABI,且都定义了
`_MSC_VER`,但二者在 Boost 条件编译上有三处本质差异:

1. `clang-cl` 定义 `__clang__`,不定义 `BOOST_MSVC`;原生 `cl.exe` 定义
`BOOST_MSVC`,不定义 `__clang__` 与 `__GNUC__`。
2. `Boost.Config` 对 `BOOST_MSVC` 无条件定义 `BOOST_NO_COMPLETE_VALUE_INITIALIZATION`,
经由 `cxx_composite.hpp` 连带定义 `BOOST_NO_CXX03` 与 `BOOST_NO_CXX11`。
3. `cl.exe` 在未传 `/Zc:__cplusplus` 时将 `__cplusplus` 固定为 `199711L`,即便开启
`/std:c++latest`。

因此启用原生 `cl.exe` 后,集中暴露了一批仅在 `BOOST_MSVC` 下触发的头文件分支、
导出符号差异与编译器行为差异。

## 已落地的适配

### 1. `hana`:保护不支持 MSVC 的 `experimental/type_name.hpp`(`25ec4c4d`)

- **现象**:依赖扫描阶段即在 `src/hana.cppm` 失败:
`boost/hana/experimental/type_name.hpp(41): fatal error C1189: #error: "No support for this compiler."`
- **原因**:上游 `type_name.hpp` 仅实现了 `BOOST_HANA_CONFIG_CLANG` 与
`BOOST_HANA_CONFIG_GCC` 两个分支。
- **决策**:
- 在 `src/hana.cppm` 中用
`#if defined(BOOST_HANA_CONFIG_CLANG) || defined(BOOST_HANA_CONFIG_GCC)`
保护 `#include <boost/hana/experimental/type_name.hpp>`(`gen_exports.py --check`
按文本扫描 GMF `#include`,与 `src/process.cppm` 惯例一致)。
- 在 `tools/export_policy.toml` 新增 `[[hana.guard]]`,按同一上游条件保护该头文件
声明的 4 个符号(`boost::hana::experimental::type_name`、
`detail::cstring`、`detail::type_name_impl1`、`detail::type_name_impl2`),
并重新生成 `generated/exports/hana.inc` 与 `generated/meta/skipped.txt`。

### 2. `type_traits` 与 `variant`:补齐 `BOOST_MSVC` 条件导出与 `::mpl_` 映射(`c4a5383e`)

- **现象**:`src/type_traits.cppm` 出现 8 个 `C2039` / `C3083` / `C2873` 错误。
- **原因与决策**:均为 `BOOST_MSVC` 下的上游分支差异,在 `tools/export_policy.toml`
按上游宏条件添加 `guard` 并重新生成导出文件:

| 模块 | 符号 | 上游条件 / 原因 | 处理 |
|---|---|---|---|
| `type_traits` | `boost::detail::false_or_cpp11_noexcept_move_assignable` | `is_nothrow_move_assignable.hpp` 在 MSVC 走 `BOOST_IS_NOTHROW_MOVE_ASSIGN` 内建分支 | `!defined(BOOST_IS_NOTHROW_MOVE_ASSIGN)` |
| `type_traits` | `boost::detail::false_or_cpp11_noexcept_move_constructible` | `is_nothrow_move_constructible.hpp` 走 `BOOST_IS_NOTHROW_MOVE_CONSTRUCT` 分支 | `!defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT)` |
| `type_traits` | `::mpl_::{bool_,integral_c,integral_c_tag}` | `integral_constant.hpp` 在 `BOOST_MSVC` 下跳过 `::mpl_` 隔离命名空间,直接声明在 `boost::mpl` | `!defined(BOOST_MSVC) && !defined(BOOST_MPL_CFG_NO_ADL_BARRIER_NAMESPACE)`,并在 `#else` 导出 `boost::mpl::*` |
| `type_traits` | `boost::tt_align_ns::{a2,a4}` | `type_with_alignment.hpp` 仅 GCC/Clang 分支声明 `a2`/`a4`,MSVC 分支从 `a8` 起 | `(defined(__GNUC__) || defined(__clang__)) && !defined(BOOST_TT_DISABLE_INTRINSICS)` |
| `type_traits` | `boost::type_traits::detail::sized_type_for_promotion` | `integral_promotion.hpp` 仅在 `!defined(BOOST_MSVC)` 下声明 | `!defined(BOOST_MSVC)` |
| `variant` | `::mpl_::{_,_1.._6,arg,false_,int_,long_,na,size_t,true_,void_}`(15 个) | `boost/mpl/aux_/config/adl.hpp` 在 `BOOST_MSVC` 下定义 `BOOST_MPL_CFG_NO_ADL_BARRIER_NAMESPACE` | 主动排查一并修复:`!defined(BOOST_MPL_CFG_NO_ADL_BARRIER_NAMESPACE)`,并在 `#else` 导出 `boost::mpl::*` |

### 3. `concept_check`:处理 `msvc.hpp` 分支与 include guard 冲突(`a3401a05`)

- **现象**:`src/concept_check.cppm` 报 `boost::concept_check_`、`concept_check_failed`、
`constraint_check`、`constraint_check_failed`、`boost::concept_checking::*`、
`boost::concepts::{constraint,requirement,requirement_}`、`detail::instantiate`
均未声明。
- **原因**:
1. `boost/concept/assert.hpp` 在 `BOOST_MSVC` 下包含 `boost/concept/detail/msvc.hpp`
而非 `general.hpp`,改为声明 `boost::concepts::{check,require,require_}` 及
`boost::concepts::detail::constraint`。
2. 上游 `boost/concept/detail/msvc.hpp` 与 `boost/concept_check/general.hpp` 共享
同一个 include guard `BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP`,导致后者在
MSVC 下被完全跳过。
- **决策**:在 `tools/export_policy.toml` 中以 `!defined(BOOST_MSVC)` 保护 general
分支符号,并在 `#else` 分支导出 MSVC 下 `BOOST_CONCEPT_ASSERT` 实际使用的
`boost::concepts::{check,require,require_}` 与 `boost::concepts::detail::constraint`。

### 4. `algorithm` 与 `math`:保护 `is_blank` 并消除 `differentiation::detail` 歧义(`280ae791`)

- **`algorithm`**:
- **现象**:`boost::is_blank` 与 `boost::algorithm::is_blank` 在 MSVC 下未声明。
- **原因**:`boost/algorithm/string/classification.hpp` 将二者置于 `#ifndef BOOST_NO_CXX11`
内,而 `Boost.Config` 对 MSVC 定义了 `BOOST_NO_CXX11`。
- **决策**:在 `tools/export_policy.toml` 添加 `!defined(BOOST_NO_CXX11)` 保护。
- **`math`**:
- **现象**:`lanczos_smoothing.hpp`、`finite_difference.hpp`、`condition_numbers.hpp`
及 `generated/exports/math.inc(1843-1849)` 报 `error C2872: 'detail': ambiguous symbol`
(`boost::math::differentiation::detail` 与 `boost::math::differentiation::autodiff_v1::detail` 冲突)。
- **原因**:`autodiff.hpp` 定义了 `inline namespace autodiff_v1 { namespace detail { ... } }`,
与 `lanczos_smoothing.hpp` / `finite_difference.hpp` 的 `boost::math::differentiation::detail`
落在同一模块 GMF 中;MSVC 对限定/非限定查找 `detail` 严格报歧义。
- **决策**:
- 在 `patches/math.patch` 中引入 `BOOST_MATH_DIFF_DETAIL_NS` 宏:非 MSVC 展开为
`detail`(AST 与导出集合零变化),`BOOST_MSVC` 下展开为 `diff_detail`,应用于
`lanczos_smoothing.hpp`、`finite_difference.hpp` 与 `condition_numbers.hpp`。
- 在 `tools/export_policy.toml` 中以 `!defined(BOOST_MSVC)` 保护
`boost::math::differentiation::detail` 下的 7 个内部 helper 导出,既满足 MSVC
编译,又不丢失非 MSVC 的可达导出(`check_reachable.py` 通过)。
- **否决方案**:直接改名 `autodiff_v1::detail`(涉及 68 个导出符号,且 `autodiff.hpp`
内部多处引用 `differentiation::detail::fvar`)。

### 5. MSVC `/Zc:__cplusplus` 与 `units`(`060138bc`)

- **`/Zc:__cplusplus`(修复 `hana/traits.hpp`)**:
- **现象**:`boost/hana/traits.hpp(74): error C2039: 'is_literal_type': is not a member of 'std'`。
- **原因**:`hana/traits.hpp` 使用 `#if __cplusplus < 201703L` 保护 `std::is_literal_type`,
而 MSVC 未传 `/Zc:__cplusplus` 时 `__cplusplus` 为 `199711L`,在 `/std:c++latest`
下误入该分支并引用了 C++20 已移除的 trait。
- **决策**:在 `mcpp.toml` 新增 `[target.'cfg(compiler = "msvc")'.build]`,设置
`cxxflags = ["/Zc:__cplusplus"]`。
- **`units`**:
- **现象**:`generated/exports/units.inc(823): error C2039: 'pascal': is not a member of 'boost::units::si'`。
- **原因**:`boost/units/systems/si/pressure.hpp` 在 `BOOST_MSVC` 下定义
`BOOST_UNITS_NO_PASCAL` 并省略 `pascal`。
- **决策**:在 `tools/export_policy.toml` 为 `boost::units::si::pascal` 添加
`!defined(BOOST_UNITS_NO_PASCAL)` 保护。

## 待跟进事项

1. **`type_erasure` MSVC ICE**:在 `280ae791` 的 `group A` 日志中,
`src/type_erasure.cppm(28)`(模块文件末尾,写 `.ifc` 阶段)触发
`fatal error C1001: Internal compiler error (compiler file 'msc1.cpp', line 1678)`,
附带 `note: IFC import detected`。需在 `060138bc` 的 CI 结果出来后确认是否仍复现;
若仍复现,需定位触发 ICE 的具体导入或导出项并制定规避方案。
2. **后续模块、测试与示例验证**:待 `group A` / `group B` 全部模块编译通过后,
继续排查可能出现的链接/运行期问题,并验证 `examples` job;全部落地前补充更新
`patches/README.md` 对 `math.patch` 新增改动的说明,并将本记录状态置为 `landed`。

## 本地验证

每轮修改均已在本地通过:

- `uv run --project tools --locked python -m unittest discover -s tests`(114 tests OK)
- `uv run --project tools --locked python tools/gen_features.py --check`
- `uv run --project tools --locked python tools/apply_patches.py`
- `uv run --project tools --locked python tools/ci/check_reachable.py --base origin/main`
- `python3 tools/doc-tools/check_docs.py`
11 changes: 10 additions & 1 deletion .agents/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
- `todos/` 放尚未完成的工作项,它们不是决定的记录。
- 移动或改名用 `tools/doc-tools/move_record.py`,它同时改写仓库中对该文件的引用。

共 31 篇记录(其中 0 篇已归档),1 项待办。
共 32 篇记录(其中 0 篇已归档),1 项待办。

## 进行中

- [Windows 原生 MSVC(`msvc@system`)CI 适配记录](2026-12-04-windows-msvc-ci-adaptations-design.md) — active
- [PR #5 第二轮评审的 [nit] 修复:覆盖率按测试程序列出的用例核对](2026-11-21-pr5-review-nits-design.md) — active
- [子工程复用根工程的构建产物,mcpp 升级到 2026.11.20.1](2026-11-20-sub-project-build-reuse-design.md) — active
- [模块测试加固的发现复盘:封装层缺陷与上游 Boost 问题(对照 1.93.0.beta1)](2026-11-12-module-tests-findings-and-upstream-bugs-analysis.md) — active
Expand All @@ -39,6 +40,10 @@

只列出声明了 subject 的记录。

### ci

- [Windows 原生 MSVC(`msvc@system`)CI 适配记录](2026-12-04-windows-msvc-ci-adaptations-design.md) — active

### docs

- [设计记录的管理:只增不删、按年归档、生成的索引与 `tools/doc-tools/`](2026-11-08-design-records-management-design.md) — landed
Expand All @@ -64,6 +69,10 @@

## 按日期

### 2026-12

- [Windows 原生 MSVC(`msvc@system`)CI 适配记录](2026-12-04-windows-msvc-ci-adaptations-design.md) — active

### 2026-11

- [可达导出集合检查与 issue #2 剩余名称的处理](2026-11-29-reachable-exports-design.md) — landed
Expand Down
52 changes: 41 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Boost 1.92.0 as C++23 named modules (mcpplibs.mwrap.boost) — build/test matrix.
#
# Ported from the pre-mwrap wrapper's CI (boost-module b1.92.0wdev tests.yml).
# The five host configurations and their pinned toolchains are the ones that
# wrapper validated; keep the set if a leg is added or dropped:
# The six host configurations and their pinned toolchains are the ones that
# CI validates; keep the set if a leg is added or dropped:
#
# windows-latest x86_64 msvc@system (cl.exe, MSVC 14.52 + SDK 10.0.26100.0)
# windows-latest x86_64 llvm@23.1.3 (clang-cl / clang-msvc)
# ubuntu-24.04 x86_64 gcc@16.1.0
# ubuntu-24.04-arm arm64 gcc@16.1.0
Expand Down Expand Up @@ -31,7 +32,7 @@
#
# The examples, the template smoke test and the release-page check run in the
# `examples` job, which `needs: [test]`: they start only after both groups have
# passed on all five hosts.
# passed on all six hosts.
#
# mcpp comes from the repository's own pin: xlings installs `mcpp 2026.11.27.1`
# (only that entry of `.xlings.json`; its `llvm` pin is the generator's), and
Expand Down Expand Up @@ -61,6 +62,9 @@ env:
XLINGS_NON_INTERACTIVE: '1'
# Must match [workspace].mcpp in .xlings.json — checked on every leg.
MCPP_VERSION: "2026.11.27.1"
# Pinned MSVC toolset and Windows SDK on windows-latest (setup-msvc-dev).
MSVC_TOOLSET: "14.52"
WINDOWS_SDK: "10.0.26100.0"
# Leave the runners room: the vendored tree is large and every leg compiles
# Boost from the same checkout.
MCPP_JOBS: '4'
Expand Down Expand Up @@ -97,6 +101,7 @@ jobs:
fail-fast: false
matrix:
target:
- { name: windows-msvc, os: windows-latest, arch: x86_64, toolchain: "msvc@system", install: "" }
- { name: windows-llvm-msvc, os: windows-latest, arch: x86_64, toolchain: "llvm@23.1.3", install: "llvm 23.1.3" }
- { name: linux-gcc, os: ubuntu-24.04, arch: x86_64, toolchain: "gcc@16.1.0", install: "gcc 16.1.0" }
- { name: linux-gcc, os: ubuntu-24.04-arm, arch: arm64, toolchain: "gcc@16.1.0", install: "gcc 16.1.0" }
Expand All @@ -106,6 +111,14 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Set up MSVC (${{ env.MSVC_TOOLSET }}, SDK ${{ env.WINDOWS_SDK }})
if: runner.os == 'Windows'
uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64
toolset: ${{ env.MSVC_TOOLSET }}
sdk: ${{ env.WINDOWS_SDK }}

# Warm the mcpp sandbox (engine, registry, toolchain payloads and the
# global BMI cache). Keyed per toolchain so the gcc and llvm legs on one
# OS cannot restore each other's default (config.toml); A and B share the
Expand All @@ -114,9 +127,9 @@ jobs:
uses: actions/cache@v6
with:
path: ~/.mcpp
key: mcpp-${{ matrix.target.os }}-${{ matrix.target.name }}-${{ matrix.target.arch }}-${{ matrix.target.toolchain }}-v${{ env.MCPP_VERSION }}
key: mcpp-${{ matrix.target.os }}-${{ matrix.target.name }}-${{ matrix.target.arch }}-${{ matrix.target.toolchain }}${{ matrix.target.toolchain == 'msvc@system' && format('-{0}-{1}', env.MSVC_TOOLSET, env.WINDOWS_SDK) || '' }}-v${{ env.MCPP_VERSION }}
restore-keys: |
mcpp-${{ matrix.target.os }}-${{ matrix.target.name }}-${{ matrix.target.arch }}-${{ matrix.target.toolchain }}-
mcpp-${{ matrix.target.os }}-${{ matrix.target.name }}-${{ matrix.target.arch }}-${{ matrix.target.toolchain }}${{ matrix.target.toolchain == 'msvc@system' && format('-{0}-{1}', env.MSVC_TOOLSET, env.WINDOWS_SDK) || '' }}-

- name: Install xlings
if: runner.os != 'Windows'
Expand Down Expand Up @@ -154,8 +167,10 @@ jobs:
shell: bash
run: |
set -euo pipefail
mcpp toolchain install ${{ matrix.target.install }}
mcpp toolchain default ${{ matrix.target.toolchain }}
if [ -n "${{ matrix.target.install }}" ]; then
mcpp toolchain install ${{ matrix.target.install }}
fi
mcpp toolchain default "${{ matrix.target.toolchain }}"
mcpp toolchain list

# Guard the grouping invariant: every library feature in mcpp.toml is in
Expand Down Expand Up @@ -278,6 +293,11 @@ jobs:
fail-fast: false
matrix:
include:
- name: windows-msvc
os: windows-latest
arch: x86_64
toolchain: msvc@system
install: ""
- name: windows-llvm-msvc
os: windows-latest
arch: x86_64
Expand Down Expand Up @@ -306,13 +326,21 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Set up MSVC (${{ env.MSVC_TOOLSET }}, SDK ${{ env.WINDOWS_SDK }})
if: runner.os == 'Windows'
uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64
toolset: ${{ env.MSVC_TOOLSET }}
sdk: ${{ env.WINDOWS_SDK }}

- name: Cache mcpp sandbox
uses: actions/cache@v6
with:
path: ~/.mcpp
key: mcpp-${{ matrix.os }}-${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.toolchain }}-v${{ env.MCPP_VERSION }}
key: mcpp-${{ matrix.os }}-${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.toolchain }}${{ matrix.toolchain == 'msvc@system' && format('-{0}-{1}', env.MSVC_TOOLSET, env.WINDOWS_SDK) || '' }}-v${{ env.MCPP_VERSION }}
restore-keys: |
mcpp-${{ matrix.os }}-${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.toolchain }}-
mcpp-${{ matrix.os }}-${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.toolchain }}${{ matrix.toolchain == 'msvc@system' && format('-{0}-{1}', env.MSVC_TOOLSET, env.WINDOWS_SDK) || '' }}-

- name: Install xlings
if: runner.os != 'Windows'
Expand Down Expand Up @@ -348,8 +376,10 @@ jobs:
shell: bash
run: |
set -euo pipefail
mcpp toolchain install ${{ matrix.install }}
mcpp toolchain default ${{ matrix.toolchain }}
if [ -n "${{ matrix.install }}" ]; then
mcpp toolchain install ${{ matrix.install }}
fi
mcpp toolchain default "${{ matrix.toolchain }}"
mcpp toolchain list

# examples/basic consumes the root package as a path dependency with an
Expand Down
10 changes: 10 additions & 0 deletions generated/exports/algorithm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ export namespace boost {
using boost::is_alnum;
using boost::is_alpha;
using boost::is_any_of;
#if !defined(BOOST_NO_CXX11)
// boost/algorithm/string/classification.hpp declares is_blank only under
// !defined(BOOST_NO_CXX11) (which Boost.Config defines on MSVC via
// BOOST_NO_COMPLETE_VALUE_INITIALIZATION -> BOOST_NO_CXX03 -> BOOST_NO_CXX11).
using boost::is_blank;
#endif
using boost::is_classified;
using boost::is_cntrl;
using boost::is_digit;
Expand Down Expand Up @@ -269,7 +274,12 @@ export namespace boost { namespace algorithm {
using boost::algorithm::is_alnum;
using boost::algorithm::is_alpha;
using boost::algorithm::is_any_of;
#if !defined(BOOST_NO_CXX11)
// boost/algorithm/string/classification.hpp declares is_blank only under
// !defined(BOOST_NO_CXX11) (which Boost.Config defines on MSVC via
// BOOST_NO_COMPLETE_VALUE_INITIALIZATION -> BOOST_NO_CXX03 -> BOOST_NO_CXX11).
using boost::algorithm::is_blank;
#endif
using boost::algorithm::is_clamped;
using boost::algorithm::is_classified;
using boost::algorithm::is_cntrl;
Expand Down
Loading
Loading