diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ae5f3ad5e67..409177512f5 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -32,41 +32,48 @@ jobs: echo $DOING_RELEASE test: - name: Test on ${{ matrix.build }} + name: Test on ${{ matrix.id }} runs-on: ${{ matrix.os }} needs: setup strategy: fail-fast: false matrix: - build: [linux-x64, macos-x64, macos-arm64, windows-x64, linux-aarch64] include: - - build: linux-x64 + - id: linux-x64 os: ubuntu-18.04 rust: 1.48 llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/linux-amd64.tar.gz' artifact_name: 'wasmer-linux-amd64' cross_compilation_artifact_name: 'cross_compiled_from_linux' run_integration_tests: true - - build: macos-x64 + - id: linux-musl-x64 + os: ubuntu-18.04 + rust: 1.48 + target: x86_64-unknown-linux-musl + llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/linux-amd64.tar.gz' + artifact_name: 'wasmer-linux-musl-amd64' + cross_compilation_artifact_name: 'cross_compiled_from_linux' + run_integration_tests: true + - id: macos-x64 os: macos-latest rust: 1.48 llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/darwin-amd64.tar.gz' artifact_name: 'wasmer-darwin-amd64' cross_compilation_artifact_name: 'cross_compiled_from_mac' run_integration_tests: true - - build: macos-arm64 + - id: macos-arm64 os: macos-11.0 rust: 1.49 target: aarch64-apple-darwin artifact_name: 'wasmer-darwin-arm64' - - build: windows-x64 + - id: windows-x64 os: windows-latest rust: 1.48 llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/windows-amd64.tar.gz' artifact_name: 'wasmer-windows-amd64' cross_compilation_artifact_name: 'cross_compiled_from_win' run_integration_tests: true - - build: linux-aarch64 + - id: linux-aarch64 os: [self-hosted, linux, ARM64] random_sccache_port: true rust: 1.48 @@ -80,11 +87,16 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up libstdc++ on Linux + if: matrix.id == 'linux-x64' run: | sudo apt-get update -y sudo apt-get install -y --allow-downgrades libstdc++6=8.4.0-1ubuntu1~18.04 sudo apt-get install --reinstall g++-8 - if: matrix.os == 'ubuntu-18.04' + - name: Set up musl on Linux + if: matrix.id == 'linux-musl-x64' + run: | + sudo apt-get update -y + sudo apt-get install -y musl-dev musl-tools - name: Install Rust ${{ matrix.rust }} uses: actions-rs/toolchain@v1 with: @@ -92,12 +104,12 @@ jobs: target: ${{ matrix.target }} override: true - name: Install LLVM (Windows) - if: matrix.os == 'windows-latest' + if: matrix.id == 'windows-x64' shell: cmd run: | choco install llvm - name: Install LLVM - if: matrix.os != 'windows-latest' && matrix.os != 'macos-11.0' + if: matrix.id != 'windows-x64' && matrix.id != 'macos-arm64' && matrix.id != 'linux-musl-x64' shell: bash run: | curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.llvm_url }} -L -o llvm.tar.gz @@ -108,23 +120,22 @@ jobs: env: LLVM_DIR: ${{ github.workspace }}/llvm-10 - name: Set up dependencies for Mac OS + if: matrix.id == 'macos-x64' || matrix.id == 'macos-arm64' run: | brew install automake # using gnu-tar is a workaround for https://github.com/actions/cache/issues/403 brew install gnu-tar echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV - if: matrix.os == 'macos-latest' || matrix.os == 'macos-11.0' - uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git - key: ${{ matrix.build }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}-v1 - # Install sccache + key: ${{ matrix.id }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}-v1 - uses: actions/cache@v2 with: path: ${{ runner.tool_cache }}/cargo-sccache - key: ${{ matrix.build }}-${{ matrix.target }}-sccache-bin-${{ env.CARGO_SCCACHE_VERSION }}-v1 + key: ${{ matrix.id }}-${{ matrix.target }}-sccache-bin-${{ env.CARGO_SCCACHE_VERSION }}-v1 - name: Install sccache run: | if [ ! -f ${{ runner.tool_cache }}/cargo-sccache/bin/sccache ]; then @@ -132,13 +143,14 @@ jobs: fi shell: bash - name: Setup Rust target + if: matrix.target run: | cat << EOF > .cargo/config.toml [build] target = "${{ matrix.target }}" EOF - if: matrix.target - name: Set sccache port + if: matrix.random_sccache_port run: | netstat -aln | awk ' $6 == "LISTEN" { @@ -156,7 +168,6 @@ jobs: ' >> $GITHUB_ENV # echo "SCCACHE_SERVER_PORT=9000" echo "Setting random sccache port to: $SCCACHE_SERVER_PORT" - if: matrix.random_sccache_port shell: bash - name: Start sccache run: | @@ -165,28 +176,28 @@ jobs: ${{ runner.tool_cache }}/cargo-sccache/bin/sccache -s echo "RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache" >> $GITHUB_ENV - name: Test + if: matrix.id != 'macos-arm64' run: | make test - if: matrix.target != 'aarch64-apple-darwin' - name: Test C API + if: matrix.id != 'windows-x64' && matrix.id != 'macos-arm64' # we can't test yet on Apple Silicon or Windows run: | make test-capi - if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' # we can't test yet on Apple Silicon or Windows - name: Build C API + if: matrix.id != 'macos-arm64' run: | make build-capi - if: matrix.target != 'aarch64-apple-darwin' - name: Build C API (system libffi) + if: matrix.id != 'macos-arm64' run: | make build-capi-cranelift-system-libffi - if: matrix.target == 'aarch64-apple-darwin' - name: Build Wasmer binary run: | make build-wasmer - name: Build Wapm binary + if: needs.setup.outputs.DOING_RELEASE == '1' run: | make build-wapm - if: needs.setup.outputs.DOING_RELEASE == '1' - name: Copy target binaries run: | mkdir -p target/release @@ -201,19 +212,19 @@ jobs: run: | make distribution - name: Run integration tests (Windows) + if: matrix.run_integration_tests && matrix.id == 'windows-x64' shell: cmd run: | call refreshenv set WASMER_DIR=%CD%\package make test-integration - if: matrix.run_integration_tests && matrix.os == 'windows-latest' - name: Run integration tests (Unix) + if: matrix.run_integration_tests && matrix.id != 'windows-x64' run: | export WASMER_DIR=`pwd`/package make test-integration - if: matrix.run_integration_tests && matrix.os != 'windows-latest' - name: Cross compile from Linux - if: matrix.os == 'ubuntu-18.04' + if: matrix.id == 'linux-x64' shell: bash run: | ls target/release @@ -225,7 +236,7 @@ jobs: #cp qjs_win_from_linux.wjit cross cp target/release/wasmer cross - name: Cross compile from Mac - if: matrix.os == 'macos-latest' + if: matrix.id == 'macos-x64' shell: bash run: | ls target/release @@ -237,7 +248,7 @@ jobs: #cp qjs_win_from_mac.wjit cross cp target/release/wasmer cross #- name: Cross compile from Windows - # if: matrix.os == 'windows-latest' + # if: matrix.id == 'windows-x64' # shell: bash # run: | # alias wasmer=target/release/wasmer diff --git a/Makefile b/Makefile index b051d3df3c7..41ea451fd99 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,12 @@ ifneq ($(OS), Windows_NT) ARCH := $(shell uname -m) UNAME_S := $(shell uname -s) + LIBC := $(shell ldd 2>&1 | grep -o musl | head -n1) else # We can assume, if in windows it will likely be in x86_64 ARCH := x86_64 - UNAME_S := + UNAME_S := + LIBC := endif # Which compilers we build. These have dependencies that may not be on the system. @@ -32,14 +34,21 @@ ifeq ($(ARCH), x86_64) test_compilers_engines += cranelift-jit # LLVM could be enabled if not in Windows ifneq ($(OS), Windows_NT) - # Native engine doesn't work on Windows yet. - test_compilers_engines += cranelift-native + ifneq ($(LIBC), musl) + # Native engine doesn't work on Windows and musl yet. + test_compilers_engines += cranelift-native + endif # Singlepass doesn't work yet on Windows. compilers += singlepass # Singlepass doesn't work with the native engine. test_compilers_engines += singlepass-jit ifneq (, $(findstring llvm,$(compilers))) - test_compilers_engines += llvm-jit llvm-native + test_compilers_engines += llvm-jit + + ifneq ($(LIBC), musl) + # Native engine doesn't work on musl yet. + test_compilers_engines += llvm-native + endif endif endif endif @@ -73,9 +82,9 @@ compilers := $(filter-out ,$(compilers)) test_compilers_engines := $(filter-out ,$(test_compilers_engines)) ifneq ($(OS), Windows_NT) - bold := $(shell tput bold) - green := $(shell tput setaf 2) - reset := $(shell tput sgr0) + bold := $(shell tput bold 2>/dev/null || echo -n '') + green := $(shell tput setaf 2 2>/dev/null || echo -n '') + reset := $(shell tput sgr0 2>/dev/null || echo -n '') endif diff --git a/examples/engine_cross_compilation.rs b/examples/engine_cross_compilation.rs index d5644c35d3d..5e820460cc6 100644 --- a/examples/engine_cross_compilation.rs +++ b/examples/engine_cross_compilation.rs @@ -97,13 +97,3 @@ fn main() -> Result<(), Box> { Ok(()) } - -#[test] -#[cfg(not(any( - windows, - // We don't support yet crosscompilation in macOS with Apple Silicon - all(target_os = "macos", target_arch = "aarch64") -)))] -fn test_cross_compilation() -> Result<(), Box> { - main() -} diff --git a/examples/engine_headless.rs b/examples/engine_headless.rs index 40b4881d6ea..1f1170af3d0 100644 --- a/examples/engine_headless.rs +++ b/examples/engine_headless.rs @@ -147,7 +147,7 @@ fn main() -> Result<(), Box> { } #[test] -#[cfg(not(any(windows, target_arch = "aarch64")))] +#[cfg(not(any(windows, target_arch = "aarch64", target_env = "musl")))] fn test_engine_headless() -> Result<(), Box> { main() } diff --git a/examples/engine_native.rs b/examples/engine_native.rs index 3345d0e5bb7..e9f72d1bf97 100644 --- a/examples/engine_native.rs +++ b/examples/engine_native.rs @@ -87,7 +87,7 @@ fn main() -> Result<(), Box> { } #[test] -#[cfg(not(target_arch = "aarch64"))] +#[cfg(not(any(target_arch = "aarch64", target_env = "musl")))] fn test_engine_native() -> Result<(), Box> { main() } diff --git a/tests/compilers/traps.rs b/tests/compilers/traps.rs index aa8d99f8cc9..c619c20459f 100644 --- a/tests/compilers/traps.rs +++ b/tests/compilers/traps.rs @@ -43,6 +43,7 @@ fn test_trap_return() -> Result<()> { feature = "test-singlepass", feature = "test-native", target_arch = "aarch64", + target_env = "musl", ), ignore )] @@ -130,6 +131,7 @@ fn test_trap_trace_cb() -> Result<()> { feature = "test-singlepass", feature = "test-native", target_arch = "aarch64", + target_env = "musl", ), ignore )] @@ -169,6 +171,7 @@ fn test_trap_stack_overflow() -> Result<()> { feature = "test-llvm", feature = "test-native", target_arch = "aarch64", + target_env = "musl", ), ignore )] @@ -210,6 +213,7 @@ RuntimeError: unreachable feature = "test-llvm", feature = "test-native", target_arch = "aarch64", + target_env = "musl", ), ignore )] @@ -424,7 +428,8 @@ fn mismatched_arguments() -> Result<()> { feature = "test-singlepass", feature = "test-llvm", feature = "test-native", - all(target_os = "macos", target_arch = "aarch64") + all(target_os = "macos", target_arch = "aarch64"), + target_env = "musl", ), ignore )] @@ -464,6 +469,7 @@ RuntimeError: indirect call type mismatch feature = "test-llvm", feature = "test-native", target_arch = "aarch64", + target_env = "musl", ), ignore )]