microsoft / microsoft/onnxruntime

[Build] --build_wasm_static_lib with --use_xnnpack produces libonnxruntime_webassembly.a with undefined xnn_*/pthreadpool_* symbols

Open
#32,396 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build ep:Xnnpack platform:web
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

Describe the issue

A static WASM build with XNNPACK enabled completes successfully, but the resulting libonnxruntime_webassembly.a does not contain the XNNPACK or pthreadpool objects. Any Emscripten project that links it fails at wasm-ld with undefined xnn_* and pthreadpool_* symbols.

libonnxruntime_providers_xnnpack.a is built and bundled, and it references those symbols — but nothing in the build defines them, because the XNNPACK and pthreadpool targets are never built or linked.

Cause

cmake/onnxruntime_providers_xnnpack.cmake attaches XNNPACK and pthreadpool only via onnxruntime_add_include_to_target (include dirs only, no link dependency), so CMake never builds them. bundle_static_library() in cmake/onnxruntime_webassembly.cmake discovers archives by walking LINK_LIBRARIES, so they are silently omitted from the bundle. The non-static path's target_link_libraries(onnxruntime_webassembly PRIVATE XNNPACK) is in the else() branch of if (onnxruntime_BUILD_WEBASSEMBLY_STATIC_LIB) and never runs for static builds.

Still present on main at a6e96aa. Distinct from #23460 (configure-time failure, fixed by #24860) - this surfaces only at link time in a downstream project.

Happy to raise a PR for this.

Urgency

Blocks static WASM builds with XNNPACK for any consumer.

Target platform

WASM (Emscripten, emsdk 4.0.23; host Linux x86-64)

Build script

./build.sh --config Release --build_wasm --build_wasm_static_lib
--enable_wasm_simd --use_xnnpack --skip_tests
--disable_wasm_exception_catching --disable_rtti --parallel

Error / output

wasm-ld: error: undefined symbol: xnn_initialize
wasm-ld: error: undefined symbol: xnn_deinitialize
wasm-ld: error: undefined symbol: xnn_create_convolution2d_nhwc_f32
wasm-ld: error: undefined symbol: xnn_reshape_convolution2d_nhwc_f32
wasm-ld: error: undefined symbol: xnn_setup_convolution2d_nhwc_f32
wasm-ld: error: undefined symbol: xnn_run_operator
wasm-ld: error: undefined symbol: xnn_delete_operator
wasm-ld: error: undefined symbol: xnn_delete_weights_cache
wasm-ld: error: undefined symbol: pthreadpool_create
wasm-ld: error: undefined symbol: pthreadpool_destroy
... (~20 total, all xnn_* create/reshape/setup variants and pthreadpool_*)

Visual Studio Version

No response

GCC / Compiler Version

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading cmake/onnxruntime_providers_xnnpack.cmake and cmake/onnxruntime_webassembly.cmake, then reproduce the issue with the provided build.sh command using Emscripten. Trace how the static bundle discovers LINK_LIBRARIES and verify that the resulting libonnxruntime_webassembly.a supplies the reported xnn_* and pthreadpool_* symbols when linked by a downstream WASM project.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, wasm
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.