From 04c3efc3c3b0cc3dbefb97fbba33f76679e33e01 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 20 Dec 2021 00:32:27 +0100 Subject: [PATCH] Update assert for WASM --- src/compiler/llvm_codegen_stmt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index a88975e1a..d5fc2b860 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -1099,7 +1099,9 @@ void llvm_emit_debug_output(GenContext *c, const char *message, const char *file int line_index; int expr_index; int func_index = -1; - switch (platform_target.os) + OsType os = platform_target.os; + if (platform_target.arch == WASM32 || platform_target.arch == WASM64) os = OS_TYPE_WASI; + switch (os) { case OS_TYPE_WIN32: name = "_assert"; @@ -1122,6 +1124,7 @@ void llvm_emit_debug_output(GenContext *c, const char *message, const char *file func_index = 3; break; case OS_TYPE_LINUX: + case OS_TYPE_WASI: name = "__assert_fail"; expr_index = 0; file_index = 1; @@ -1157,6 +1160,7 @@ void llvm_emit_debug_output(GenContext *c, const char *message, const char *file break; } case OS_DARWIN_TYPES: + case OS_TYPE_WASI: case OS_TYPE_LINUX: case OS_TYPE_SOLARIS: {