iTranslated by AI
Building Onyx from Source
Conclusion
I was able to get it working as shown below after running git clone. At least in my environment.
source ./settings.sh && ONYX_RUNTIME_LIBRARY=ovmwasm ./build.sh compile install
Installing Onyx
In the article above, I installed it using the installation script located at https://get.onyxlang.io [1].
Building Onyx from Source
In this article, I will build it from source. The procedure is listed at https://onyxlang.io/docs/install#source.
git clone https://github.com/onyx-lang/onyx
cd ./onyx
source settings.sh
./build.sh compile
It results in an error stating that the assembly file libwasmer.a is missing.
$ ./build.sh compile
Compiling onyx
clang: error: no such file or directory: '~/.wasmer/lib/libwasmer.a'
libwasmer.a seems to be a lightweight headless Wasmer compiler, but I don't know how to install it.
For now, reading build.sh suggests that the build branches between compiling with a compiler or an interpreter depending on the value of the ONYX_RUNTIME_LIBRARY environment variable.
compile_all() {
if [ "$ONYX_RUNTIME_LIBRARY" = "ovmwasm" ]; then
cd interpreter
./build.sh $1
cd ..
fi
cd compiler
./build.sh $1
cd ..
if [ ! -z ${ONYX_RUNTIME_LIBRARY+x} ]; then
cd runtime
./build.sh $1
cd ..
fi
}
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"
;;
# Used by MacOS ARM64 cross compilation
wasmer-custom)
LIBS="$WASMER_LIB_PATH/libwasmer.a $LIBS"
;;
*)
echo "Unknown WebAssembly runtime '$ONYX_RUNTIME_LIBRARY'. Aborting.";
exit 1
;;
esac
Building with ONYX_RUNTIME_LIBRARY="ovmwasm"[2] seems to eliminate the need for libwasmer.a. This setting is also mentioned as a comment in ./settings.sh, which is loaded during the build process.
$ ONYX_RUNTIME_LIBRARY=ovmwasm ./build.sh compile
Compiling ovmwasm to ../shared/lib/darwin_arm64/lib/libovmwasm.a
Compiling onyx
Compiling onyx_runtime.dylib
The binary is built in ./compiler/onyx.
$ ./compiler/onyx version
Onyx toolchain version v0.1.8
Built on Wed Jan 3 08:21:31 2024
Runtime: ovmwasm
Installation
$ ./build.sh install
Installing on 'Darwin ... (omitted) ... arm64'
Installing core libs
Installing core tools
Installing runtime library
Installing to $HOME/.onyx
Just add $HOME/.onyx/bin to your path as needed.
Build Time
Approximately 7 seconds.
$ time /bin/bash -c 'source ./settings.sh && ONYX_RUNTIME_LIBRARY=ovmwasm ./build.sh compile install'
# ... (omitted) ...
/bin/bash -c 6.53s user 0.95s system 85% cpu 8.712 total
Summary
Since I got an error due to the missing libwasmer.a, I tried building with ovmwasm, and it worked for now.
Hmm... I felt like I should study Wasmer itself more.
Other References
- How does Wasmer create native binaries from Wasm?
- Testing the binary generation feature for each platform from WASM in Wasmer 3.0 | Mamezou Developer Site
-
This URL redirects to bin/install.sh in the
devbranch of the https://github.com/onyx-lang/onyx repository. When I checked, there were no particular differences in this file betweenmasteranddev. ↩︎ -
ovm stands for Onyx Virtual Machine, which I assume is Onyx's own runtime system, different from Wasm or Wasmer. ovm is slightly slower than Wasmer but supports debug execution. ↩︎
Discussion