Update LLVM to 18.1.2 and add wasm-component-ld

This commit has two intertwined changes within it. First the LLVM
submodule is updated to the 18.1.2 release branch. This alone would
cause CI and tests to fail due to differing behavior for the
`wasm32-wasip2` target. To fix these test failures the
`wasm-component-ld` tool is added to the build. This tool is a
Rust-written tool and installed via `cargo install` as part of the build
at a pinned version written in the `Makefile`. This linker, used for
components, is then used for the `wasm32-wasip2` target.

Tests and CI are then updated to skip the need to have `wasm-tools` or
the adapter for WASI when making components since that's now the job of
`wasm-component-ld`. This then necessitated some changes to tests too.
pull/402/head
Alex Crichton 1 year ago
parent a7b2182949
commit d129523c4d

@ -42,15 +42,6 @@ jobs:
uses: bytecodealliance/actions/wasmtime/setup@v1 uses: bytecodealliance/actions/wasmtime/setup@v1
with: with:
version: "18.0.2" version: "18.0.2"
- name: Setup `wasm-tools` for tests
uses: bytecodealliance/actions/wasm-tools/setup@v1
with:
version: "1.201.0"
- name: Download command adapter for tests
run: curl -f -L --retry 5 -o ${{ runner.temp }}/wasi_snapshot_preview1.command.wasm https://github.com/bytecodealliance/wasmtime/releases/download/v18.0.2/wasi_snapshot_preview1.command.wasm
- uses: actions/checkout@v4
with:
fetch-depth: 0
# We can't use `--depth 1` here sadly because the GNU config # We can't use `--depth 1` here sadly because the GNU config
# submodule is not pinned to a particular tag/branch. Please # submodule is not pinned to a particular tag/branch. Please
# bump depth (or even better, the submodule), in case of "error: # bump depth (or even better, the submodule), in case of "error:
@ -67,7 +58,7 @@ jobs:
run: NINJA_FLAGS=-v make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON run: NINJA_FLAGS=-v make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
shell: bash shell: bash
- name: Run the testsuite - name: Run the testsuite
run: NINJA_FLAGS=-v make check RUNTIME=wasmtime ADAPTER=${{ runner.temp }}/wasi_snapshot_preview1.command.wasm WASM_TOOLS=wasm-tools run: NINJA_FLAGS=-v make check RUNTIME=wasmtime
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

@ -54,7 +54,7 @@ default: build
@echo "Use -fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)" @echo "Use -fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)"
check: check:
TARGETS="$(TARGETS)" tests/run.sh "$(BUILD_PREFIX)" "$(RUNTIME)" "$(ADAPTER)" "$(WASM_TOOLS)" TARGETS="$(TARGETS)" tests/run.sh "$(BUILD_PREFIX)" "$(RUNTIME)"
clean: clean:
rm -rf build $(DESTDIR) rm -rf build $(DESTDIR)
@ -122,6 +122,11 @@ build/llvm.BUILT:
llvm-config llvm-config
touch build/llvm.BUILT touch build/llvm.BUILT
build/wasm-component-ld.BUILT: build/llvm.BUILT
cargo install wasm-component-ld@0.1.5 --root $(BUILD_PREFIX)
touch build/wasm-component-ld.BUILT
# Flags for running `make` in wasi-libc # Flags for running `make` in wasi-libc
# $(1): the target that's being built # $(1): the target that's being built
WASI_LIBC_MAKEFLAGS = \ WASI_LIBC_MAKEFLAGS = \
@ -132,7 +137,7 @@ WASI_LIBC_MAKEFLAGS = \
SYSROOT=$(BUILD_PREFIX)/share/wasi-sysroot \ SYSROOT=$(BUILD_PREFIX)/share/wasi-sysroot \
TARGET_TRIPLE=$(1) TARGET_TRIPLE=$(1)
build/wasi-libc.BUILT: build/compiler-rt.BUILT build/wasi-libc.BUILT: build/compiler-rt.BUILT build/wasm-component-ld.BUILT
$(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasi) default libc_so $(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasi) default libc_so
$(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasip1) default libc_so $(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasip1) default libc_so
$(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasip2) WASI_SNAPSHOT=p2 default libc_so $(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasip2) WASI_SNAPSHOT=p2 default libc_so

