diff --git a/tools/python/util/vcpkg_helpers.py b/tools/python/util/vcpkg_helpers.py index 34477dc38e38d..f976e525aff93 100644 --- a/tools/python/util/vcpkg_helpers.py +++ b/tools/python/util/vcpkg_helpers.py @@ -101,6 +101,16 @@ def add_port_configs( )""" ) + # When building ONNX for WebAssembly, we disable doc strings to reduce the binary size. The ONNX doc strings are + # only used for error messages and are not critical for end users. Disabling them can significantly reduce the + # binary size, which is important for WebAssembly targets. + if is_emscripten: + f.write( + r""" + string(APPEND VCPKG_C_FLAGS " -D__ONNX_NO_DOC_STRINGS") + string(APPEND VCPKG_CXX_FLAGS " -D__ONNX_NO_DOC_STRINGS")""" + ) + f.write(r""" endif() # End ONNX-specific block """)