Skip to content

Update EMSDK to 5.0.0#479

Open
kvpanch wants to merge 4 commits intomainfrom
kvpanch/emsdk_update
Open

Update EMSDK to 5.0.0#479
kvpanch wants to merge 4 commits intomainfrom
kvpanch/emsdk_update

Conversation

@kvpanch
Copy link
Contributor

@kvpanch kvpanch commented Feb 16, 2026

Emscripten 4.0.12 introduced breaking change by changing module factory to always return promise even if WASM_ASYNC_COMPILATION=0. Due to the last def, it's necessary to strip await keyword from generated resolc.js to keep it synchronous for C FFI.

Emscripten 4.0.12 introduced breaking change by changing module factory
to always return promise even if `WASM_ASYNC_COMPILATION=0`. Due to the
last def, it's necessary to strip `await` keyword from generated
`resolc.js` to keep it synchronous for C FFI.
@kvpanch kvpanch marked this pull request as ready for review February 17, 2026 15:07
@kvpanch kvpanch requested review from elle-j and xermicus February 17, 2026 15:07
Comment on lines +49 to +51
// 2. Remove all "await" keywords.
// With WASM_ASYNC_COMPILATION=0 all awaited values are not Promises,
// so removing await just evaluates the expression directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't there be other operations not affected by WASM_ASYNC_COMPILATION that still need to be awaited?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With WASM_ASYNC_COMPILATION=0 (which we use) they should be evaluated directly, so it should be safe to remove them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then wouldn't it essentially be the same as skipping this step altogether? Then it'd be less modifications and less risk of potentially removing a needed await somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it's necessary to remove them, otherwise there will be syntax error.

console.log('Changed "return readyPromise" to "return Module"');
}

if (!modified) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the script succeeds if modified was updated one or more times. Should it succeed even if it was only updated once? Or perhaps some combination thereof.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting question. The resolc.js file is generated as a part of llvm release, so it always has same structure. Assuming bump of emscripten won't happen in nearest future, even updating and releasing new LLVM binary won't change resolc.js content, therefore it should be fine to just keep a check if (!modified) error
Writing more generic check, i.e. modified != 3 might be useful if we find emscripten will constantly change content of the generated JS file.
That said, I think it might be an overkill now, but can be useful if there will be issues with that script

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright 👍 (Yeah, was thinking that if e.g. "return async function(moduleArg" was replaced, should we then always expect one (or some) of the other steps to also have replaced something in particular. If so, then we could detect early if the something went wrong in the script.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does usage change for the end-user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not. Do you think it can increase compile time?

@xermicus xermicus requested a review from smiasojed February 17, 2026 21:28
@xermicus
Copy link
Member

@smiasojed deferring the review to you since I'm afk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments