diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6d304d6..c7efa08 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -76,9 +76,14 @@ jobs: wamerican - name: Compile sledge run: | - make install - echo "/opt/sledge/bin:$PATH" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV + make build + make build-validate + make rtinit + mkdir bin + mkdir lib + SYS_PREFIX="$(pwd)" ./install.sh + echo "$(pwd)/bin:$PATH" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=$(pwd)/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - name: Compile sample apps and run tests run: | ./test.sh diff --git a/Makefile b/Makefile index 91c208f..7762b34 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,15 @@ build: test -f ./${COMPILER}/wasmception/dist/bin/clang || make -C ${COMPILER}/wasmception @cd ${COMPILER} && cargo build --release && cd ${ROOT} +.PHONY: build-validate +build-validate: + which awsm + awsm --version + cd ${COMPILER} + which awsm + awsm --version + cd ${ROOT} + .PHONY: build-dev build-dev: test -f ./${COMPILER}/wasmception/dist/bin/clang || make -C ${COMPILER}/wasmception @@ -35,6 +44,6 @@ runtime: make -C runtime .PHONY: install -install: build rtinit +install: build build-validate rtinit @./install.sh wasmception diff --git a/install.sh b/install.sh index 420b830..d09cd2d 100755 --- a/install.sh +++ b/install.sh @@ -4,10 +4,14 @@ echo "Setting up toolchain environment" # Get the path of this repo +# SYS_SRC_PREFIX could be externally set +# This is written assuming that install.sh might be in the project top level directory or a subdirectory, +# but that it is always called with a relative path from the project root SYS_SRC_PREFIX=${SYS_SRC_PREFIX:-"$( cd "$(dirname "$(dirname "${0}")")" || exit 1 pwd -P )"} +echo SYS_SRC_PREFIX: "$SYS_SRC_PREFIX" # And check for the presence of this script to make sure we got it right if [ ! -x "${SYS_SRC_PREFIX}/install.sh" ]; then @@ -17,21 +21,27 @@ fi SYS_NAME='sledge' COMPILER='awsm' -COMPILER_EXECUTABLE='silverfish' +COMPILER_EXECUTABLE=$COMPILER # /opt/sledge SYS_PREFIX=${SYS_PREFIX:-"/opt/${SYS_NAME}"} +echo SYS_PREFIX: "$SYS_PREFIX" # /sledge, where the sledge repo is mounted from the host SYS_SRC_PREFIX=${SYS_SRC_PREFIX:-"/${SYS_NAME}"} +echo SYS_SRC_PREFIX: "$SYS_SRC_PREFIX" # The release directory containing the binary of the aWsm compiler SYS_COMPILER_REL_DIR=${SYS_COMPILER_REL_DIR:-"${SYS_SRC_PREFIX}/${COMPILER}/target/release"} +echo SYS_COMPILER_REL_DIR: "$SYS_COMPILER_REL_DIR" # /opt/sledge/bin SYS_BIN_DIR=${SYS_BIN_DIR:-"${SYS_PREFIX}/bin"} +echo SYS_BIN_DIR: "$SYS_BIN_DIR" + # /opt/sledge/lib SYS_LIB_DIR=${SYS_LIB_DIR:-"${SYS_PREFIX}/lib"} +echo SYS_LIB_DIR: "$SYS_LIB_DIR" # The first argument can be either wasi or wasmception. This determines the system interface used # The default is wasmception @@ -53,14 +63,30 @@ elif [ "$1" = "wasi" ]; then WASM_BIN_PREFIX=${WASM_BIN_PREFIX:-"$WASM_TARGET"} WASM_TOOLS=ar dwarfdump nm ranlib size fi - +echo WASM_PREFIX: "$WASM_PREFIX" +echo WASM_BIN: "$WASM_BIN" +echo WASM_SYSROOT: "$WASM_SYSROOT" +echo WASM_TARGET: "$WASM_TARGET" +echo WASM_BIN_PREFIX: "$WASM_BIN_PREFIX" +echo WASM_TOOLS: "$WASM_TOOLS" + +# Delete all existing installations of the binaries +echo rm -f "${SYS_BIN_DIR}"/* rm -f "${SYS_BIN_DIR}"/* + +# And reinstall +echo install -d -v "$SYS_BIN_DIR" || exit 1 install -d -v "$SYS_BIN_DIR" || exit 1 -# Link the Awsm compiler. Rename to awsm if still using legacy "silverfish" name +# Symbolically link the Awsm compiler # /sledge/awsm/target/release/silverfish /opt/sledge/bin/awsm -ln -sfv "${SYS_COMPILER_REL_DIR}/${COMPILER_EXECUTABLE}" "${SYS_BIN_DIR}/awsm" +echo ln -sfv "${SYS_COMPILER_REL_DIR}/${COMPILER_EXECUTABLE}" "${SYS_BIN_DIR}/${COMPILER_EXECUTABLE}" +ln -sfv "${SYS_COMPILER_REL_DIR}/${COMPILER_EXECUTABLE}" "${SYS_BIN_DIR}/${COMPILER_EXECUTABLE}" +# Generate shell script stubs that act as aliases that automatically set the approproiate target and sysroot +# for either Wasmception or WASI-SDK +# For example, when wasmception is set, calling `wasm32-unknown-unknown-wasm-clang` results in +# `exec "/sledge/awsm/wasmception/dist/bin/clang" --target="wasm32-unknown-unknown-wasm" --sysroot="/sledge/awsm/wasmception/sysroot" "$@"` for file in clang clang++; do wrapper_file="$(mktemp)" cat >"$wrapper_file" <