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:33+01:00
log777215d78bd49597dc0b369c8b71765a0e5d338c
tree0b2278b712dc84ebeed4367448131c89545ae3e6
parent26fdb81c16760b5aabbd1905ef96cefdf596fc3d

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
...@@ -264,7 +264,12 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -264,7 +264,12 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
264 .eabihf => "eabihf",264 .eabihf => "eabihf",
265 .android => "android",265 .android => "android",
266 .androideabi => "androideabi",266 .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 },
268 .muslabin32 => "musl", // Should be muslabin32 in LLVM 20.273 .muslabin32 => "musl", // Should be muslabin32 in LLVM 20.
269 .muslabi64 => "musl", // Should be muslabi64 in LLVM 20.274 .muslabi64 => "musl", // Should be muslabi64 in LLVM 20.
270 .musleabi => "musleabi",275 .musleabi => "musleabi",