changed: simplifying build process
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 16 Nov 2023 21:35:14 +0000 (15:35 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 16 Nov 2023 21:35:14 +0000 (15:35 -0600)
.github/workflows/onyx-build.yml
compiler/build.sh
interpreter/build.sh
runtime/onyx_runtime.c
runtime/src/ort_net_linux.h
settings.sh

index 32e4116a25baad784140d55fcae0908ead76e6d7..c6fe092db60fb4b85a46c45ee2f84848c5d77e64 100644 (file)
@@ -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'
index 5da5304c9cdf6bc16e4df844fcb7b0bc70e2e187..1f582fe90d95b9cb669be2f7deebc5beba783dc1 100755 (executable)
@@ -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
 
index e72417d121b87831409307f149d7996eba48e9e9..289f6c8b5f572b3bff67d02dce91c6bc550d0166 100755 (executable)
@@ -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"
 
index 5847a6e46c533e952cc8a7d4ce120d1b8d0f847f..1e75c3b807068e4c69c0658ad873063bcd69467e 100644 (file)
@@ -18,7 +18,6 @@
     #include <netinet/in.h>
     #include <sys/socket.h>
     #include <sys/un.h>
-    #include <linux/futex.h>
     #include <sys/syscall.h>
     #include <poll.h>
     #include <termios.h>
     #include <unistd.h>
 #endif
 
+#if defined(_BH_LINUX)
+    #include <linux/futex.h>
+#endif
+
 #include "types.h"  // For POINTER_SIZE
 
 #include "src/ort_files.h"
index 89175799ead4c567d9a976835ec3743e7fda206e..85a656e024106f09c39a1bf4e23153ad28771791 100644 (file)
@@ -3,8 +3,6 @@
 // Networking
 //
 
-#include <byteswap.h>
-
 #define SOCKET_ERROR_NONE 0
 #define SOCKET_ERROR_BAD_SETTINGS 1
 #define SOCKET_ERROR_CONNECT_FAILED 1
index 7f194012b6910c9b41004b8b2a3d44173d74216b..f6c48ca2dc4ed48efd3913cf5a52895d42c89347 100644 (file)
@@ -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