Skip to content

wasm: find emcc by the name the platform actually installs - #2629

Merged
bfiete merged 2 commits into
beefytech:masterfrom
robknopf:pr/emcc-resolve
Nov 30, 2026
Merged

bfiete merged 2 commits into
beefytech:masterfrom
robknopf:pr/emcc-resolve

Conversation

@robknopf

Copy link
Copy Markdown
Contributor

The wasm link step and the $(EmccPath) macro both expected upstream/emscripten/emcc.exe. That's what the emsdk from fetch_wasm.bat has, but an emsdk installed from upstream ships only emcc.bat, emcc.ps1 and emcc.py on Windows. Pointing Beef at one (which #2523 added support for) failed before linking:

Emscripten compiler not found at '...\upstream\emscripten\emcc.exe'

$(EmccPath) also hardcoded .exe on every platform.

Both now go through BuildContext.GetEmccPath, which takes emcc.exe, or else emcc.bat and reports that it needs a shell, on Windows, and a plain emcc elsewhere. A .bat can't be spawned directly, so the link step sets .ShellCommand when needed.

Depends on #2533. A shell-wrapped run with an args file left cmd.exe at an interactive prompt, and this is the first change that sets .ShellCommand. This branch includes #2533's commit until that merges.

DoRun builds the shell invocation for .ShellCommand, setting cmd.exe and
'/s /c "<exe> <args>"', and then the args file block below it overwrites the
arguments with '@tempfile'. cmd.exe is left with no '/c', so it opens an
interactive prompt and the build waits on it forever. The two have never been
combinable; nothing set .ShellCommand until now, so nothing hit it.

The substitution now happens first, into 'effArgs', and the shell and batch
wrappings consume that, giving 'cmd /s /c "<exe> @tempfile"'. Behaviour without
.ShellCommand or .BatchCommand is unchanged: the same arguments are set from
the same inputs, just earlier.

Also deletes the previous mTempFileName in the batch branch before replacing
it, which the args file branch already did and which leaked otherwise.
The emsdk that fetch_wasm.bat unpacks has an emcc.exe, and the link path and
the $(EmccPath) macro were both written against it. An emsdk installed from
upstream ships emcc.bat, emcc.ps1 and emcc.py on Windows and no .exe at all, so
pointing Beef at one made the link fail its existence check before it started:

    Emscripten compiler not found at '...\upstream\emscripten\emcc.exe'

which is the configuration beefytech#2523 added support for. Naming emcc.bat is not
enough on its own either, since a .bat cannot be spawned directly; the queued
run has to go through a shell, which ExecutionQueueCmd could already express
through mRunFlags but nothing set.

Both sites now go through GetEmccPath, which takes the emsdk root and reports
what is there: emcc.exe, else emcc.bat with 'needs a shell', else a plain emcc
off Windows. The link passes .ShellCommand when told to; $(EmccPath) needs no
flag, as ExecuteRaw already shells anything not ending in .exe.

$(EmccPath) also had no platform guard, so it named an emcc.exe that cannot
exist when the wasm32 config is built from a POSIX host.
@bfiete
bfiete merged commit 921900b into beefytech:master Nov 30, 2026
5 checks passed
@robknopf
robknopf deleted the pr/emcc-resolve branch November 30, 2026 23:56
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.

2 participants