@ -1 +1 @@
Subproject commit 461274b81d8641eab64d494accddc81d7db8a09e Subproject commit 26a1d6601d727a96f4301d0d8647b5a42760ae0c

@ -1,6 +1,6 @@
Error: failed to run main module `abort.c.---.wasm` Error: failed to run main module `abort.c.---.wasm`
Caused by: Caused by:
0: failed to invoke command default 0: failed to invoke
1: error while executing at wasm backtrace: 1: error while executing at wasm backtrace:
2: wasm trap: wasm `unreachable` instruction executed 2: wasm trap: wasm `unreachable` instruction executed

@ -3,4 +3,5 @@ set -euo pipefail
cat \ cat \
| sed -e 's/main module `abort\.c\.[^`]*\.wasm`/main module `abort.c.---.wasm`/' \ | sed -e 's/main module `abort\.c\.[^`]*\.wasm`/main module `abort.c.---.wasm`/' \
| sed -e 's/failed to invoke.*/failed to invoke/' \
| sed -E '/0x[[:xdigit:]]+/d' | sed -E '/0x[[:xdigit:]]+/d'

@ -2,6 +2,6 @@ Assertion failed: false (assert-fail.c: main: 5)
Error: failed to run main module `assert-fail.c.---.wasm` Error: failed to run main module `assert-fail.c.---.wasm`
Caused by: Caused by:
0: failed to invoke command default 0: failed to invoke
1: error while executing at wasm backtrace: 1: error while executing at wasm backtrace:
2: wasm trap: wasm `unreachable` instruction executed 2: wasm trap: wasm `unreachable` instruction executed

@ -3,4 +3,5 @@ set -euo pipefail
cat \ cat \
| sed -e 's/main module `assert-fail\.c\.[^`]*\.wasm`/main module `assert-fail.c.---.wasm`/' \ | sed -e 's/main module `assert-fail\.c\.[^`]*\.wasm`/main module `assert-fail.c.---.wasm`/' \
| sed -e 's/failed to invoke.*/failed to invoke/' \
| sed -E '/0x[[:xdigit:]]+/d' | sed -E '/0x[[:xdigit:]]+/d'

@ -3,4 +3,4 @@ Program received fatal signal: Aborted
Error: failed to run main module `sigabrt.c.---.wasm` Error: failed to run main module `sigabrt.c.---.wasm`
Caused by: Caused by:
0: failed to invoke command default 0: failed to invoke

@ -3,5 +3,6 @@ set -euo pipefail
cat \ cat \
| sed -e 's/main module `sigabrt\.c\.[^`]*\.wasm`/main module `sigabrt.c.---.wasm`/' \ | sed -e 's/main module `sigabrt\.c\.[^`]*\.wasm`/main module `sigabrt.c.---.wasm`/' \
| sed -e 's/failed to invoke.*/failed to invoke/' \
| sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \ | sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \
| head -n 6 | head -n 6

