Skip to content

Update LLVM to 18.1.2 and add wasm-component-ld #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ jobs:
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
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
Expand All @@ -67,7 +61,7 @@ jobs:
run: NINJA_FLAGS=-v make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
shell: bash
- 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
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -107,6 +101,7 @@ jobs:
msystem: ${{ matrix.sys }}
update: true
release: false
path-type: inherit
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ RUN curl -sSLO https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-
&& mv cmake-3.25.1-linux-x86_64 /opt/cmake
ENV PATH /opt/cmake/bin:$PATH

ENV RUSTUP_HOME=/rust/rustup CARGO_HOME=/rust/cargo PATH=$PATH:/rust/cargo/bin
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile=minimal && \
chmod -R a+w /rust

RUN groupadd -g ${GID} builder && \
useradd --create-home --uid ${UID} --gid ${GID} builder
USER builder
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ default: build
@echo "Use -fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)"

check:
TARGETS="$(TARGETS)" tests/run.sh "$(BUILD_PREFIX)" "$(RUNTIME)" "$(ADAPTER)" "$(WASM_TOOLS)"
TARGETS="$(TARGETS)" tests/run.sh "$(BUILD_PREFIX)" "$(RUNTIME)"

clean:
rm -rf build $(DESTDIR)
Expand Down Expand Up @@ -122,6 +122,14 @@ build/llvm.BUILT:
llvm-config
touch build/llvm.BUILT

# Build the `wasm-component-ld` linker from source via `cargo install`. This is
# used for the `wasm32-wasip2` target natively by Clang. Note that `--root`
# passed to `cargo install` will place it in the output directory automatically.
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
# $(1): the target that's being built
WASI_LIBC_MAKEFLAGS = \
Expand All @@ -132,7 +140,7 @@ WASI_LIBC_MAKEFLAGS = \
SYSROOT=$(BUILD_PREFIX)/share/wasi-sysroot \
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-wasip1) default libc_so
$(MAKE) $(call WASI_LIBC_MAKEFLAGS,wasm32-wasip2) WASI_SNAPSHOT=p2 default libc_so
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 149 files
25 changes: 8 additions & 17 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ wasi_sdk="$1"
# Determine the wasm runtime to use, if one is provided.
if [ $# -gt 1 ]; then
runwasi="$2"
if [ $# -gt 3 ]; then
adapter="$3"
wasm_tools="$4"
else
adapter=""
wasm_tools=""
fi
else
runwasi=""
adapter=""
wasm_tools=""
fi

testdir=$(dirname $0)
Expand All @@ -45,13 +36,13 @@ for target in $TARGETS; do
echo "===== Testing compile-only with $options ====="
for file in *.c; do
echo "Testing compile-only $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/clang" "$options --target=$target" "$file"
../testcase.sh "$target" "" "$wasi_sdk/bin/$target-clang" "$options" "$file"
done
for file in *.cc; do
echo "Testing compile-only $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/clang++" "$options --target=$target -fno-exceptions" "$file"
../testcase.sh "$target" "" "$wasi_sdk/bin/$target-clang++" "$options -fno-exceptions" "$file"
done
done
cd - >/dev/null
Expand All @@ -61,13 +52,13 @@ for target in $TARGETS; do
echo "===== Testing with $options ====="
for file in *.c; do
echo "Testing $file..."
../testcase.sh "$target" "$runwasi" "$adapter" "$wasm_tools" "$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/clang" "$options --target=$target" "$file"
../testcase.sh "$target" "$runwasi" "$wasi_sdk/bin/$target-clang" "$options" "$file"
done
for file in *.cc; do
echo "Testing $file..."
../testcase.sh "$target" "$runwasi" "$adapter" "$wasm_tools" "$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/clang++" "$options --target=$target -fno-exceptions" "$file"
../testcase.sh "$target" "$runwasi" "$wasi_sdk/bin/$target-clang++" "$options -fno-exceptions" "$file"
done
done
cd - >/dev/null
Expand Down
16 changes: 4 additions & 12 deletions tests/testcase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ set -ueo pipefail
# script, so don't do anything fancy.
target="$1"
runwasi="$2"
adapter="$3"
wasm_tools="$4"
compiler="$5"
options="$6"
input="$7"
compiler="$3"
options="$4"
input="$5"

# Compile names for generated files.
wasm="$input.$options.wasm"
stdout_observed="$input.$options.stdout.observed"
stderr_observed="$input.$options.stderr.observed"
exit_status_observed="$input.$options.exit_status.observed"
run_args=""

# Optionally load compiler options from a file.
if [ -e "$input.options" ]; then
Expand All @@ -44,11 +41,6 @@ if [ "$runwasi" == "" ]; then
exit 0
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.
if [ -e "$input.stdin" ]; then
stdin="$input.stdin"
Expand All @@ -74,7 +66,7 @@ fi

# Run the test, capturing stdout, stderr, and the exit status.
exit_status=0
"$runwasi" $run_args $env $dir "$wasm" $dirarg \
"$runwasi" $env $dir "$wasm" $dirarg \
< "$stdin" \
> "$stdout_observed" \
2> "$stderr_observed" \
Expand Down