Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion runtime/druntime/src/rt/dmain2.d
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ extern (C) int rt_init()
return 0;
}

version (Emscripten)
{
private extern (C) void rt_term_atexit()
{
rt_term();
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest putting this as nested static function directly above the single usage below.


/**********************************************
* Terminate use of druntime.
*/
Expand Down Expand Up @@ -547,7 +555,12 @@ private extern (C) int _d_run_main2(char[][] args, size_t totalArgsLength, MainF
else
result = EXIT_FAILURE;

if (!rt_term())
version (Emscripten)
{
import core.stdc.stdlib : atexit;
atexit(&rt_term_atexit);
}
else if (!rt_term())
result = (result == EXIT_SUCCESS) ? EXIT_FAILURE : result;
}

Expand Down
Loading