Repository navigation
Closed
Description
需求与已有讨论的关系
相关但独立的通用参数配置请求:#717(目标条件下的 dialect_cxxflags)。CRT 语义配置完善后,本项目可不再手写该参数,但 #717 仍适用于其他平台专用的模块图参数。
希望完善 Windows MSVC ABI 下的 CRT 选择,使同一个语义配置能够覆盖 cl、clang-cl 和普通 clang++,并统一用于源码编译、标准库模块和缓存。
这是 #649 E10 的后续功能请求:
- 该问题的结项说明 已说明:LLVM 行记录其静态 CRT,并诊断无法满足的 cxx_runtime;是否支持 /MD 对应的模型是另一个决策。
- 这里不把上述已完成的诊断修复当作回归,而是请求进一步支持显式的动态/静态 CRT 选择。
- MSVC: cxx_runtime does not reach the std module build — /MD project against a /MT std.ifc fails with C2375 #422 曾修复 cl 的项目 TU 与 std BMI 使用不同 CRT 的问题,新支持也应沿用“一个解析结果,供两边共同消费”的原则。
使用场景
- Windows,mcpp
2026.9.26.2,LLVM22.1.8,普通clang++驱动,目标为 Windows MSVC ABI。 - GalTranslPP 使用 C++23 模块、
import std;,并使用 Qt/vcpkg 提供的动态 release CRT 库。 - release 构建仍生成 PDB,即启用调试信息,但不希望切换到 debug CRT。
- 当前项目用以下底层参数显式选择 CRT:
[build]
dialect_cxxflags = ["-fms-runtime-lib=dll"]这能让参数同时到达项目源码及 std BMI,但项目需要知道驱动拼写和模块参数通道,还存在平台条件声明的问题。
按本地源码 52549fbb2d17939e89efb1e05e0c2717bf30d96c:
- flags.cppm 的 CRT 参数路径 在 MSVC 命令行方言分支中生成参数。
- 标准库模块准备 使用同一 CRT 推导机制。
- 已有测试 覆盖 cl 参数和已有配置推导。
本次诉求是对普通 clang++ / MSVC ABI 补齐语义配置,不是要求改变其他平台的默认运行库策略。
配置形式:供讨论,不限定必须新增字段
若现有 linkage / cxx_runtime 足够表达需求,可以完善现有机制并明确文档,避免重复配置。
若需要直接表达 CRT 选择,可考虑沿用现有 ABI 配置位置,例如:
# 提议的新字段,目前不可直接使用
[target.windows.abi]
msvc_crt_linkage = "dynamic" # static / dynamic
msvc_crt_variant = "release" # release / debug是否支持 debug CRT 可以分阶段决定;当前项目的直接需求是普通 clang++ 下显式选择动态 release CRT。
两个维度的预期映射:
| CRT 链接方式 | CRT 变体 | cl / clang-cl | 普通 clang++,Windows MSVC ABI |
|---|---|---|---|
| dynamic | release | /MD | -fms-runtime-lib=dll |
| static | release | /MT | -fms-runtime-lib=static |
| dynamic | debug | /MDd | -fms-runtime-lib=dll_dbg |
| static | debug | /MTd | -fms-runtime-lib=static_dbg |
debug = true 表示调试信息需求,不应自动等价于 debug CRT。
期望行为
- 根据目标 ABI 和编译器驱动生成参数,而不是仅凭宿主 OS 或 GNU/CL 参数风格判断。
- 同一个解析后的 CRT 选择用于相关 C/C++ 编译、模块扫描、std/std.compat BMI 和链接。
- CRT 选择进入相关缓存标识,切换后不复用另一 CRT 配置的模块/对象。
- 对 Linux、macOS、MinGW 等不适用目标,不泄漏 MSVC 专用参数;明确不适用配置的诊断或跳过规则。
- 与
linkage、cxx_runtime及已有默认行为统一解析,记录优先级;对已知矛盾给出明确诊断,不输出互相覆盖的 CRT 参数。 - 运行库事实记录和部署/打包对运行库依赖的判断也应反映实际选择,避免只改编译参数却保留静态 CRT 的记录。
- 不承诺替用户重建外部预编译库;文档说明它们仍需与选用的 CRT 配置相容。
建议验证
- 相同 CRT 选择在各支持驱动下生成对应参数。
- 包含
import std;的最小程序能够编译链接,TU 与标准库 BMI 使用一致配置。 - static/dynamic 切换后缓存正确失效,产物的运行库依赖符合声明。
- release CRT + 调试信息能够共存。
- 非适用目标不收到 MSVC CRT 参数。
不要求本 issue 一次实现所有配置维度,但希望先有受支持的方式,让 LLVM/clang++ 行显式选择动态 release CRT,并让 std BMI、缓存及运行库记录保持一致。
Metadata
Metadata
Assignees
Labels
No labels
Activity
T8 (#718 W9): the CRT model is a property of the MSVC ABI, not of cl.exe
docs(50): the refusal token msvc-redist-unavailable (#718)
review: the round's CI failures and the three review angles
2026.9.28.1: eight reports (#717, #718, #720, #722-#726), one downloa…
build: drop the hand-written -fms-runtime-lib=dll; mcpp's CRT model s…
speak-agent commentedon Sep 28, 2026
Completed across two releases; closing with the readings.
2026.9.28.1 (#727) implemented the CRT model on the MSVC ABI for every driver:
clspells it/MDor/MT, clang++-fms-runtime-lib=dllorstatic, and the one resolved choice reaches compilation, the std and std.compat BMIs (whose cache identity includes it) and the link (behaviours 1 to 3).cxx_runtimeandlinkagestate it, with no new key; a hand-written CRT word that agrees is warned as redundant, one that contradicts is refused, a dependency's contradicting word is refused, and the debug words are refused, since the model has no debug axis (4, 5). Non-MSVC targets receive no MSVC word (4).2026.9.28.2 (#730, #731) completes behaviour 6, the runtime facts, the placement and the packing. One resolver (
mcpp.build.runtime_placement, SPEC-006 §3.7.1) decides the files beside a Windows program: the MSVC C++ runtime is one versioned set, the toolset's unless a complete, strictly newer set is offered; a dependency's copy is stated once as a packaging fault; the contract governs whether the set is carried. The plan, the post-link placement andmcpp packread that one answer, andresolution.jsonrecords it. Every action of an MSVC-ABI build runs with the toolset's runtime first onPATH, so Qt's tools start from a payload that carries no runtime of its own (xim:qt-base6.11.1 revision 1, openxlings/xim-pkgindex#898).Readings on GalTranslPP (Windows, llvm@22.1.8 over MSVC 14.51.36231):
dialect_cxxflags = ["-fms-runtime-lib=dll"]in its five manifests (run 36378870254): success, no redundancy warning, and the packages carryMSVCP140*andVCRUNTIME140*beside the programs, so the model alone chose the dynamic CRT.Behaviour 7 (prebuilt external libraries must match the chosen CRT) is documented in docs/20. The record is
.agents/docs/2026-09-28-ecosystem-design-and-optimisation-plan.md§8.The bundled xlings is 2026.11.16.1