Skip to content

Commit 37aa1e1

Browse files
StiensWoutcodexGrok 4.7
committed
fix(desktop): limit Linux bytecode generation to x64
Co-authored-by: GPT 6.1 Sol <[email protected]> Co-authored-by: Grok 4.7 <[email protected]>
1 parent 0fa0afb commit 37aa1e1

3 files changed

Lines changed: 31 additions & 20 deletions

File tree

‎docs/operations/development.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ options.
270270

271271
### Prepared server bytecode
272272

273-
Native macOS, Windows and Linux desktop artifact builds generate server bytecode with the packaged
274-
Electron executable, after ASAR creation and before signing. Generation imports the CLI and server
273+
Native macOS and Windows desktop artifact builds, and native Linux x64 builds, generate server
274+
bytecode with the packaged Electron executable, after ASAR creation and before signing. Generation imports the CLI and server
275275
module declarations without launching server services; worker-only modules compile normally.
276276
AppImage backends use temporary links for each mount and remove them on normal exit. Later launches
277277
reclaim abandoned cache directories whose links point to gone mounts; AppImage main-process caching
@@ -287,7 +287,7 @@ differ or resource permissions prevent linking. Protected installations therefor
287287
prepared bytecode. No cache bytes are copied during startup.
288288

289289
The key calculation follows Node's internal portable ESM format. Generation checks that the
290-
packaged engine produced the expected CLI entry and fails the build if that format changes.
290+
packaged engine produced the expected CLI and server entries and fails the build if that format changes.
291291
The manifest also checks Electron, Node, OS, architecture and V8's flags-sensitive version tag.
292292
Missing or rejected entries compile from the shipped JavaScript. Prepared backends skip the
293293
explicit startup flush; Node can persist missing entries on normal exit. The writable fallback

‎scripts/lib/server-compile-cache.test.ts‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,30 @@ import * as NodeURL from "node:url";
66
import { expect, it } from "vite-plus/test";
77
import { cacheKey, seedPreparedCache } from "./server-compile-cache.ts";
88

9-
it("skips prepared bytecode generation for unsupported platforms", async () => {
10-
const { spawnSync } = await import("node:child_process");
11-
const hook = NodeURL.fileURLToPath(
12-
new URL("../prepare-server-compile-cache.cjs", import.meta.url),
13-
);
14-
const result = spawnSync(
15-
process.execPath,
16-
[
17-
"-e",
18-
`Object.defineProperty(process, "platform", { value: "freebsd" });
19-
require(${JSON.stringify(hook)})({ electronPlatformName: "freebsd", arch: 1 }).catch(error => { console.error(error); process.exitCode = 1; });`,
20-
],
21-
{ encoding: "utf8" },
22-
);
23-
expect(result.status, result.stderr).toBe(0);
24-
expect(result.stdout).toContain("Skipping unsupported target freebsd");
25-
});
9+
it.each([
10+
{ platform: "freebsd", hostArch: "x64", arch: 1, reason: "unsupported target freebsd" },
11+
{ platform: "linux", hostArch: "arm64", arch: 3, reason: "unsupported Linux architecture arm64" },
12+
])(
13+
"skips unsupported $platform/$hostArch cache generation",
14+
async ({ platform, hostArch, arch, reason }) => {
15+
const { spawnSync } = await import("node:child_process");
16+
const hook = NodeURL.fileURLToPath(
17+
new URL("../prepare-server-compile-cache.cjs", import.meta.url),
18+
);
19+
const result = spawnSync(
20+
process.execPath,
21+
[
22+
"-e",
23+
`Object.defineProperty(process, "platform", { value: ${JSON.stringify(platform)} });
24+
Object.defineProperty(process, "arch", { value: ${JSON.stringify(hostArch)} });
25+
require(${JSON.stringify(hook)})({ electronPlatformName: ${JSON.stringify(platform)}, arch: ${arch} }).catch(error => { console.error(error); process.exitCode = 1; });`,
26+
],
27+
{ encoding: "utf8" },
28+
);
29+
expect(result.status, result.stderr).toBe(0);
30+
expect(result.stdout).toContain(`Skipping ${reason}`);
31+
},
32+
);
2633

2734
// macOS runs on an ARM64 host to exercise the Rosetta build-host check.
2835
it.each([

‎scripts/prepare-server-compile-cache.cjs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ module.exports = async ({ appOutDir, electronPlatformName, arch, packager }) =>
1111
return;
1212
}
1313
const targetArch = ["ia32", "x64", "armv7l", "arm64", "universal"][arch];
14+
if (electronPlatformName === "linux" && targetArch !== "x64") {
15+
console.log(`[server-compile-cache] Skipping unsupported Linux architecture ${targetArch}`);
16+
return;
17+
}
1418
const runsWithRosetta =
1519
electronPlatformName === "darwin" &&
1620
process.platform === "darwin" &&

0 commit comments

Comments
 (0)