Skip to content

Commit 777215d

Browse files
castholmalexrp
authored andcommitted
Use -unknown when converting WASI/Emscripten target triples into LLVM triples
The "musl" part of the Zig target triples `wasm32-wasi-musl` and `wasm32-emscripten-musl` refers to the libc, not really the ABI. For WASM, most LLVM-based tooling uses `wasm32-wasi`, which is normalized into `wasm32-unknown-wasi`, with an implicit `-unknown` and without `-musl`. Similarly, Emscripten uses `wasm32-unknown-emscripten` without `-musl`. By using `-unknown` instead of `-musl` we get better compatibility with external tooling.
1 parent 26fdb81 commit 777215d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/codegen/llvm.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
264264
.eabihf => "eabihf",
265265
.android => "android",
266266
.androideabi => "androideabi",
267-
.musl => "musl",
267+
.musl => switch (target.os.tag) {
268+
// For WASI/Emscripten, "musl" refers to the libc, not really the ABI.
269+
// "unknown" provides better compatibility with LLVM-based tooling for these targets.
270+
.wasi, .emscripten => "unknown",
271+
else => "musl",
272+
},
268273
.muslabin32 => "musl", // Should be muslabin32 in LLVM 20.
269274
.muslabi64 => "musl", // Should be muslabi64 in LLVM 20.
270275
.musleabi => "musleabi",

0 commit comments

Comments
 (0)