Skip to content

Commit f0ac48b

Browse files
committed
Use latest EMSDK
1 parent 875fdd3 commit f0ac48b

5 files changed

Lines changed: 26 additions & 29 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414
contents: read
1515

1616
env:
17-
EMSDK_VERSION: "3.1.51"
17+
EMSDK_VERSION: "4.0.23"
1818

1919
jobs:
2020
wasm-build-test:
@@ -43,8 +43,8 @@ jobs:
4343
emcc --version
4444
node --version
4545
46-
- name: Run WASM tests
46+
- name: Run Emscripten tests
4747
env:
4848
EMSDK_PATH: ${{ env.EMSDK }}
4949
run: |
50-
./tests/ci/run_wasm_tests.sh
50+
./tests/ci/run_emscripten_tests.sh

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake-build-debug/
33
build/
44
build32/
55
build64/
6-
build-fips/
6+
build-*/
77
*_BUILD_ROOT/
88
ssl/test/runner/runner
99
*.pyc

crypto/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,9 @@ endif()
702702
#
703703
# For now we assume embedded OSes do not have threads. Additionally, the Threads
704704
# package does not work with Android, but Android does not require any extra
705-
# parameters to link pthreads.
706-
if(NOT CMAKE_SYSTEM_NAME MATCHES "^(Generic|Android)$")
705+
# parameters to link pthreads. Emscripten provides its own pthread implementation
706+
# via Web Workers and SharedArrayBuffer, configured through compiler flags.
707+
if(NOT CMAKE_SYSTEM_NAME MATCHES "^(Generic|Android|Emscripten)$")
707708
find_package(Threads REQUIRED)
708709
target_link_libraries(crypto PUBLIC Threads::Threads)
709710
endif()
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
# SPDX-License-Identifier: Apache-2.0 OR ISC
44

