From de6f586b6fb147ee64f5cffac308c46a13da2104 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 10 Mar 2023 16:59:23 -0600 Subject: [PATCH] bugfix: dyncall is not behind a #define --- compiler/build.sh | 4 ++-- compiler/src/wasm_runtime.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/compiler/build.sh b/compiler/build.sh index 99fe9ff3..da6f68bd 100755 --- a/compiler/build.sh +++ b/compiler/build.sh @@ -6,7 +6,7 @@ ENABLE_DEBUG_INFO=1 C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser symres types utils wasm_emit wasm_runtime " -LIBS="-L$CORE_DIR/lib -l$RUNTIME_LIBRARY -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl -lm -ldyncall_s" +LIBS="-L$CORE_DIR/lib -l$RUNTIME_LIBRARY -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl -lm -l:libdyncall_s.a" INCLUDES="-I./include -I../shared/include -I../shared/include/dyncall" WARNINGS='-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wmaybe-uninitialized -Wsign-compare -Wstrict-overflow -Wduplicated-branches -Wduplicated-cond -Wtrigraphs -Waddress -Wlogical-op' @@ -25,7 +25,7 @@ if [ "$ENABLE_DEBUG_INFO" = "1" ]; then FLAGS="$FLAGS -DENABLE_DEBUG_INFO" fi -FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER" +FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER -DUSE_DYNCALL" sudo mkdir -p "$BIN_DIR" diff --git a/compiler/src/wasm_runtime.c b/compiler/src/wasm_runtime.c index 7eee52a6..0233a4f9 100644 --- a/compiler/src/wasm_runtime.c +++ b/compiler/src/wasm_runtime.c @@ -5,6 +5,11 @@ #include "onyx_library.h" #include "dyncall.h" +#ifdef USE_DYNCALL + #include "dyncall.h" + static DCCallVM *dcCallVM; +#endif + #ifndef USE_OVM_DEBUGGER #include "wasmer.h" #endif @@ -25,9 +30,6 @@ wasm_instance_t* wasm_instance; wasm_module_t* wasm_module; wasm_memory_t* wasm_memory; -// @Temporary -static DCCallVM *dcCallVM; - OnyxRuntime wasm_runtime; b32 wasm_name_equals(const wasm_name_t* name1, const wasm_name_t* name2) { @@ -198,6 +200,8 @@ static void lookup_and_load_custom_libraries(LinkLibraryContext *ctx, bh_arr(Was } +#ifdef USE_DYNCALL + typedef struct DynCallContext { void (*func)(); char types[64]; @@ -285,6 +289,8 @@ static wasm_func_t *link_and_prepare_dyncall_function( return wasm_func; } +#endif // USE_DYNCALL + static void onyx_print_trap(wasm_trap_t* trap) { wasm_message_t msg; wasm_trap_message(trap, &msg); @@ -366,6 +372,7 @@ static b32 link_wasm_imports( } } +#ifdef USE_DYNCALL if (wasm_name_starts_with(module_name, "dyncall:")) { wasm_name_t library_name = *module_name; library_name.data += 8; @@ -387,6 +394,7 @@ static b32 link_wasm_imports( import = wasm_func_as_extern(wasm_func); goto import_found; } +#endif bh_arr_each(WasmFuncDefinition **, library_funcs, linkable_functions) { WasmFuncDefinition **pcurrent_function = *library_funcs; -- 2.25.1