@@ -7,8 +7,8 @@ echo "🌐 =========================================="
77echo " "
88
99# Configuration for CI (GitHub Actions)
10- SWIFT_WASM_SDK_URL=" https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.3 -RELEASE/swift-wasm-6.0.3 -RELEASE-wasm32-unknown-wasi.artifactbundle.zip"
11- SWIFT_WASM_SDK_CHECKSUM=" 31d3585b06dd92de390bacc18527801480163188cd7473f492956b5e213a8618 "
10+ SWIFT_WASM_SDK_URL=" https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.1 -RELEASE/swift-wasm-6.1 -RELEASE-wasm32-unknown-wasi.artifactbundle.zip"
11+ SWIFT_WASM_SDK_CHECKSUM=" 7550b4c77a55f4b637c376f5d192f297fe185607003a6212ad608276928db992 "
1212CI_SDK_NAME=" wasm32-unknown-wasi"
1313
1414# Swift command to use (may be overridden if toolchain detected)
@@ -99,11 +99,47 @@ install_wasmtime() {
9999 echo " 🔧 Checking wasmtime..."
100100 if command -v wasmtime & > /dev/null; then
101101 echo " ✅ wasmtime already installed: $( wasmtime --version) "
102+ return 0
103+ fi
104+
105+ echo " ⬇️ Installing wasmtime..."
106+
107+ # Pinned version to avoid issues with dynamic version fetching
108+ # The wasmtime.dev/install.sh script can fail when GitHub API rate limits
109+ # cause the version to be parsed incorrectly (e.g., returning '{' as version)
110+ WASMTIME_VERSION=" 29.0.1"
111+
112+ # Detect platform
113+ case " $( uname -s) " in
114+ Linux)
115+ WASMTIME_ARCH=" x86_64-linux"
116+ ;;
117+ Darwin)
118+ if [ " $( uname -m) " = " arm64" ]; then
119+ WASMTIME_ARCH=" aarch64-macos"
120+ else
121+ WASMTIME_ARCH=" x86_64-macos"
122+ fi
123+ ;;
124+ * )
125+ echo " ❌ Unsupported platform: $( uname -s) "
126+ exit 1
127+ ;;
128+ esac
129+
130+ WASMTIME_URL=" https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION} /wasmtime-v${WASMTIME_VERSION} -${WASMTIME_ARCH} .tar.xz"
131+ WASMTIME_DIR=" $HOME /.wasmtime"
132+
133+ echo " Downloading from: $WASMTIME_URL "
134+ mkdir -p " $WASMTIME_DIR /bin"
135+ curl -L " $WASMTIME_URL " | tar -xJ --strip-components=1 -C " $WASMTIME_DIR "
136+ export PATH=" $WASMTIME_DIR /bin:$PATH "
137+
138+ if command -v wasmtime & > /dev/null; then
139+ echo " ✅ wasmtime installed successfully: $( wasmtime --version) "
102140 else
103- echo " ⬇️ Installing wasmtime..."
104- curl https://wasmtime.dev/install.sh -sSf | bash
105- export PATH=" $HOME /.wasmtime/bin:$PATH "
106- echo " ✅ wasmtime installed successfully"
141+ echo " ❌ Failed to install wasmtime"
142+ exit 1
107143 fi
108144 echo " "
109145}
@@ -143,11 +179,26 @@ run_tests() {
143179 echo " 📍 Test binary: $TEST_BINARY "
144180
145181 # Determine wasmtime flags based on SDK type
182+ # Note: We configure stack and memory limits to prevent crashes:
183+ # 1. max-wasm-stack (32MB): Maximum stack for wasm execution. Required for
184+ # ICU/Foundation date formatting which uses significant stack space.
185+ # 2. async-stack-size (64MB): Stack for async operations. MUST be larger than
186+ # max-wasm-stack. XCTest uses async/await extensively, and swift_task_switch
187+ # operations during test execution and teardown require adequate async stack.
188+ # 3. memory-reservation-for-growth (256MB): Reserve space for memory growth
189+ # without committing large amounts upfront. This allows the linear memory
190+ # to grow on demand while having space available.
191+ # 4. memory-guard-size (64KB): Guard pages to catch out-of-bounds access.
146192 WASMTIME_FLAGS=" --dir ."
193+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -W max-wasm-stack=33554432"
194+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -W async-stack-size=67108864"
195+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -O memory-reservation-for-growth=268435456"
196+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -O memory-guard-size=65536"
147197 if echo " $SWIFT_SDK_NAME " | grep -q " threads" ; then
148198 WASMTIME_FLAGS=" $WASMTIME_FLAGS --wasm threads=y --wasi threads=y"
149199 fi
150200
201+ echo " 🔧 Wasmtime flags: $WASMTIME_FLAGS "
151202 wasmtime run $WASMTIME_FLAGS " $TEST_BINARY "
152203 echo " "
153204}
0 commit comments