From 882577c201bc7cebb2ecfc37519b073800c48013 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 30 Jul 2024 19:16:31 -0500 Subject: [PATCH 1/3] Clone a larger depth in submodules (#464) This is an attempt to fix CI errors where the `config` submodule is now located on a commit further than 32 commits behind the main branch (presumably). --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3109532..ead42c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,7 +79,7 @@ jobs: # bump depth (or even better, the submodule), in case of "error: # Server does not allow request for unadvertised object" in the # future. - - run: git submodule update --init --depth 32 --jobs 3 + - run: git submodule update --init --depth 64 --jobs 3 # Persist ccache-based caches across builds. This directory is configured # via the CCACHE_DIR env var below for ccache to use. @@ -265,7 +265,7 @@ jobs: fetch-depth: 0 - run: git fetch --tags --force name: Force-fetch tags to work around actions/checkout#290 - - run: git submodule update --init --depth 32 --jobs 3 + - run: git submodule update --init --depth 64 --jobs 3 - name: Setup `wasmtime` for tests uses: bytecodealliance/actions/wasmtime/setup@v1 with: From 0de1b487fc18636cbd59367b7cf39b0c7026ccf5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 30 Jul 2024 19:22:23 -0500 Subject: [PATCH 2/3] Fix testing the right targets on CI (#461) This commit fixes a bug from the cmake migration where tests were not actually testing the correct target. Object files were compiled with the right options but the link step was missing both `--target` and `-pthread` which caused everything to accidentally be tested as `wasm32-wasi`. When fixing this one test was needed to have its stderr updated because the component output of `wasm32-wasip2` is slightly different. A timeout was additionally added because without `-pthread` at the link step some tests infinitely ran which made debugging difficult. --- ci/build.sh | 3 ++- tests/CMakeLists.txt | 2 ++ tests/general/sigabrt.c.stderr.expected | 2 +- tests/general/sigabrt.c.stderr.expected.filter | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 09c92a3..7525aa4 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -47,4 +47,5 @@ if [ "$WASI_SDK_CI_SKIP_TESTS" = "1" ]; then fi # Run tests to ensure that the sysroot works. -ctest --output-on-failure --parallel 10 --test-dir $build_dir/sysroot/tests +ctest --output-on-failure --parallel 10 --test-dir $build_dir/sysroot/tests \ + --timeout 60 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c5e7edd..edbb129 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,6 +48,7 @@ function(add_testcase runwasi test) # as well. if(NOT(CMAKE_C_COMPILER MATCHES ${target})) target_compile_options(${target_name} PRIVATE --target=${target}) + target_link_options(${target_name} PRIVATE --target=${target}) endif() # Apply test-specific compile options and link flags. @@ -79,6 +80,7 @@ function(add_testcase runwasi test) # Apply target-specific options. if(target MATCHES threads) target_compile_options(${target_name} PRIVATE -pthread) + target_link_options(${target_name} PRIVATE -pthread) endif() if(runwasi) diff --git a/tests/general/sigabrt.c.stderr.expected b/tests/general/sigabrt.c.stderr.expected index 72c425d..d702a88 100644 --- a/tests/general/sigabrt.c.stderr.expected +++ b/tests/general/sigabrt.c.stderr.expected @@ -3,4 +3,4 @@ Program received fatal signal: Aborted Error: failed to run main module `sigabrt.c.---.wasm` Caused by: - 0: failed to invoke command default + 0: failed to invoke --- diff --git a/tests/general/sigabrt.c.stderr.expected.filter b/tests/general/sigabrt.c.stderr.expected.filter index e6b54c2..726f024 100755 --- a/tests/general/sigabrt.c.stderr.expected.filter +++ b/tests/general/sigabrt.c.stderr.expected.filter @@ -4,4 +4,5 @@ set -euo pipefail cat \ | sed -e 's/main module `.*sigabrt\.c\.wasm`/main module `sigabrt.c.---.wasm`/' \ | sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \ + | sed -e 's/failed to invoke.*/failed to invoke ---/' \ | head -n 6 From b0075f9a8234c94a24e67a8f339c653d25f89be9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 31 Jul 2024 11:54:37 -0500 Subject: [PATCH 3/3] Add some CMake guards when building the sysroot (#462) * Require that the compiler is Clang, for example gcc and msvc cannot compile to WebAssembly. * Require that the Clang version is above the minimum threshold. Unsure what the minimum threshold is at this time so I've set it to 18.0.0 --- cmake/wasi-sdk-sysroot.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/wasi-sdk-sysroot.cmake b/cmake/wasi-sdk-sysroot.cmake index 6bed7d3..394b562 100644 --- a/cmake/wasi-sdk-sysroot.cmake +++ b/cmake/wasi-sdk-sysroot.cmake @@ -5,6 +5,16 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() +if(NOT CMAKE_C_COMPILER_ID MATCHES Clang) + message(FATAL_ERROR "C compiler ${CMAKE_C_COMPILER} is not `Clang`, it is ${CMAKE_C_COMPILER_ID}") +endif() + +set(minimum_clang_required 18.0.0) + +if(CMAKE_C_COMPILER_VERSION VERSION_LESS ${minimum_clang_required}) + message(FATAL_ERROR "compiler version ${CMAKE_C_COMPILER_VERSION} is less than the required version ${minimum_clang_required}") +endif() + find_program(MAKE make REQUIRED) option(WASI_SDK_DEBUG_PREFIX_MAP "Pass `-fdebug-prefix-map` for built artifacts" ON)