From 887a368eab86315cdd8fedbd6b16b1714736db05 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 16 Nov 2023 15:35:14 -0600 Subject: [PATCH] changed: simplifying build process --- .github/workflows/onyx-build.yml | 24 +++++------------------- compiler/build.sh | 32 ++++++++++++++++++++++++-------- interpreter/build.sh | 2 +- runtime/onyx_runtime.c | 5 ++++- runtime/src/ort_net_linux.h | 2 -- settings.sh | 8 ++------ 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.github/workflows/onyx-build.yml b/.github/workflows/onyx-build.yml index 32e4116a..c6fe092d 100644 --- a/.github/workflows/onyx-build.yml +++ b/.github/workflows/onyx-build.yml @@ -27,7 +27,7 @@ jobs: artifact_name: 'onyx-linux-ovm-amd64' - build: linux-amd64 os: ubuntu-latest - runtime_library: ':libwasmer.a' + runtime_library: wasmer artifact_name: 'onyx-linux-wasmer-amd64' - build: linux-amd64 os: ubuntu-latest @@ -49,20 +49,10 @@ jobs: mkdir -p build - name: Install Linux building dependencies - if: matrix.runtime_library == ':libwasmer.a' + if: matrix.runtime_library == 'wasmer' run: | curl https://get.wasmer.io -sSfL | sh - - name: Setup environment variables for Wasmer - if: matrix.runtime_library == ':libwasmer.a' - run: | - echo "ONYX_LIBRARY_DIR=/home/runner/.wasmer/lib" >> "$GITHUB_ENV" - - - name: Setup environment variables for OVM-Wasm - if: matrix.runtime_library != ':libwasmer.a' - run: | - echo "ONYX_LIBRARY_DIR=../shared/lib/linux_x86_64/lib" >> "$GITHUB_ENV" - - name: Install Windows building dependencies if: matrix.build == 'windows-amd64' uses: ilammy/msvc-dev-cmd@v1 @@ -73,10 +63,8 @@ jobs: ./build.sh compile package env: ONYX_CC: gcc - ONYX_ARCH: x86_64 + ONYX_ARCH: linux_x86_64 ONYX_RUNTIME_LIBRARY: ${{ matrix.runtime_library }} - ONYX_INCLUDE_DIR: ../shared/include - ONYX_LIBRARY_DIR: ${{ env.ONYX_LIBRARY_DIR }} ONYX_USE_DYNCALL: '1' - name: Build Onyx for ${{ matrix.build }} @@ -85,8 +73,7 @@ jobs: ./build.sh compile package env: ONYX_CC: gcc - ONYX_ARCH: x86_64 - ONYX_INCLUDE_DIR: ../shared/include + ONYX_ARCH: linux_x86_64 - name: Build Onyx for ${{ matrix.build }} if: (matrix.build == 'darwin-arm64') && (matrix.runtime_library == 'none') @@ -94,8 +81,7 @@ jobs: ./build.sh compile package env: ONYX_CC: gcc - ONYX_ARCH: arm64 - ONYX_INCLUDE_DIR: ../shared/include + ONYX_ARCH: darwin_arm64 - name: Build Onyx for ${{ matrix.build }} if: matrix.build == 'windows-amd64' diff --git a/compiler/build.sh b/compiler/build.sh index 5da5304c..1f582fe9 100755 --- a/compiler/build.sh +++ b/compiler/build.sh @@ -1,7 +1,7 @@ #!/bin/sh C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser symres types utils wasm_emit " -LIBS="-L$ONYX_LIBRARY_DIR -lpthread -ldl -lm" +LIBS="-lpthread -ldl -lm" 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' @@ -12,20 +12,36 @@ else FLAGS="$WARNINGS -O3" fi +FLAGS="$FLAGS -DENABLE_DEBUG_INFO" + if [ ! -z ${ONYX_RUNTIME_LIBRARY+x} ]; then FLAGS="$FLAGS -DENABLE_RUN_WITH_WASMER" C_FILES="${C_FILES}wasm_runtime " - LIBS="-l$ONYX_RUNTIME_LIBRARY $LIBS" + case "${ONYX_RUNTIME_LIBRARY}" in + ovmwasm) + LIBS="../shared/lib/$ONYX_ARCH/lib/libovmwasm.a $LIBS" + FLAGS="$FLAGS -DUSE_OVM_DEBUGGER" + ;; + + wasmer) + LIBS="$(wasmer config --libdir)/libwasmer.a $LIBS" + ;; + + *) + echo "Unknown WebAssembly runtime '$ONYX_RUNTIME_LIBRARY'. Aborting."; + exit 1 + ;; + esac fi -if [ "$ONYX_RUNTIME_LIBRARY" = "ovmwasm" ]; then - FLAGS="$FLAGS -DUSE_OVM_DEBUGGER" -fi - -FLAGS="$FLAGS -DENABLE_DEBUG_INFO" +case "$ONYX_ARCH" in + *darwin*) + LIBS="$LIBS -lffi -lSystem -framework CoreFoundation -framework SystemConfiguration" + ;; +esac if [ "$ONYX_USE_DYNCALL" = "1" ] && [ "$ONYX_RUNTIME_LIBRARY" = "ovmwasm" ]; then - LIBS="$LIBS ../shared/lib/linux_$ONYX_ARCH/lib/libdyncall_s.a ../shared/lib/linux_$ONYX_ARCH/lib/libdyncallback_s.a" + LIBS="$LIBS ../shared/lib/$ONYX_ARCH/lib/libdyncall_s.a ../shared/lib/$ONYX_ARCH/lib/libdyncallback_s.a" FLAGS="$FLAGS -DUSE_DYNCALL" fi diff --git a/interpreter/build.sh b/interpreter/build.sh index e72417d1..289f6c8b 100755 --- a/interpreter/build.sh +++ b/interpreter/build.sh @@ -4,7 +4,7 @@ # FLAGS="-g3 -DOVM_VERBOSE=1" FLAGS="-Ofast -fno-stack-protector" LIBS="-pthread" -TARGET="../shared/lib/linux_$(uname -m)/lib/libovmwasm.a" +TARGET="../shared/lib/$ONYX_ARCH/lib/libovmwasm.a" C_FILES="src/ovmwasm.c src/vm/*.c src/wasm/*.c src/debug/*.c" INCLUDES="-I../shared/include -Iinclude" diff --git a/runtime/onyx_runtime.c b/runtime/onyx_runtime.c index 5847a6e4..1e75c3b8 100644 --- a/runtime/onyx_runtime.c +++ b/runtime/onyx_runtime.c @@ -18,7 +18,6 @@ #include #include #include - #include #include #include #include @@ -26,6 +25,10 @@ #include #endif +#if defined(_BH_LINUX) + #include +#endif + #include "types.h" // For POINTER_SIZE #include "src/ort_files.h" diff --git a/runtime/src/ort_net_linux.h b/runtime/src/ort_net_linux.h index 89175799..85a656e0 100644 --- a/runtime/src/ort_net_linux.h +++ b/runtime/src/ort_net_linux.h @@ -3,8 +3,6 @@ // Networking // -#include - #define SOCKET_ERROR_NONE 0 #define SOCKET_ERROR_BAD_SETTINGS 1 #define SOCKET_ERROR_CONNECT_FAILED 1 diff --git a/settings.sh b/settings.sh index 7f194012..f6c48ca2 100644 --- a/settings.sh +++ b/settings.sh @@ -3,14 +3,10 @@ export ONYX_CC='gcc' # The architecture of your system. If your not sure, leave this alone. -export ONYX_ARCH="$(uname -m)" +export ONYX_ARCH="$(uname | tr '[:upper:]' '[:lower:]')_$(uname -m)" export ONYX_RUNTIME_LIBRARY="ovmwasm" -# export ONYX_RUNTIME_LIBRARY=":libwasmer.a" - -export ONYX_INCLUDE_DIR="$(pwd)/shared/include" -export ONYX_LIBRARY_DIR="$(pwd)/shared/lib/linux_$ONYX_ARCH/lib" -# export ONYX_LIBRARY_DIR="$(wasmer config --libdir)" +# export ONYX_RUNTIME_LIBRARY="wasmer" # Enable Dynamic call export ONYX_USE_DYNCALL=1 -- 2.25.1