feat(build): 汇编源一等公民 — .S/.s/.asm 进 sources,NASM 按目标推导 -f#220
Merged
Conversation
设计: .agents/docs/2026-07-17-asm-sources-and-general-build-capabilities-design.md (PR-A)
- .S/.s (GAS) 走 C 驱动的新 asm_object 规则(asm 安全旗标子集,无 -std/-O,
PIC/调试/工具链定位旗标保留);.asm (NASM) 走 nasm_object 规则,-f 由
Triple::nasm_format() 从目标三元组推导(elf64/win64/macho64/...,交叉零特判),
%include 经 -MD/-MQ 进 ninja deps 通道
- 默认 sources glob 扩为 src/**/*.{cppm,cpp,cc,c,S,s,asm};汇编对象名带全扩展
限定(foo.asm.o),同 stem 的 .c/.asm 兄弟不再撞对象
- 扩展名路由四处同改并单测锁住:scanner 跳模块扫描、plan 链接收集
(is_implementation_source)、ninja pick_rule、cdb(.asm 不进
compile_commands,clangd 读不懂;.S 以 cc + asm 旗标进)
- nasm 惰性解析(仅当计划含 .asm 单元):PATH → mcpp 沙箱 → xlings install,
版本 floor ≥2.16,不可得即硬失败,绝不静默跳过;非 x86 目标遇 .asm、
MSVC 工具链遇 .S 均硬报错并给出门控指引
- G8a: 源 glob 跟随目录软链接(递归栈祖先链防环 + 文件级 canonical 去重);
顺带修 path_matches_glob 用 fs::relative 会解析软链致匹配失效的问题
(改词法 lexically_relative)
- e2e 104(GAS 全链路+增量+build/test 双路径)/105(NASM/-f 推导/%include
依赖追踪/CDB 排除),run_all.sh 增 nasm capability;单测 35/35 过,
e2e 106 过(3 失败均为既有环境性:22/54/62)
This was referenced Jul 17, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
G1–G9 通用构建能力方案的 PR-A(共三个 PR,单版本 0.0.95,本 PR 不 bump 版本;版本与发布随 PR-C)。设计文档随本 PR 入库:
.agents/docs/2026-07-17-mcpp-feature-requests.md(需求清单 G1–G9).agents/docs/2026-07-17-asm-sources-and-general-build-capabilities-design.md(设计 + PR 拆分)内容(G1 + G7 收口 + G8a)
汇编源一等公民
.S/.s(GAS)→ 新asm_object规则(C 驱动,asm 安全旗标子集:无-std/-O,保留 PIC/-g/工具链定位旗标——hermetic 原则,绝不落宿主as).asm(NASM)→ 新nasm_object规则,-f由Triple::nasm_format()从目标三元组推导(elf64/win64/macho64/...,交叉构建零特判);%include经-MD/-MQ进 ninja depssrc/**/*.{cppm,cpp,cc,c,S,s,asm};汇编对象名带全扩展限定(foo.asm.o),同 stem 的.c/.asm兄弟不撞对象pick_rule、CDB(.asm不进compile_commands.json)-D/-U/-I子集(feature defines 因此对汇编生效)nasm 供给(G7 mcpp 侧)
.asm单元:PATH → mcpp 沙箱 →xlings install nasm;floor ≥2.16;不可得硬失败,绝不静默跳过.asm、MSVC 工具链遇.S均硬报错并给出门控指引G8a:glob 跟目录软链接
path_matches_glob用fs::relative(canonicalize)导致软链路径永不匹配的问题 →lexically_relative测试
Triple::nasm_format全矩阵、asm/nasm 规则 emit、asm 旗标过滤、CDB 排除、scanner 跳扫、软链 glob104_asm_sources_gas.sh(默认 glob→构建→运行→增量→build/test 双路径)、105_asm_sources_nasm.sh(-f推导、%include依赖追踪、CDB 排除);run_all.sh增nasmcapability~/.xlings/datagcc 路径等)/ 5 跳(平台性)后续
PR-B(声明式清单能力:features.sources / generated_files / cfg 条件 sources / per-glob flags)→ PR-C(build.mcpp 环境契约 + cross + 依赖包执行,bump 0.0.95 并发布)。