fix(build): feature sources 在 mcpp test 下不编译 (0.0.94)#218
Merged
Conversation
prepare_build() 把 feature 源集解析(drop + add)整段门在 `!includeDevDeps`, `mcpp test` 走 includeDevDeps=true → 激活 feature 的 sources 从不被加回构建图。 xpkg 的 `features.X.sources` 只落进 featureSources、从不进 base sources,故 「只在 features 下声明」的包 build 正常、test 必然 undefined reference。 命中 compat.cjson `utils`、compat.eigen `eigen_blas`(dgemm_)、compat.spdlog `compiled`。eigen_blas 的 dgemm_ 一直被记为「链进 test 二进制是 follow-up」, 定性是错的:不是链接问题,是源集解析问题。 drop 仍只在 build 模式做(test 模式需保留完整源面供 dev-dep 轨 per-test main 检测剪枝,见 e2e 79);add 改为两模式都做 + 去重(gtest 双列 glob 不会进两次)。 回归测试 e2e 100:已验证在未修复的 0.0.92 上以目标错误失败、修复后通过; e2e 78/79(#168 gtest 回归靶子)与单测 35/35 均通过。
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.
根因
prepare_build()把 feature 源集解析(drop + add)整段门在!includeDevDeps(
src/build/prepare.cppm),而mcpp test走includeDevDeps = true→ 激活feature 的 sources 从不被加回构建图。
叠加 xpkg 侧的事实:
features.X.sources只落进buildConfig.featureSources[X](
src/manifest/xpkg.cppm),从不进 basesources。两者一合:mcpp buildmcpp testsources和features(gtest 的gtest_main.cc)features下(xpkg 常态)undefined reference那段注释原本假设「descriptor 会把 gtest_main.cc 同时留在 base sources 里,故 test
模式不受影响」——这个前提只对 gtest 成立,是个未被察觉的隐式耦合。门自 #169
(0.0.65,修 #168 gtest_main LNK2005)引入后未动过。
命中面
compat.cjson的utils→cJSONUtils_*compat.eigen的eigen_blas→dgemm_compat.spdlog的compiled(mcpp-index feat: mcpp self init + ensure_base_init_ok + bootstrap residue cleanup #72 正因此误判为「引擎不支持 feature sources」)eigen_blas的dgemm_一直被记为「把 feature 编出的依赖目标链进 test 二进制是follow-up」——定性是错的:不是链接问题,是源集解析问题。
修复
mcpp test需要保留完整源面,让 dev-dep 轨的per-test main 检测看得见
gtest_main.cc并逐 test 剪枝(e2e 79 锁住)。净 diff 4 行逻辑。
验证
(
undefined reference to cJSONUtils_FindPointerFromObjectTo);修复后 → OK。三段断言:test 模式必须编译+链接 feature sources / build 模式仍正常 /
不请求 feature 时 gated 源仍被排除(防「无条件全加」)。