Skip to content

Commit c71eecb

Browse files
committed
Try musl fixes
1 parent d9af624 commit c71eecb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

build/ui.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ import { bold, cyan, yellow } from "jsr:@std/fmt@1/colors";
22
import { ensureDeps } from "./deps.ts";
33
import { exec, getEnvVars, getSysrootEnv } from "./util.ts";
44

5+
// Detect if running on musl libc (e.g., Alpine Linux)
6+
async function isMusl(): Promise<boolean> {
7+
if (Deno.build.os !== "linux") {
8+
return false;
9+
}
10+
try {
11+
await Deno.stat("/etc/alpine-release");
12+
return true;
13+
} catch {
14+
// Also check for musl by looking at ldd
15+
try {
16+
const cmd = new Deno.Command("ldd", { args: ["--version"], stderr: "piped" });
17+
const { stderr } = await cmd.output();
18+
return new TextDecoder().decode(stderr).toLowerCase().includes("musl");
19+
} catch {
20+
return false;
21+
}
22+
}
23+
}
24+
525
// Build Tauri UI
626
export async function buildUi(target?: string, debug = false) {
727
// Ensure dependencies are set up
@@ -77,6 +97,12 @@ export async function buildUi(target?: string, debug = false) {
7797
Object.assign(env, getSysrootEnv(target));
7898
}
7999

100+
// On musl (Alpine), GTK must be dynamically linked
101+
if (platform === "desktop" && await isMusl()) {
102+
const existingFlags = env.RUSTFLAGS || "";
103+
env.RUSTFLAGS = `${existingFlags} -C target-feature=-crt-static`.trim();
104+
}
105+
80106
await exec(buildArgs, env);
81107
Deno.chdir("..");
82108
}

0 commit comments

Comments
 (0)