@ -17,17 +17,8 @@ wasi_sdk="$1"
# Determine the wasm runtime to use, if one is provided. # Determine the wasm runtime to use, if one is provided.
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
runwasi="$2" runwasi="$2"
if [ $# -gt 3 ]; then
adapter="$3"
wasm_tools="$4"
else
adapter=""
wasm_tools=""
fi
else else
runwasi="" runwasi=""
adapter=""
wasm_tools=""
fi fi
testdir=$(dirname $0) testdir=$(dirname $0)
@ -45,13 +36,13 @@ for target in $TARGETS; do
echo "===== Testing compile-only with $options =====" echo "===== Testing compile-only with $options ====="
for file in *.c; do for file in *.c; do
echo "Testing compile-only $file..." echo "Testing compile-only $file..."
../testcase.sh "$target" "" "" "" "$wasi_sdk/bin/clang" "$options --target=$target" "$file" ../testcase.sh "$target" "" "$wasi_sdk/bin/clang" "$options --target=$target" "$file"
../testcase.sh "$target" "" "" "" "$wasi_sdk/bin/$target-clang" "$options" "$file" ../testcase.sh "$target" "" "$wasi_sdk/bin/$target-clang" "$options" "$file"
done done
for file in *.cc; do for file in *.cc; do
echo "Testing compile-only $file..." echo "Testing compile-only $file..."
../testcase.sh "$target" "" "" "" "$wasi_sdk/bin/clang++" "$options --target=$target -fno-exceptions" "$file" ../testcase.sh "$target" "" "$wasi_sdk/bin/clang++" "$options --target=$target -fno-exceptions" "$file"
../testcase.sh "$target" "" "" "" "$wasi_sdk/bin/$target-clang++" "$options -fno-exceptions" "$file" ../testcase.sh "$target" "" "$wasi_sdk/bin/$target-clang++" "$options -fno-exceptions" "$file"
done done
done done
cd - >/dev/null cd - >/dev/null
@ -61,13 +52,13 @@ for target in $TARGETS; do
echo "===== Testing with $options =====" echo "===== Testing with $options ====="
for file in *.c; do for file in *.c; do
echo "Testing $file..." echo "Testing $file..."
../testcase.sh "$target" "$runwasi" "$adapter" "$wasm_tools" "$wasi_sdk/bin/clang" "$options --target=$target" "$file" ../testcase.sh "$target" "$runwasi" "$wasi_sdk/bin/clang" "$options --target=$target" "$file"
../testcase.sh "$target" "$runwasi" "$adapter" "$wasm_tools" "$wasi_sdk/bin/$target-clang" "$options" "$file" ../testcase.sh "$target" "$runwasi" "$wasi_sdk/bin/$target-clang" "$options" "$file"
done done
for file in *.cc; do for file in *.cc; do
echo "Testing $file..." echo "Testing $file..."
../testcase.sh "$target" "$runwasi" "$adapter" "$wasm_tools" "$wasi_sdk/bin/clang++" "$options --target=$target -fno-exceptions" "$file" ../testcase.sh "$target" "$runwasi" "$wasi_sdk/bin/clang++" "$options --target=$target -fno-exceptions" "$file"
../testcase.sh "$target" "$runwasi" "$adapter" "$wasm_tools" "$wasi_sdk/bin/$target-clang++" "$options -fno-exceptions" "$file" ../testcase.sh "$target" "$runwasi" "$wasi_sdk/bin/$target-clang++" "$options -fno-exceptions" "$file"
done done
done done
cd - >/dev/null cd - >/dev/null

@ -8,18 +8,15 @@ set -ueo pipefail
# script, so don't do anything fancy. # script, so don't do anything fancy.
target="$1" target="$1"
runwasi="$2" runwasi="$2"
adapter="$3" compiler="$3"
wasm_tools="$4" options="$4"
compiler="$5" input="$5"
options="$6"
input="$7"
# Compile names for generated files. # Compile names for generated files.
wasm="$input.$options.wasm" wasm="$input.$options.wasm"
stdout_observed="$input.$options.stdout.observed" stdout_observed="$input.$options.stdout.observed"
stderr_observed="$input.$options.stderr.observed" stderr_observed="$input.$options.stderr.observed"
exit_status_observed="$input.$options.exit_status.observed" exit_status_observed="$input.$options.exit_status.observed"
run_args=""
# Optionally load compiler options from a file. # Optionally load compiler options from a file.
if [ -e "$input.options" ]; then if [ -e "$input.options" ]; then
@ -44,11 +41,6 @@ if [ "$runwasi" == "" ]; then
exit 0 exit 0
fi fi
if [ "$target" == "wasm32-wasip2" -a -n "$adapter" -a -n "$wasm_tools" ]; then
"$wasm_tools" component new --adapt "$adapter" "$wasm" -o "$wasm"
run_args="--wasm component-model"
fi
# Determine the input file to write to stdin. # Determine the input file to write to stdin.
if [ -e "$input.stdin" ]; then if [ -e "$input.stdin" ]; then
stdin="$input.stdin" stdin="$input.stdin"
@ -74,7 +66,7 @@ fi
# Run the test, capturing stdout, stderr, and the exit status. # Run the test, capturing stdout, stderr, and the exit status.
exit_status=0 exit_status=0
"$runwasi" $run_args $env $dir "$wasm" $dirarg \ "$runwasi" $env $dir "$wasm" $dirarg \
< "$stdin" \ < "$stdin" \
> "$stdout_observed" \ > "$stdout_observed" \
2> "$stderr_observed" \ 2> "$stderr_observed" \

Loading…
Cancel
Save