Skip to content

Fix Dawn WebGPU parallel build race on webgpu_enum_class_bitmasks.h in wasm_inferencing_webgpu_jspi#29777

Draft
tianleiwu with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-web-ci-pipeline-job
Draft

Fix Dawn WebGPU parallel build race on webgpu_enum_class_bitmasks.h in wasm_inferencing_webgpu_jspi#29777
tianleiwu with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-web-ci-pipeline-job

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

Extends cmake/patches/dawn/dawn_parallel_build_fix.patch with a second hunk and updates the explanatory comment in onnxruntime_external_deps.cmake. Two fixes in the patch address the race:

Fix 1 — missing output directory (existing hunk): adds cmake -E make_directory before cmake -E copy in emdawnwebgpu_headers_gen_add so the destination directory is guaranteed to exist before any copy runs, regardless of parallel job scheduling.

Fix 2 — duplicate custom-command recipe (new hunk): removes webgpu_enum_class_bitmasks.h from emdawnwebgpu_cpp's HEADERS list:

 dawn_add_library(
     emdawnwebgpu_cpp
     ...
     HEADERS
         "${EM_BUILD_GEN_DIR}/include/dawn/webgpu_cpp_print.h"
         "${EM_BUILD_GEN_DIR}/include/webgpu/webgpu_cpp.h"
         "${EM_BUILD_GEN_DIR}/include/webgpu/webgpu_cpp_chained_struct.h"
-        "${EM_BUILD_GEN_DIR}/include/webgpu/webgpu_enum_class_bitmasks.h"
     DEPENDS
         emdawnwebgpu_c
 )

emdawnwebgpu_cpp is an INTERFACE library, so anything in HEADERS goes into INTERFACE_SOURCES. When onnxruntime_providers_webgpu links to it, CMake propagates the generated file into ORT's directory scope and emits a second cmake -E copy recipe for the same output path. With -j32, both recipes run concurrently → race → copy failure. Removing the entry eliminates the duplicate recipe. The header remains reachable via ${EM_BUILD_GEN_DIR}/include (already on emdawnwebgpu_c_include's INTERFACE_INCLUDE_DIRECTORIES), and build ordering is preserved through the existing emdawnwebgpu_c → emdawnwebgpu_c_include → emdawnwebgpu_headers_gen chain.

Also removes a stale comment in cmake/onnxruntime_providers_webgpu.cmake that described an older, different bug.

Motivation and Context

The wasm_inferencing_webgpu_jspi step (CI job 88023093249) was failing because webgpu_enum_class_bitmasks.h was being copied by two parallel make jobs simultaneously. The JSPI build is most susceptible because it runs after a warmed ccache, so all ORT compilation steps finish quickly and many more jobs compete for the Dawn header generation step at the same time.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

…gpu_jspi

Two related fixes for the race condition where cmake -E copy fails when
two parallel make jobs both try to copy webgpu_enum_class_bitmasks.h to
the same destination file.

Fix 1: Add cmake -E make_directory before cmake -E copy in the
emdawnwebgpu_headers_gen_add macro to ensure the output directory exists
before any copy command runs, regardless of parallel build ordering.

Fix 2: Remove webgpu_enum_class_bitmasks.h from emdawnwebgpu_cpp's
HEADERS list. Because emdawnwebgpu_cpp is an INTERFACE library and this
file is in INTERFACE_SOURCES, CMake propagates it to every linking target's
directory scope and generates a duplicate cmake -E copy recipe. With
parallel make (-jN), both the Dawn-directory recipe and the
ORT-directory recipe run concurrently for the same output file, causing
the copy to fail. The header remains accessible via the include directory
set on emdawnwebgpu_c_include (${EM_BUILD_GEN_DIR}/include), and build
ordering is preserved through the existing dependency chain.
Copilot AI changed the title [WIP] Fix failing Web CI pipeline job from PR #29776 Fix Dawn WebGPU parallel build race on webgpu_enum_class_bitmasks.h in wasm_inferencing_webgpu_jspi Jul 18, 2026
Copilot AI requested a review from tianleiwu July 18, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants