Skip to content

Commit 38f469b

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 38f469b

File tree

3 files changed

+89
-21
lines changed

3 files changed

+89
-21
lines changed

.github/workflows/main.yml

+5-21
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
~/.cargo/git/db/
4242
target/
4343
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
44-
- run: npm ci;
4544
- name: Prepare no-compat builds
4645
run: |
4746
./builds/prepare_builds/prepare_all_projects.sh
@@ -57,17 +56,9 @@ jobs:
5756
run: |
5857
brew install wabt;
5958
if: matrix.os == 'macos-latest'
60-
# Check simd for rust builds
61-
- name: Check 2d simd rust build
59+
- name: Check simd rust build
6260
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
61+
./scripts/verify_simd_rust.sh
7162
- uses: actions/upload-artifact@v4
7263
with:
7364
name: pkg no-compat ${{ matrix.os }}
@@ -92,7 +83,6 @@ jobs:
9283
~/.cargo/git/db/
9384
target/
9485
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
95-
- run: npm ci;
9686
- name: Prepare compat builds
9787
run: |
9888
./builds/prepare_builds/prepare_all_projects.sh
@@ -102,6 +92,7 @@ jobs:
10292
npm ci;
10393
npm run build;
10494
npm run test;
95+
cd -;
10596
# Install dependencies to check simd for builds
10697
- name: Install wabt
10798
run: |
@@ -112,16 +103,9 @@ jobs:
112103
brew install wabt;
113104
if: matrix.os == 'macos-latest'
114105
# 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
106+
- name: Check simd compat build
121107
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
108+
./scripts/verify_simd_compat.sh
125109
# Upload
126110
- uses: actions/upload-artifact@v4
127111
with:

scripts/verify_simd_compat.sh

+42
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

+42
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)