From a54cc41315118fd899b17bf23f9c066589bc543f Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Tue, 2 Dec 2025 17:22:20 -0800 Subject: [PATCH 1/4] upgrade emsdk to v4.0.21 --- .gitmodules | 2 +- cmake/external/emsdk | 2 +- tools/ci_build/build_args.py | 2 +- .../github/azure-pipelines/templates/linux-wasm-ci.yml | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index a48c4062a90fe..37455d1bb64c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,4 +7,4 @@ [submodule "cmake/external/emsdk"] path = cmake/external/emsdk url = https://github.com/emscripten-core/emsdk.git - branch = 4.0.11 + branch = 4.0.21 diff --git a/cmake/external/emsdk b/cmake/external/emsdk index d49219d03a41c..b2436aafa7351 160000 --- a/cmake/external/emsdk +++ b/cmake/external/emsdk @@ -1 +1 @@ -Subproject commit d49219d03a41cd12f95a33ba84273c20d41fd350 +Subproject commit b2436aafa7351ee1b581f15841f1b45ed716a279 diff --git a/tools/ci_build/build_args.py b/tools/ci_build/build_args.py index 6763973406294..8f79598b2381c 100644 --- a/tools/ci_build/build_args.py +++ b/tools/ci_build/build_args.py @@ -359,7 +359,7 @@ def add_webassembly_args(parser: argparse.ArgumentParser) -> None: """Adds arguments for WebAssembly (WASM) platform builds.""" parser.add_argument("--build_wasm", action="store_true", help="Build for WebAssembly.") parser.add_argument("--build_wasm_static_lib", action="store_true", help="Build WebAssembly static library.") - parser.add_argument("--emsdk_version", default="4.0.11", help="Specify version of emsdk.") + parser.add_argument("--emsdk_version", default="4.0.21", help="Specify version of emsdk.") parser.add_argument( "--enable_wasm_jspi", action="store_true", help="Enable WebAssembly JavaScript Promise Integration." ) diff --git a/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml b/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml index 249c866b88df4..6cb16313ef309 100644 --- a/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/linux-wasm-ci.yml @@ -96,15 +96,15 @@ jobs: - script: | set -ex cd '$(Build.SourcesDirectory)/cmake/external/emsdk' - ./emsdk install 4.0.11 ccache-git-emscripten-64bit - ./emsdk activate 4.0.11 ccache-git-emscripten-64bit + ./emsdk install 4.0.21 ccache-git-emscripten-64bit + ./emsdk activate 4.0.21 ccache-git-emscripten-64bit displayName: 'emsdk install and activate ccache for emscripten' - ${{if eq(parameters.WithCache, false)}}: - script: | set -ex cd '$(Build.SourcesDirectory)/cmake/external/emsdk' - ./emsdk install 4.0.11 - ./emsdk activate 4.0.11 + ./emsdk install 4.0.21 + ./emsdk activate 4.0.21 displayName: 'emsdk install and activate ccache for emscripten' - template: build-linux-wasm-step.yml From a550e26d37e5e6d5e35e2845f3811ab567aac652 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Fri, 5 Dec 2025 17:03:14 -0800 Subject: [PATCH 2/4] try fix one break --- tools/python/util/vcpkg_helpers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/python/util/vcpkg_helpers.py b/tools/python/util/vcpkg_helpers.py index 415aeaf22211d..b6110274c879c 100644 --- a/tools/python/util/vcpkg_helpers.py +++ b/tools/python/util/vcpkg_helpers.py @@ -24,9 +24,25 @@ def add_port_configs(f, has_exception: bool, is_emscripten: bool, enable_minimal list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DBENCHMARK_ENABLE_WERROR=OFF" ) -endif() """ ) + if (is_emscripten): + # workaround for https://github.com/google/benchmark/issues/2057 + f.write( + r""" + string(APPEND VCPKG_C_FLAGS + " -Wno-c2y-extensions" + ) + string(APPEND VCPKG_CXX_FLAGS + " -Wno-c2y-extensions" + ) +""" + ) + f.write(r""" +endif() # benchmark +""" + ) + f.write( r"""if(PORT MATCHES "date") list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS From f639d3d77c033f039b567ec66f677748b5146012 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Tue, 9 Dec 2025 19:00:40 -0800 Subject: [PATCH 3/4] fix webgpu header build issue --- cmake/onnxruntime_providers_webgpu.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/onnxruntime_providers_webgpu.cmake b/cmake/onnxruntime_providers_webgpu.cmake index 62f594d194543..f382f70ffedb0 100644 --- a/cmake/onnxruntime_providers_webgpu.cmake +++ b/cmake/onnxruntime_providers_webgpu.cmake @@ -58,6 +58,20 @@ # WebAssembly/JavaScript code for WebGPU support. target_link_libraries(onnxruntime_providers_webgpu PUBLIC emdawnwebgpu_cpp) + # Dawn's emdawnwebgpu_cpp target has a bug: it lists ${DAWN_INCLUDE_DIR}/webgpu/webgpu_enum_class_bitmasks.h + # in INTERFACE_SOURCES but doesn't add ${DAWN_INCLUDE_DIR} to INTERFACE_INCLUDE_DIRECTORIES. + # In emsdk 4.0.11, this was masked because Emscripten bundled its own copy of the WebGPU headers. + # In emsdk 4.0.21+, Emscripten removed the bundled WebGPU headers, exposing this bug. + # We need to manually add the Dawn include directory to find webgpu_enum_class_bitmasks.h. + # + # IMPORTANT: We must also add the generated emdawnwebgpu include directory BEFORE the Dawn source + # include directory, because ${dawn_SOURCE_DIR}/include/webgpu/webgpu_cpp.h is a stub that redirects + # to dawn/webgpu_cpp.h (native Dawn), but we need the generated Emscripten-specific webgpu_cpp.h. + target_include_directories(onnxruntime_providers_webgpu PRIVATE + "${dawn_BINARY_DIR}/gen/src/emdawnwebgpu/include" + "${dawn_SOURCE_DIR}/include" + ) + if (onnxruntime_ENABLE_WEBASSEMBLY_JSPI) target_link_options(onnxruntime_providers_webgpu PUBLIC "SHELL:-s JSPI=1" From cb0c46899468c1d6a72254b89d745bcc43ff0981 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:19:12 -0800 Subject: [PATCH 4/4] format code --- tools/python/util/vcpkg_helpers.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/python/util/vcpkg_helpers.py b/tools/python/util/vcpkg_helpers.py index b6110274c879c..182d757907ab2 100644 --- a/tools/python/util/vcpkg_helpers.py +++ b/tools/python/util/vcpkg_helpers.py @@ -26,7 +26,7 @@ def add_port_configs(f, has_exception: bool, is_emscripten: bool, enable_minimal ) """ ) - if (is_emscripten): + if is_emscripten: # workaround for https://github.com/google/benchmark/issues/2057 f.write( r""" @@ -40,8 +40,7 @@ def add_port_configs(f, has_exception: bool, is_emscripten: bool, enable_minimal ) f.write(r""" endif() # benchmark -""" - ) +""") f.write( r"""if(PORT MATCHES "date")