I'm working on compiling fail-components/webtransport to WASM for use in the browser as server and client (using Direct Sockets UDPSocket). The original code was written to compile to Node.js Addon, not WASM or WASI. I got to 32% compiled before encounting Google's Protobuf including sys/wait.h. I'm already using wasi-threads. How to get around this?
cmake . -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk-pthread.cmake \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/media/user/1/webtransport/transports/http3-quiche/build-wasm/Release" \
-DCMAKE_JS_INC="/media/user/1/webtransport/node_modules/node-api-headers/include;/media/user/1/webtransport/node_modules/node-addon-api" \
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" \
-DCMAKE_JS_INC="/media/user/1/webtransport/node_modules/node-api-headers/include;/media/user/1/webtransport/node_modules/node-addon-api" \
-DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="26.0.0-nightly20251023f819aec288" \
-DNODE_ARCH="x64" -Dnapi_build_version="6" -DCMAKE_JS_LIB="" \
-DCMAKE_CXX_FLAGS="-DBUILDING_NODE_EXTENSION -D_WASI_EMULATED_SIGNAL -lwasi-emulated-signal" \
-DCMAKE_JS_VERSION="7.3.1" \
-DCMAKE_BUILD_TYPE="Release" \
--no-warn-unused-cli
make
# ...
clang++: warning: -lwasi-emulated-signal: 'linker' input unused [-Wunused-command-line-argument]
[ 32%] Building CXX object third_party/protobuf/CMakeFiles/libprotoc.dir/src/google/protobuf/compiler/subprocess.cc.obj
clang++: warning: -lwasi-emulated-signal: 'linker' input unused [-Wunused-command-line-argument]
/media/user/1/webtransport/transports/http3-quiche/third_party/protobuf/src/google/protobuf/compiler/subprocess.cc:43:10: fatal error: 'sys/wait.h' file not found
43 | #include <sys/wait.h>
| ^~~~~~~~~~~~
1 error generated.
make[2]: *** [third_party/protobuf/CMakeFiles/libprotoc.dir/build.make:1213: third_party/protobuf/CMakeFiles/libprotoc.dir/src/google/protobuf/compiler/subprocess.cc.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:5416: third_party/protobuf/CMakeFiles/libprotoc.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
I believe this is intended, wasi-libc doesn't have a sys/wait.h header
Any thoughts on approaches to proceed in spite of that?
You'll need to patch the code somehow -- unfortunately the WASI platform doesn't have that header because the functionality therein (waitpid, etc) doesn't exist
Hmm, this got a 'lil further along using Rust https://github.com/guest271314/quinn-wasm/tree/direct-sockets.
From the maintainer, modification of this in CMakeLists.txt targeting WASM/WASI might do something.
I don't know CMake functions, and what to substitute for WASI-SDK
IF(APPLE)
set_target_properties(protoc libprotoc libprotobuf PROPERTIES OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE )
ENDIF(APPLE)
Last updated: Dec 06 2025 at 05:03 UTC