Skip to content

CI: non-simd opcode check #319

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 6 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,9 @@ jobs:
run: |
brew install wabt;
if: matrix.os == 'macos-latest'
# Check simd for rust builds
- name: Check 2d simd rust build
- name: Check simd rust build
run: |
if ! wasm-objdump -d builds/rapier2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1
fi
- name: Check 3d simd compat build
run: |
if ! wasm-objdump -d builds/rapier3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1
fi
./scripts/verify_simd_rust.sh
- uses: actions/upload-artifact@v4
with:
name: pkg no-compat ${{ matrix.os }}
Expand All @@ -92,16 +84,17 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: npm ci;
- name: Prepare compat builds
run: |
./builds/prepare_builds/prepare_all_projects.sh
- run: npm ci;
- name: Build rapier-compat
run: |
cd rapier-compat;
npm ci;
npm run build;
npm run test;
cd -;
# Install dependencies to check simd for builds
- name: Install wabt
run: |
Expand All @@ -112,16 +105,9 @@ jobs:
brew install wabt;
if: matrix.os == 'macos-latest'
# Check simd for compat builds
- name: Check 2d simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1;
fi
- name: Check 3d simd compat build
- name: Check simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1;
fi
./scripts/verify_simd_compat.sh
# Upload
- uses: actions/upload-artifact@v4
with:
Expand Down
42 changes: 42 additions & 0 deletions scripts/verify_simd_compat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

is_error=0

check_simd_opcode_compat() {
local dimension=$1
local features_flag=$2

local file_path="rapier-compat/builds/${dimension}${features_flag}/pkg/rapier_wasm${dimension}_bg.wasm"

echo "wasm-objdump -d $file_path" >&2
if [ "$features_flag" = "-simd" ]; then
if ! wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension}${features_flag} compat build should include simd opcode prefix." && exit 1
fi
else
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension} ${features_flag} compat build should not include simd opcode prefix." && exit 1
fi
fi
}

## simd

check_simd_opcode_compat "2d" "-simd" || is_error=1
check_simd_opcode_compat "3d" "-simd" || is_error=1


## not simd

check_simd_opcode_compat "2d" "-deterministic" || is_error=1
check_simd_opcode_compat "3d" "-deterministic" || is_error=1

check_simd_opcode_compat "2d" "" || is_error=1
check_simd_opcode_compat "3d" "" || is_error=1

if [ $is_error = 1 ]; then
echo "ERROR: SIMD check in rust builds failed."
exit 1
else
echo "SIMD check in rust builds: All checks passed."
fi
42 changes: 42 additions & 0 deletions scripts/verify_simd_rust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

is_error=0

check_simd_opcode_rust() {
local dimension=$1
local features_flag=$2

local file_path="builds/rapier${dimension}${features_flag}/pkg/rapier_wasm${dimension}_bg.wasm"

if [ "$features_flag" = "-simd" ]; then
if ! wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension}${features_flag} build should include simd opcode prefix." && exit 1
fi
else
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension} ${features_flag} build should not include simd opcode prefix." && exit 1
fi
fi
}

## simd

check_simd_opcode_rust "2d" "-simd" || is_error=1
check_simd_opcode_rust "3d" "-simd" || is_error=1


## not simd

check_simd_opcode_rust "2d" "-deterministic" || is_error=1
check_simd_opcode_rust "3d" "-deterministic" || is_error=1

check_simd_opcode_rust "2d" "" || is_error=1
check_simd_opcode_rust "3d" "" || is_error=1


if [ $is_error = 1 ]; then
echo "ERROR: SIMD check in rust builds failed."
exit 1
else
echo "SIMD check in rust builds: All checks passed."
fi