bugfix: dyncall is not behind a #define
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 10 Mar 2023 22:59:23 +0000 (16:59 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 10 Mar 2023 22:59:23 +0000 (16:59 -0600)
compiler/build.sh
compiler/src/wasm_runtime.c

index 99fe9ff3cff5b4961ba3b227ecf3c0879e5999a0..da6f68bd1b454c33e6b12588eb527269c332307c 100755 (executable)
@@ -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"
 
index 7eee52a6588a34aba0cfdd835499c22361068352..0233a4f94b748e86fb59b756fd3c33a99fe9edc4 100644 (file)
@@ -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;