Skip to content

Commit 7253a9f

Browse files
committed
fix(build): the scan's -o and -fdeps-target are different under the split shape
拆分调度下这两者必须分开,我让它们共用了 `$compile_target`: 扫描边于是去写 `gcm.cache/<mod>.gcm`,而那个目录此时还不存在 —— cc1plus: fatal error: opening output file gcm.cache/fx.unit_19.gcm: No such file or directory **在 mcpp 自己的仓库上它没暴露**,因为 gcm.cache 早被上一次构建建好了; 换一个全新工程(bench 的 fixture)立刻失败。这正是"只在开发它的那个工程上验过" 会漏掉的东西 —— 也是要有独立对照组的理由。 `-o` 回到目标文件,`-fdeps-target` 单独走 `$deps_target`(拆分时指向 BMI, 让 dyndep 绑到 BMI 边)。
1 parent 1b9e67e commit 7253a9f

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/build/ninja_backend.cppm

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ std::string emit_ninja_string(const BuildPlan& plan) {
972972
// GCC path: compiler-integrated P1689 scanning.
973973
append(std::format(" command = $cxx{} $cxxflags $unit_cxxflags -fmodules "
974974
"-fdeps-format=p1689r5 "
975-
"-fdeps-file=$out -fdeps-target=$compile_target "
975+
"-fdeps-file=$out -fdeps-target=$deps_target "
976976
"-M -MM -MF $out.dep $unit_lang -E $in -o $compile_target\n",
977977
rsp_ref(scanPayload)));
978978
} else {
@@ -1200,10 +1200,18 @@ std::string emit_ninja_string(const BuildPlan& plan) {
12001200
ddi_paths.push_back(ddi);
12011201
append(std::format("build {} : cxx_scan {}{}\n", escape_ninja_path(ddi),
12021202
escape_ninja_path(cu.source), stagedOrderOnly));
1203-
// Under the split shape the dyndep file must bind the BMI edge —
1204-
// that is the edge whose inputs are the imported BMIs — so the
1205-
// scanner is told the BMI is the primary output.
1206-
append(std::format(" compile_target = {}\n",
1203+
// `-o` and `-fdeps-target` are DIFFERENT under the split shape and
1204+
// must not share a variable. The scan writes a throwaway object to
1205+
// `-o`, but the dyndep file has to bind the BMI edge — that is the
1206+
// edge whose inputs are the imported BMIs.
1207+
//
1208+
// Pointing both at the BMI made the SCAN try to create
1209+
// `gcm.cache/<mod>.gcm` before anything had made that directory:
1210+
// cc1plus: fatal error: opening output file gcm.cache/fx.unit_19.gcm
1211+
// It survived on this repository only because gcm.cache already
1212+
// existed there from an earlier build — a fresh project failed.
1213+
append(std::format(" compile_target = {}\n", escape_ninja_path(cu.object)));
1214+
append(std::format(" deps_target = {}\n",
12071215
splitBmi && cu.providesModule
12081216
? bmi_path(*cu.providesModule)
12091217
: escape_ninja_path(cu.object)));

0 commit comments

Comments
 (0)