WasmFS NodeRawFS is not consistent with NodeRawFS (non-WasmFS version)

Open Beginner friendly
#24,830 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
cpp, node.js, wasm

Research direction

The relevant backend is system/lib/wasmfs/backends/noderawfs_root.cpp, specifically the root initialization referenced in the report. Reproduce test.cc with emcc and Node using both -sNODERAWFS and -sWASMFS; done means /proc/self/exe returns the same Node executable path in both cases.

Written by the indexing model from the issue text.

Description

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.11 (d3432e7a2a6585331c94b041973fb16c9f332ce4)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 0f0079c29da4b4d5bbd43dced1db9ad6c6d11008)
Target: wasm32-unknown-emscripten
Thread model: posix

Consider this example:

/* test.cc */
#include <stdio.h>
#include <limits.h>
#include <unistd.h>

int main(int argc, char** argv) {
  char buf[PATH_MAX + 1];
  ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
  if (len > PATH_MAX) {
    return 2;
  }
  printf("self exe: %s", buf);
  fflush(stdout);
  return 0;
}
% emcc -sEXIT_RUNTIME -sNODERAWFS test.cc && node a.out.js
self exe: /home/trybka/.nvm/versions/node/v22.13.1/bin/node

vs.

% emcc -sEXIT_RUNTIME -sNODERAWFS -sWASMFS test.cc && node a.out.js
self exe: 

This is because the "root" of the VFS for NodeRawFS should be /, but when using WasmFS it is . (I assume, via https://github.com/emscripten-core/emscripten/blob/e5c41dbbc93b3a4ab3e0c30935223865facfdbcb/system/lib/wasmfs/backends/noderawfs_root.cpp#L11)

If I change the . to / then it works the same in both cases.

Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 15h
Merged PRs (30d)
109

Contributor guide

Open the contributing guide

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.

More from emscripten-core/emscripten

All issues in emscripten-core/emscripten

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.