Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(build): check every shipped Windows binary's architecture, and refuse a partial x64 whisper fallback
Christian Schmittelc3e2e98a773f
diff --git a/scripts/before-pack.cjs b/scripts/before-pack.cjsindex f71802635..ea96e59c1 100644--- a/scripts/before-pack.cjs+++ b/scripts/before-pack.cjs@@ -475,29 +475,32 @@ function checkWinNoRedistDependency(dir) {);}- // A colocated copy only counts when the loader can use it, and the name check above- // cannot tell: the Redist tree holds an x64 and an arm64 vcomp140.dll under the same- // name, and either one satisfies `shipped`. The x64 loader refuses the arm64 copy- // with the same 0xC0000135 as a missing file.+ // Every binary here must be built for this directory's architecture, and none of the+ // checks above can tell: the right name and clean imports say nothing about the+ // machine. An x64 compositor addon in win32-arm64 fails require() on every ARM64+ // device, and the Redist tree holds an x64 and an arm64 vcomp140.dll under the same+ // name, so either satisfies `shipped` while the loader refuses the wrong one with+ // the same 0xC0000135 as a missing file.//- // Only the copies something here imports. The arm64 Redist folder carries a- // vcruntime140_1.dll whose header says x64 — it is the ARM64EC build Microsoft ships- // for emulated x64 code — and no ARM64 binary loads it, so its machine is irrelevant.+ // The one exception is a runtime DLL that nothing here imports. The arm64 Redist+ // folder carries a vcruntime140_1.dll whose header says x64 — it is the ARM64EC build+ // Microsoft ships for emulated x64 code — and no ARM64 binary loads it.const dirArch = path.basename(dir).match(/^win32-(.+)$/)?.[1];if (!dirArch) {return;}const imported = new Set(scanned.flatMap((entry) => entry.imports.map((d) => d.toLowerCase())));- const wrongArch = files- .filter((name) => VC_REDIST_DLL.test(name) && imported.has(name.toLowerCase()))- .map((name) => ({ name, arch: peArch(path.join(dir, name)) }))+ const wrongArch = scanned+ .filter(({ name }) => !VC_REDIST_DLL.test(name) || imported.has(name.toLowerCase()))+ .map(({ name }) => ({ name, arch: peArch(path.join(dir, name)) })).filter((entry) => entry.arch !== dirArch);if (wrongArch.length > 0) {throw new Error(- "Refusing to package Visual C++ runtime DLLs built for the wrong architecture.\n\n" ++ "Refusing to package native binaries built for the wrong architecture.\n\n" +`${wrongArch.map((e) => ` - ${e.name} in ${path.basename(dir)} is built for ${e.arch ?? "an unknown machine"}`).join("\n")}\n\n` +- "The loader skips a DLL for another architecture as if it were absent. Stage the\n" +- `${dirArch} copy from VC\\Redist\\MSVC\\<version>\\${dirArch}\\ — scripts/stage-vcomp-runtime.mjs does.`,+ `A ${dirArch} process cannot load them. Rebuild or re-fetch them for ${dirArch}; for the\n` ++ `Visual C++ runtime, stage the copy from VC\\Redist\\MSVC\\<version>\\${dirArch}\\ —\n` ++ "scripts/stage-vcomp-runtime.mjs does.",);}}diff --git a/scripts/before-pack.test.mjs b/scripts/before-pack.test.mjsindex 6abd46a8c..e39e9e041 100644--- a/scripts/before-pack.test.mjs+++ b/scripts/before-pack.test.mjs@@ -458,4 +458,18 @@ describe("checkWinShippedRedist", () => {expect(() => testing().checkWinShippedRedist(bin)).not.toThrow();});});++ // Not only the runtime: an x64 compositor addon in win32-arm64 has the right name and+ // clean imports, and an ARM64 process still cannot load it.+ it("refuses any native binary built for the other architecture", () => {+ const arm64 = {+ ...arm64Native,+ "compositor_view.node": pe(MACHINE.x64, ["KERNEL32.dll"]),+ };+ withWinBin({ "win32-arm64": arm64 }, (bin) => {+ expect(() => testing().checkWinShippedRedist(bin)).toThrow(+ /compositor_view\.node in win32-arm64 is built for x64/,+ );+ });+ });});diff --git a/scripts/stage-vcomp-runtime.mjs b/scripts/stage-vcomp-runtime.mjsindex 4218fc2f9..1ebf96893 100644--- a/scripts/stage-vcomp-runtime.mjs+++ b/scripts/stage-vcomp-runtime.mjs@@ -68,16 +68,32 @@ const DLLS = [// cannot stand in for it — the x64 loader skips a DLL of another architecture as if it// were absent — so on a machine without the x64 Redistributable transcription died in// the loader. That is the only x64 import there; whisper-stt-server.exe needs no CRT.-const STAGINGS = [{ arch: TARGET_ARCH, names: DLLS }];-if (TARGET_ARCH === "arm64" && fs.existsSync(path.join(binDir("x64"), "ggml-base.dll"))) {- STAGINGS.push({ arch: "x64", names: ["vcomp140.dll"] });-}+//+// Keyed off the server, not off a library: a server staged without the two libraries+// that import OpenMP is a fallback that cannot start, and skipping the runtime for it+// would let that package through. Refuse it here instead.+const X64_WHISPER_OPENMP_LIBS = ["ggml-base.dll", "ggml-cpu.dll"];if (process.platform !== "win32") {console.log("Skipping Visual C++ runtime staging: Windows-only.");process.exit(0);}+const STAGINGS = [{ arch: TARGET_ARCH, names: DLLS }];+if (TARGET_ARCH === "arm64" && fs.existsSync(path.join(binDir("x64"), "whisper-stt-server.exe"))) {+ const absent = X64_WHISPER_OPENMP_LIBS.filter(+ (name) => !fs.existsSync(path.join(binDir("x64"), name)),+ );+ if (absent.length > 0) {+ throw new Error(+ `win32-x64 holds whisper-stt-server.exe but not ${absent.join(", ")}.\n\n` ++ "The arm64 installer would ship an x64 transcription fallback that cannot start.\n" ++ "Stage the helper as a whole: bash scripts/stage-whisper-stt.sh win32-x64",+ );+ }+ STAGINGS.push({ arch: "x64", names: ["vcomp140.dll"] });+}+/*** Every vcomp140.dll under a Visual Studio redistributable directory.*