Repository navigation
0.2.2: Emscripten (wasm32-emscripten) - #8
Closed
Sunrisepeak wants to merge 1 commit into
Closed
Sunrisepeak wants to merge 1 commit into
Sunrisepeak wants to merge 1 commit into
Conversation
…en's C library and openkal-emscripten 0.6.0; fs::read without a 64 KiB stack array; an enquiry asks for the kind it reads absence from
Sunrisepeak
added a commit
that referenced
this pull request
Oct 28, 2026
…en's C library and openkal-emscripten 0.6.0; fs::read without a 64 KiB stack array; an enquiry asks for the kind it reads absence from (#9) Replaces #8 (closed when its base branch was deleted). - **Emscripten (`wasm32-emscripten`).** A wasm module over Emscripten's C library and openkal-emscripten 0.6.0, under node or in a page: `platform::emscripten`, `architecture::wasm32`, `is_emscripten`; `src/targets/emscripten.cppm`, `src/arch/wasm32.cppm`, `src/emscripten/` and the C library's part of `src/posix/fs.cpp`. No platform module is defined. A program that starts another fails at link, naming the openkal symbol (`checks/absent`). `interrupt` reports that no request to end is delivered; its openkal implementation moves to `src/kal/interrupt.cpp`. - **`fs::read` reads into the string**, not through a 64 KiB array on the stack (all of a wasm module's default stack). - **An enquiry asks for the kind it reads absence from** (`stamp_of`, `identity_of` reported existing files not found where an implementation fills only the fields asked for). - CI: `emscripten (node) dev/release` runs the five suites that start no program under node, builds `checks/constants` for the target and asserts the link failure in `checks/absent`. The checks resolve openkal-emscripten 0.6.0 from the index (mcpplibs/mcpp-index#618).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #7 (
os-0.2.1). When #7 merges, GitHub retargets this PR tomain.mcpplibs.os had no
wasm32-emscriptentarget. A program that imports it, such as openmui's web build, stops at the first module:This adds the target over Emscripten's C library and openkal-emscripten 0.6.0 (mcpplibs/openkal-emscripten#8, which brings it to openkal 0.17.1). Running the tests on the target also found three defects that are not specific to Emscripten.
The target
platform::emscripten,architecture::wasm32andis_emscripten. They are selected bysrc/targets/emscripten.cppmandsrc/arch/wasm32.cppm.host()is a constant expression, as on a native target.[target.'cfg(os = "emscripten")'.dependencies] openkal-emscripten = "0.6.0".src/emscripten/:machine:wasm32. The processor count is the one Emscripten reports (the host's in a-pthreadlink, otherwise one), and the memory is unknown.library: not supported. A wasm module loads another only when it is linked with-sMAIN_MODULE.execreplaces no program's image, and the terminal is always in the foreground.dup/dup2, because openkal-emscripten's streams are the C library's descriptors.memfs,nodefs,idbfs, …), asked of itsFS.src/posix/fs.cpp.openkal.processthere is no stop word, soavailable()andrequested()are false andend_as_requested()does nothing. The openkal implementation moves unchanged tosrc/kal/interrupt.cpp, whichcfg(not(os = "emscripten"))selects. Before this change, a program that calledinterrupt::available()did not link on Emscripten.openkal.process, soprocess::self,run,spawnand so on fail at link, naming the openkal symbol.checks/absentasserts this in CI.process.ois linked into every program, but wasm-ld reports only undefined symbols that are reached, so a program that does not start one links.Defects found on the way (they affect every target)
fs::readoverflowed a wasm module's whole stack. It read throughchar buf[65536]on the stack, and Emscripten's default stack is 65536 bytes ("Stack overflow detected"). It now reads into the string's own storage (resize_and_overwrite), which also saves a copy.stamp_ofandidentity_ofreported existing files as not found.info()asked openkal only for the size, time or identity, then readkindto detect absence. openkal says an implementation fills only the fields that are asked for, and openkal-emscripten does exactly that, sokindstayed 0 (kal_node_absent).info()now also asks for the kind.caps()first. On a volume that has neither, they check that the request is refused withnot_supportedand changes nothing.fs_testnames its scratch directory with random bytes where no program can be named.CI
A new
emscripten (node) dev/releasejob:checks/emscripten, the package's own tests by#include) under node;checks/constantsfor the target;checks/absent.Until openkal-emscripten 0.6.0 is in the index, those three check projects pin it by git
revfrom the root, which the root's declaration allows. The comment says to remove the pin when the release is published. The package's own manifest names the version,"0.6.0".Measured locally
checks/emscriptenpasses 5 of 5 with--profile devand with--profile release.checks/constantsbuilds for wasm.checks/discardedlinks andchecks/misusefails naming the three platform functions, as on native.Release order
checks/are removed.