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/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" 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 diff --git a/tools/python/util/vcpkg_helpers.py b/tools/python/util/vcpkg_helpers.py index 415aeaf22211d..182d757907ab2 100644 --- a/tools/python/util/vcpkg_helpers.py +++ b/tools/python/util/vcpkg_helpers.py @@ -24,9 +24,24 @@ 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