Skip to content

WASM/WASI target #24250

@guest271314

Description

@guest271314

What language does this apply to?
WebAssembly/WASI, and to some extent JavaScript.

Describe the problem you are trying to solve.

I'm trying to compile https://github.com/fails-components/webtransport to WASM using WASI-SDK.

Describe the solution you'd like

WASI-SDK toolchain doesn't have <sys/wait.h> which is referenced in compiler/subprocess.cc, so I'm getting this error

[ 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

Describe alternatives you've considered

I am not a CMake expert by any means. I changed the original CMakeList.txt to this, because from what I gather from the maintainer protobuf needs to be available on the native system, not compiled to WASM

IF(APPLE)
    set_target_properties(protoc libprotoc libprotobuf PROPERTIES OSX_ARCHITECTURES arm64;x86_64 CACHE STRING "Build architectures for Mac OS X" FORCE )
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "WASI")
    # Add any specific properties for WASI targets here if needed. 
    # The WASI toolchain usually handles the necessary flags automatically.
    # The original OSX_ARCHITECTURES property is irrelevant for WASI.
    execute_process(
        COMMAND uname -m
        OUTPUT_VARIABLE HOST_ARCH
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    set_target_properties(protoc libprotoc libprotobuf
        PROPERTIES
            OSX_ARCHITECTURES "${HOST_ARCH}"
    )
ENDIF()

Next I tried just commenting out the whole subprocess.cc file, and that doesn't work, either.

Additional context
Add any other context or screenshots about the feature request here.

Issue where I try to get roadmap from maintainer, who is not interested in WASM support for their library fails-components/webtransport#354.

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedauto added to all issues by default when created.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions