Skip to content

Commit 5693eea

Browse files
committed
improve simd checks to not contain simd for non-simd builds ; made scripts standalone for easier local run
1 parent f4c21b7 commit 5693eea

File tree

3 files changed

+90
-20
lines changed

3 files changed

+90
-20
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,9 @@ jobs:
5757
run: |
5858
brew install wabt;
5959
if: matrix.os == 'macos-latest'
60-
# Check simd for rust builds
61-
- name: Check 2d simd rust build
60+
- name: Check simd rust build
6261
run: |
63-
if ! wasm-objdump -d builds/rapier2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
64-
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1
65-
fi
66-
- name: Check 3d simd compat build
67-
run: |
68-
if ! wasm-objdump -d builds/rapier3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
69-
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1
70-
fi
62+
./scripts/verify_simd_rust.sh
7163
- uses: actions/upload-artifact@v4
7264
with:
7365
name: pkg no-compat ${{ matrix.os }}
@@ -92,16 +84,17 @@ jobs:
9284
~/.cargo/git/db/
9385
target/
9486
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
95-
- run: npm ci;
9687
- name: Prepare compat builds
9788
run: |
9889
./builds/prepare_builds/prepare_all_projects.sh
90+
- run: npm ci;
9991
- name: Build rapier-compat
10092
run: |
10193
cd rapier-compat;
10294
npm ci;
10395
npm run build;
10496
npm run test;
97+
cd -;
10598
# Install dependencies to check simd for builds
10699
- name: Install wabt
107100
run: |
@@ -112,16 +105,9 @@ jobs:
112105
brew install wabt;
113106
if: matrix.os == 'macos-latest'
114107
# Check simd for compat builds
115-
- name: Check 2d simd compat build
116-
run: |
117-
if ! wasm-objdump -d rapier-compat/builds/2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
118-
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1;
119-
fi
120-
- name: Check 3d simd compat build
108+
- name: Check simd compat build
121109
run: |
122-
if ! wasm-objdump -d rapier-compat/builds/3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
123-
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1;
124-
fi
110+
./scripts/verify_simd_compat.sh
125111
# Upload
126112
- uses: actions/upload-artifact@v4
127113
with:

scripts/verify_simd_compat.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
is_error=0
4+
5+
check_simd_opcode_compat() {
6+
local dimension=$1
7+
local features_flag=$2
8+
9+
local file_path="rapier-compat/builds/${dimension}${features_flag}/pkg/rapier_wasm${dimension}_bg.wasm"
10+
11+
echo "wasm-objdump -d $file_path" >&2
12+
if [ "$features_flag" = "-simd" ]; then
13+
if ! wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
14+
>&2 echo "ERROR: ${dimension}${features_flag} compat build should include simd opcode prefix." && exit 1
15+
fi
16+
else
17+
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
18+
>&2 echo "ERROR: ${dimension} ${features_flag} compat build should not include simd opcode prefix." && exit 1
19+
fi
20+
fi
21+
}
22+
23+
## simd
24+
25+
check_simd_opcode_compat "2d" "-simd" || is_error=1
26+
check_simd_opcode_compat "3d" "-simd" || is_error=1
27+
28+
29+
## not simd
30+
31+
check_simd_opcode_compat "2d" "-deterministic" || is_error=1
32+
check_simd_opcode_compat "3d" "-deterministic" || is_error=1
33+
34+
check_simd_opcode_compat "2d" "" || is_error=1
35+
check_simd_opcode_compat "3d" "" || is_error=1
36+
37+
if [ $is_error = 1 ]; then
38+
echo "ERROR: SIMD check in rust builds failed."
39+
exit 1
40+
else
41+
echo "SIMD check in rust builds: All checks passed."
42+
fi

scripts/verify_simd_rust.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
is_error=0
4+
5+
check_simd_opcode_rust() {
6+
local dimension=$1
7+
local features_flag=$2
8+
9+
local file_path="builds/rapier${dimension}${features_flag}/pkg/rapier_wasm${dimension}_bg.wasm"
10+
11+
if [ "$features_flag" = "-simd" ]; then
12+
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
13+
>&2 echo "ERROR: ${dimension}${features_flag} build should include simd opcode prefix." && exit 1
14+
fi
15+
else
16+
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
17+
>&2 echo "ERROR: ${dimension} ${features_flag} build should not include simd opcode prefix." && exit 1
18+
fi
19+
fi
20+
}
21+
22+
## simd
23+
24+
check_simd_opcode_rust "2d" "-simd" || is_error=1
25+
check_simd_opcode_rust "3d" "-simd" || is_error=1
26+
27+
28+
## not simd
29+
30+
check_simd_opcode_rust "2d" "-deterministic" || is_error=1
31+
check_simd_opcode_rust "3d" "-deterministic" || is_error=1
32+
33+
check_simd_opcode_rust "2d" "" || is_error=1
34+
check_simd_opcode_rust "3d" "" || is_error=1
35+
36+
37+
if [ $is_error = 1 ]; then
38+
echo "ERROR: SIMD check in rust builds failed."
39+
exit 1
40+
else
41+
echo "SIMD check in rust builds: All checks passed."
42+
fi

0 commit comments

Comments
 (0)