authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2025-03-23 14:14:42+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-24 07:04:51+01:00
loge62a3ea74eb4d019a3360f666700579ca6b30cb9
treee192a15eefe840518593c41d873eba08f4e8e6c1
parenteedfce92b0363af1b6783ab626690be0aebf4e94
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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 files changed, 6 insertions(+), 1 deletions(-)

src/codegen/llvm.zig+6-1
......@@ -265,7 +265,12 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
265265 .eabihf => "eabihf",
266266 .android => "android",
267267 .androideabi => "androideabi",
268 .musl => "musl",
268 .musl => switch (target.os.tag) {
269 // For WASI/Emscripten, "musl" refers to the libc, not really the ABI.
270 // "unknown" provides better compatibility with LLVM-based tooling for these targets.
271 .wasi, .emscripten => "unknown",
272 else => "musl",
273 },
269274 .muslabin32 => "musl", // Should be muslabin32 in LLVM 20.
270275 .muslabi64 => "musl", // Should be muslabi64 in LLVM 20.
271276 .musleabi => "musleabi",