WebAssembly / WebAssembly/wasi-sdk

Avoid stdlib printing to stdout/stderr?

Open
#190 27 comments 1 reaction 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

A very minimal code sample like this:

#include <memory>

int main() {
  auto a = std::shared_ptr<int>(new int(3));
  return *a + 40;
}

compiled with WASI SDK like this:

clang++ --target=wasm32-wasi -O3 -flto -Wl,--lto-O3 -fno-exceptions --sysroot=/path/to/wasi-sysroot -o test.wasm ./test.cpp

results in a Wasm module that expects wasi_snapshot_preview1::{fd_close, fd_seek, fd_write} as imports, which feels unexpected to me. I am not sure why these imports are there, because I can’t find any embedded debugging strings, but I am assuming it’s because failed allocations etc will print to stderr? Is there any way to disable that and just fail with unreachable instead?

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

Reproduce the minimal C++ example with the shown WASI SDK and inspect the resulting imports. Trace which standard-library or wasi-libc components introduce fd_close, fd_seek, and fd_write. Done means determining whether those imports can be removed or disabled, and documenting the supported configuration or limitation; no source file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
build-system, compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.