# The architecture of your system. If your not sure, leave this alone.
ARCH="$(uname -m)"
-RUNTIME_LIBRARY="wasmer"
+RUNTIME_LIBRARY="ovmwasm"
+# RUNTIME_LIBRARY="wasmer"
-# Comment this line if you do not want the Wamser libraries installed,
+# Comment this line if you do not want the above library installed,
# and do not with to have the Onyx runtime.
-ENABLE_BUNDLING_WASMER=1
+ENABLE_BUNDLING_WASM_RUNTIME=1
# Where the Wasmer library files can be found.
# They are bundled with the project, but if a different version is available, these can be changed.
C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser symres types utils wasm_emit"
LIBS=
-INCLUDES=
+INCLUDES="-I./include"
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'
+TARGET="./bin/onyx"
if [ "$1" = "debug" ]; then
- FLAGS="$WARNINGS -g3 -I./include"
- TARGET="./bin/onyx-debug"
+ FLAGS="$WARNINGS -g3"
else
- FLAGS="$WARNINGS -O3 -I./include"
- TARGET='./bin/onyx'
+ FLAGS="$WARNINGS -O3"
+fi
+
+if [ "$RUNTIME_LIBRARY" = "ovmwasm" ]; then
+ FLAGS="$FLAGS -DUSE_OVM_DEBUGGER"
fi
-if [ ! -z "$ENABLE_BUNDLING_WASMER" ]; then
+if [ ! -z "$ENABLE_BUNDLING_WASM_RUNTIME" ]; then
C_FILES="$C_FILES wasm_runtime"
FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER"
LIBS="$LIBS -L$CORE_DIR/lib -l$RUNTIME_LIBRARY -Wl,-rpath=$CORE_DIR/lib:./ -lpthread -ldl -lm"
sudo mkdir -p "$CORE_DIR/lib"
sudo mkdir -p "$CORE_DIR/include"
- # sudo cp "$WASMER_LIBRARY_DIR/libiwasm.so" "$CORE_DIR/lib/libiwasm.so"
- # sudo cp "$WASMER_LIBRARY_DIR/libwasmer.so" "$CORE_DIR/lib/libwasmer.so"
sudo cp "$WASMER_LIBRARY_DIR/lib$RUNTIME_LIBRARY.so" "$CORE_DIR/lib/lib$RUNTIME_LIBRARY.so"
sudo cp "include/onyx_library.h" "$CORE_DIR/include/onyx_library.h"
sudo mkdir -p "$BIN_DIR"
sudo cp ./bin/onyx "$BIN_DIR/onyx"
-if [ ! -z "$ENABLE_BUNDLING_WASMER" ]; then
+if [ ! -z "$ENABLE_BUNDLING_WASM_RUNTIME" ]; then
C_FILES="onyxrun wasm_runtime"
TARGET="./bin/onyx-run"
}
greatest :: macro (arr: [] $T) -> (i32, T) {
+ fold_idx_elem :: fold_idx_elem
return fold_idx_elem(arr, #(*A > *B));
}
least :: macro (arr: [] $T) -> (i32, T) {
+ fold_idx_elem :: fold_idx_elem
return fold_idx_elem(arr, #(*A < *B));
}
#define bh_align(x, a) if ((x) % (a) != 0) (x) += (a) - ((x) % (a));
-#define bh_pointer_add(ptr, amm) ((void *)((u8 *) ptr + amm))
+#define bh_pointer_add(ptr, amm) ((void *)((u8 *) (ptr) + (amm)))
#define BH_BIT(x) (1 << (x))
#define BH_MASK_SET(var, set, mask) ((set) ? ((var) |= (mask)) : ((var) &= ~(mask)))
onyx_wasm_module_write_to_file(data_module, data_file);
onyx_wasm_module_write_to_file(context.wasm_module, output_file);
+ bh_file_close(&data_file);
} else {
onyx_wasm_module_write_to_file(context.wasm_module, output_file);
}
+ bh_file_close(&output_file);
+
if (context.options->documentation_file != NULL) {
OnyxDocumentation docs = onyx_docs_generate();
docs.format = Doc_Format_Human;
#include "utils.h"
#include "astnodes.h"
#include "wasm.h"
-#include "wasmer.h"
#include "onyx_library.h"
+#ifndef USE_OVM_DEBUGGER
+ #include "wasmer.h"
+#endif
+
#ifdef _BH_LINUX
#include <pthread.h>
#include <signal.h>
bh_arr_new(bh_heap_allocator(), linkable_functions, 4);
onyx_lookup_and_load_custom_libraries(wasm_bytes);
- wasmer_features_t* features = NULL;
wasm_trap_t* run_trap = NULL;
wasm_config = wasm_config_new();
if (!wasm_config) goto error_handling;
+#ifndef USE_OVM_DEBUGGER
// Prefer the LLVM compile because it is faster. This should be configurable from the command line and/or a top-level directive.
if (wasmer_is_compiler_available(LLVM)) {
wasm_config_set_compiler(wasm_config, LLVM);
}
- features = wasmer_features_new();
+ wasmer_features_t* features = wasmer_features_new();
wasmer_features_simd(features, 1);
wasmer_features_threads(features, 1);
wasmer_features_bulk_memory(features, 1);
wasm_config_set_features(wasm_config, features);
+#endif
wasm_engine = wasm_engine_new_with_config(wasm_config);
if (!wasm_engine) goto error_handling;
wasm_module_imports(wasm_module, &module_imports);
wasm_imports = (wasm_extern_vec_t) WASM_EMPTY_VEC;
- // wasm_imports.data = malloc(module_imports.size * 64);
- // wasm_imports.size = module_imports.size;
wasm_extern_vec_new_uninitialized(&wasm_imports, module_imports.size); // @Free
fori (i, 0, (i32) module_imports.size) {
wasm_val_vec_t args;
wasm_val_vec_t results;
wasm_val_vec_new_uninitialized(&args, 0);
+ wasm_val_vec_new_uninitialized(&results, 1);
run_trap = wasm_func_call(start_func, &args, &results);
error_handling:
bh_printf("An error occured trying to run the WASM module...\n");
+
+#ifndef USE_OVM_DEBUGGER
i32 len = wasmer_last_error_length();
char *buf = alloca(len + 1);
wasmer_last_error_message(buf, len);
bh_printf("%b\n", buf, len);
+#endif
cleanup:
if (wasm_instance) wasm_instance_delete(wasm_instance);