Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(build): wipe WGC build dir on target-arch change to prevent stale-compiler wrong-arch binaries

Christian Schmittel1cbc4ee56147
diff --git a/scripts/build-windows-wgc-helper.mjs b/scripts/build-windows-wgc-helper.mjs
index 0c75d5680..db9b5cb7c 100644
--- a/scripts/build-windows-wgc-helper.mjs
+++ b/scripts/build-windows-wgc-helper.mjs
@@ -94,7 +94,21 @@ if (process.platform !== "win32") {
console.log(`Building Windows WGC helper for target arch: ${TARGET_ARCH} (vcvars: ${VCVARS_ARCH})`);
+// CMake caches the detected compiler in the build directory. Reusing a build
+// dir that was configured for a different target arch silently produces
+// wrong-arch binaries (the cached compiler wins over the new vcvars env). Wipe
+// the build dir when the target arch changes; same-arch reruns stay incremental.
+const ARCH_STAMP = path.join(BUILD_DIR, ".target-arch");
+if (fs.existsSync(BUILD_DIR)) {
+ const previousArch = fs.existsSync(ARCH_STAMP)
+ ? fs.readFileSync(ARCH_STAMP, "utf8").trim()
+ : "";
+ if (previousArch !== TARGET_ARCH) {
+ fs.rmSync(BUILD_DIR, { recursive: true, force: true });
+ }
+}
fs.mkdirSync(BUILD_DIR, { recursive: true });
+fs.writeFileSync(ARCH_STAMP, TARGET_ARCH);
await runInVsEnv(
`"${CMAKE}" -S "${SOURCE_DIR}" -B "${BUILD_DIR}" -G Ninja -DCMAKE_BUILD_TYPE=Release`,