Skip to content

Commit

Permalink
webassembly doesnt end with main...
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdruppe committed Oct 24, 2024
1 parent 6211aa0 commit 84d89ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions druntime/src/rt/dmain2.d
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,16 @@ private extern (C) int _d_run_main2(char[][] args, size_t totalArgsLength, MainF
else
result = EXIT_FAILURE;

if (!rt_term())
result = (result == EXIT_SUCCESS) ? EXIT_FAILURE : result;
version(WebAssembly) {
// for wasm, it is possible that main is set up to run async;
// it just set up event handlers and keeps going. as such we will not
// actually call rt_term as the program does not actually exit until
// the browser tab is closed
result = EXIT_SUCCESS;
} else {
if (!rt_term())
result = (result == EXIT_SUCCESS) ? EXIT_FAILURE : result;
}
}

tryExec(&runAll);
Expand Down
4 changes: 2 additions & 2 deletions opend/src/opend.d
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ struct Commands {
`);

import std.stdio;
writeln("Installation complete, build with `opend build -mtriple=wasm32-emscripten <other args>`");
writeln("Installation complete, build with `opend --target=emscripten <other args>`");
writeln("You will need the emsdk. Install that separately and follow its instructions to activate it before trying to build D code because opend will use emcc to finish the link step.");
writeln("https://emscripten.org/docs/getting_started/downloads.html");

Expand All @@ -339,7 +339,7 @@ struct Commands {
`);

import std.stdio;
writeln("Installation complete, build with `opend build -mtriple=x86_64-windows-msvc <other args>`");
writeln("Installation complete, build with `opend --target=win64 <other args>`");

return 0;
default:
Expand Down

0 comments on commit 84d89ad

Please sign in to comment.