WebAssembly / WebAssembly/wasi-sdk

Option to suppress errors related to unsupported features

Open
#534 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CMake
Stars
1.6k
Forks
237
Avg merge
18h 26m
Merged PRs (30d)
5

Description

From what I've gathered so far, it seems like unsupported functionality is guarded by emission of preprocessor errors at the point of #including a header that represents such functionality. Maybe there's something I've missed, but this seems somewhat heavy handed and difficult to work around. Presumably in most cases, including a header alone would not cause issues so long as certain symbols are not referenced?

My immediate issue relates to trying to build code for WASI which uses C++20 modules (a niche combo admittedly). Since the standard library module will just include a bunch of system headers, the build fails right away:

In file included from C:\WASM\wasi-sdk-25.0-x86_64-windows\share\wasi-sysroot\share\libc++\v1\std.cppm:52:
In file included from C:\WASM\wasi-sdk-25.0-x86_64-windows\bin\../share/wasi-sysroot/include/wasm32-wasi/c++/v1\csetjmp:37:
C:\WASM\wasi-sdk-25.0-x86_64-windows\bin\../share/wasi-sysroot/include/wasm32-wasi\setjmp.h:13:2: error: Setjmp/longjmp support requires Exception handling support, which is [not yet standardized](https://github.com/WebAssembly/proposals?tab=readme-ov-file#phase-3---implementation-phase-cg--wg). To enable it, compile with `-mllvm -wasm-enable-sjlj` and use an engine that implements the Exception handling proposal.
   13 | #error Setjmp/longjmp support requires Exception handling support, which is [not yet standardized](https://github.com/WebAssembly/proposals?tab=readme-ov-file#phase-3---implementation-phase-cg--wg). To enable it, compile with `-mllvm -wasm-enable-sjlj` and use an engine that implements the Exception handling proposal.
      |  ^
In file included from C:\WASM\wasi-sdk-25.0-x86_64-windows\share\wasi-sysroot\share\libc++\v1\std.cppm:53:
In file included from C:\WASM\wasi-sdk-25.0-x86_64-windows\bin\../share/wasi-sysroot/include/wasm32-wasi/c++/v1\csignal:46:
C:\WASM\wasi-sdk-25.0-x86_64-windows\bin\../share/wasi-sysroot/include/wasm32-wasi\signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
    2 | #error "wasm lacks signal support; to enable minimal signal emulation, \
      |  ^
2 errors generated.

Is it feasible to allow for these errors to be conditionally disabled via macros (actually it seems for the signals there is a macro, but not for the exceptions), leaving it up to the user to navigate potential linker/runtime issues that could result?

Contributor guide

No contributing guide indexed for this repository

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 inspecting the unsupported-feature guards in setjmp.h and signal.h, along with the inclusion paths through csetjmp, csignal, and std.cppm. Determine whether conditional suppression can be made consistent without changing the existing opt-in behavior; done would require an agreed macro-based approach and validation that the headers can be included without those preprocessing errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
compilers, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.