5-
# CI script for testing AWS-LC WASM builds using Emscripten
5+
# CI script for testing AWS-LC Emscripten builds
66
#
77
# This script builds AWS-LC for WebAssembly and runs the crypto_test and ssl_test
88
# test binaries using Node.js.
@@ -96,7 +96,7 @@ function run_wasm_build {
9696

9797
${CMAKE_COMMAND} \
9898
-GNinja \
99-
-DCMAKE_TOOLCHAIN_FILE="${SRC_ROOT}/util/wasm-toolchain.cmake" \
99+
-DCMAKE_TOOLCHAIN_FILE="${SRC_ROOT}/util/emscripten-toolchain.cmake" \
100100
-DCMAKE_BUILD_TYPE="${build_type}" \
101101
-DDISABLE_CPU_JITTER_ENTROPY=ON \
102102
-DDISABLE_GO=ON \
@@ -129,11 +129,11 @@ function verify_wasm_artifacts {
129129
fi
130130
echo "Found: ${BUILD_ROOT}/ssl/libssl.a"
131131

132-
# Check for test executables (Emscripten generates JS wrapper files without extension)
132+
# Check for test executables (Emscripten generates .js wrapper files and .wasm binaries)
133133
local test_binaries=(
134-
"crypto/crypto_test"
135-
"crypto/urandom_test"
136-
"ssl/ssl_test"
134+
"crypto/crypto_test.js"
135+
"crypto/urandom_test.js"
136+
"ssl/ssl_test.js"
137137
)
138138

139139
for test_binary in "${test_binaries[@]}"; do
@@ -193,17 +193,17 @@ function run_wasm_tests {
193193
local failed_tests=()
194194

195195
# Run crypto_test (excluding fork and socket tests)
196-
if ! run_single_wasm_test "crypto/crypto_test" --gtest_filter="${WASM_GTEST_FILTER}"; then
196+
if ! run_single_wasm_test "crypto/crypto_test.js" --gtest_filter="${WASM_GTEST_FILTER}"; then
197197
failed_tests+=("crypto_test")
198198
fi
199199

200200
# Run urandom_test
201-
if ! run_single_wasm_test "crypto/urandom_test"; then
201+
if ! run_single_wasm_test "crypto/urandom_test.js"; then
202202
failed_tests+=("urandom_test")
203203
fi
204204

205205
# Run ssl_test (excluding fork and socket tests)
206-
if ! run_single_wasm_test "ssl/ssl_test" --gtest_filter="${WASM_GTEST_FILTER}"; then
206+
if ! run_single_wasm_test "ssl/ssl_test.js" --gtest_filter="${WASM_GTEST_FILTER}"; then
207207
failed_tests+=("ssl_test")
208208
fi
209209

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# AWS-LC WASM Toolchain File
1+
# AWS-LC Emscripten Toolchain File
22
#
33
# This is a wrapper toolchain file for building AWS-LC with Emscripten.
44
# It includes the standard Emscripten toolchain and configures pthread support
55
# for multithreaded WASM builds.
66
#
77
# Usage:
8-
# cmake -DCMAKE_TOOLCHAIN_FILE=util/wasm-toolchain.cmake ...
8+
# cmake -DCMAKE_TOOLCHAIN_FILE=util/emscripten-toolchain.cmake ...
99
#
1010
# Prerequisites:
1111
# - EMSDK environment must be sourced before running cmake
@@ -27,20 +27,16 @@ if(NOT EXISTS "${EMSCRIPTEN_TOOLCHAIN_FILE}")
2727
message(FATAL_ERROR "Emscripten toolchain file not found at: ${EMSCRIPTEN_TOOLCHAIN_FILE}")
2828
endif()
2929

30+
# The Emscripten toolchain file defaults CMAKE_SYSTEM_PROCESSOR to "x86" via
31+
# EMSCRIPTEN_SYSTEM_PROCESSOR. We must set this BEFORE including the toolchain
32+
# to ensure AWS-LC's architecture detection uses "generic" instead of x86,
33+
# which would add incompatible flags like -msse2.
34+
set(EMSCRIPTEN_SYSTEM_PROCESSOR wasm32)
35+
3036
# Include the standard Emscripten toolchain file
37+
# This sets CMAKE_SYSTEM_NAME to "Emscripten" and CMAKE_CROSSCOMPILING to TRUE.
3138
include("${EMSCRIPTEN_TOOLCHAIN_FILE}")
3239

33-
# Override CMAKE_SYSTEM_NAME to "Generic" so AWS-LC treats this as an embedded
34-
# target and skips the pthread requirement check in its CMakeLists.txt.
35-
# The Emscripten toolchain sets this to "Emscripten" but AWS-LC's CMakeLists.txt
36-
# only recognizes "Generic" and "Android" as systems that don't require pthreads
37-
# validation (we handle pthreads via Emscripten's own implementation).
38-
set(CMAKE_SYSTEM_NAME Generic)
39-
set(CMAKE_SYSTEM_PROCESSOR wasm32)
40-
41-
# Ensure cross-compiling is still set
42-
set(CMAKE_CROSSCOMPILING TRUE)
43-
4440
# Enable pthread support for multithreaded WASM builds.
4541
# Emscripten implements pthreads using Web Workers and SharedArrayBuffer.
4642
# This requires:
@@ -83,4 +79,4 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
8379
# - The main browser thread cannot block (Atomics.wait doesn't work there)
8480
# - Moving main() to a worker allows proper blocking on mutexes, joins, etc.
8581
# - The main thread remains responsive for handling proxied operations
86-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sENVIRONMENT=node,worker -sNODERAWFS=1 -sEXIT_RUNTIME=1 -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=134217728 -sASSERTIONS=1 -sSTACK_SIZE=1048576 -pthread -sPTHREAD_POOL_SIZE=8 -sPROXY_TO_PTHREAD -Wno-pthreads-mem-growth")
82+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sENVIRONMENT=node,worker -sNODERAWFS=1 -sEXIT_RUNTIME=1 -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=134217728 -sASSERTIONS=1 -sSTACK_SIZE=1048576 -pthread -sPTHREAD_POOL_SIZE=8 -sPROXY_TO_PTHREAD -Wno-pthreads-mem-growth")

0 commit comments

Comments
 (0)