Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- Supports LLVM 18 - 22.
- WebAssembly: `extern(C) main` is now mangled as `__main_void` or `__main_argc_argv` as appropriate, matching Clang behavior (#5186).
- WASI: `ldc2` will search for `wasm32-wasip1-clang` or `wasm32-wasip2-clang` (from [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk/)) to use as the cross-compiler AND link driver (instead of linking using `wasm-ld` directly) ((#5158, #5207).
- WASI: `core.sys.wasi.p1` provides bindings to WASIp1 "syscalls" (#5186). WASIp2 is currently limited to emulated POSIX from `wasi-libc`.

#### Bug fixes

Expand Down
27 changes: 21 additions & 6 deletions runtime/druntime/src/core/internal/abort.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,31 @@ void abort(scope string msg, scope string filename = __FILE__, size_t line = __L
}
}
else version (WASIp1) {
import core.sys.wasi.p1 : CIOVec, fdWrite;
// currently depends on wasi-libc being linked in to provide these "syscalls"
// TODO: detach this from wasi-libc
alias ushort __wasi_errno_t;
alias int __wasi_fd_t;
alias size_t __wasi_size_t;

extern(C) struct __wasi_ciovec_t {
const(ubyte)* buf;
__wasi_size_t buf_len;
}

pragma(mangle, "__wasi_fd_write")
extern(C) static __wasi_errno_t
__wasi_fd_write(__wasi_fd_t fd,
const __wasi_ciovec_t *iovs,
size_t iovs_len, __wasi_size_t *retptr0) @nogc nothrow;

static void writeStr(scope const(char)[][] m...) @nogc nothrow @trusted
{
foreach (s; m) {
CIOVec[1] iovecs;
size_t bytesWritten;
iovecs[0].buf = cast(const(ubyte)*)s.ptr;
iovecs[0].bufLen = s.length;
cast(void)fdWrite(2, iovecs[], bytesWritten);
__wasi_ciovec_t iovec;
__wasi_size_t ret;
iovec.buf = cast(const(ubyte)*)s.ptr;
iovec.buf_len = s.length;
cast(void)__wasi_fd_write(2, &iovec, 1, &ret);
}
}
} else version (WASIp2) {
Expand Down
Loading
Loading