Skip to content

Commit 2f0774f

Browse files
committed
fix: Windows ninja rules — skip BMI restat (requires POSIX shell)
The cxx_module rule used shell commands (if/cp/cmp/mv/rm) for BMI restat optimization. These don't work on Windows cmd.exe. Skip the restat on Windows — dyndep still provides correct incremental builds.
1 parent a3b53ff commit 2f0774f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/build/ninja_backend.cppm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ std::string emit_ninja_string(const BuildPlan& plan) {
220220
std::string module_output_flag = traits.needsExplicitModuleOutput
221221
? " -fmodule-output=$bmi_out" : "";
222222
append("rule cxx_module\n");
223+
#if defined(_WIN32)
224+
// Windows: skip BMI restat optimization (requires POSIX shell).
225+
// Just compile directly — incremental rebuild still works via dyndep.
226+
append(std::format(" command = "
227+
"$toolenv $cxx $cxxflags{} -c $in -o $out\n", module_output_flag));
228+
#else
223229
append(std::format(" command = "
224230
"if [ -n \"$bmi_out\" ] && [ -f \"$bmi_out\" ]; then "
225231
"cp -p \"$bmi_out\" \"$bmi_out.bak\"; "
@@ -231,6 +237,7 @@ std::string emit_ninja_string(const BuildPlan& plan) {
231237
"else "
232238
"rm -f \"$bmi_out.bak\"; "
233239
"fi\n", module_output_flag));
240+
#endif
234241
append(" description = MOD $out\n");
235242
if (dyndep)
236243
append(" restat = 1\n");

0 commit comments

Comments
 (0)