Skip to content

Commit 3941c41

Browse files
committed
Use latest EMSDK
1 parent 492fe00 commit 3941c41

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed
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: 2 additions & 2 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 \
Lines changed: 8 additions & 12 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
@@ -30,17 +30,13 @@ endif()
3030
# Include the standard Emscripten toolchain file
3131
include("${EMSCRIPTEN_TOOLCHAIN_FILE}")
3232

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)
33+
# The Emscripten toolchain file sets CMAKE_SYSTEM_NAME to "Emscripten" and
34+
# CMAKE_CROSSCOMPILING to TRUE, which AWS-LC's CMakeLists.txt recognizes.
35+
# We must set CMAKE_SYSTEM_PROCESSOR to wasm32 so that AWS-LC's architecture
36+
# detection uses "generic" instead of detecting the host's processor (e.g., x86_64)
37+
# which would add incompatible flags like -msse2.
3938
set(CMAKE_SYSTEM_PROCESSOR wasm32)
4039

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)