jprendes / emception

Run Emscripten in the browser
Other
285 stars 35 forks source link

CI: Increase swap space to avoid OOM #26

Closed windowsair closed 1 month ago

windowsair commented 8 months ago

Github action seems out of memory, causing compilation to abort:

2023-12-23T06:53:42.4386009Z em++: error: 'tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/Interp/Disasm.cpp.o' failed (received SIGKILL (-9))
2023-12-23T06:53:42.4428220Z ninja: build stopped: subcommand failed.
2023-12-23T06:53:43.5446445Z ##[error]Process completed with exit code 1.

The patch adds swap space to CI and has been tested within my own repo. I'm not sure if we need to make any further changes to the build script or CI to make it abort when an error occurs, rather than silently continuing the build process?

davidar commented 1 month ago

Note that this is due to a longstanding issue with the efficiency of the wasm backend: https://github.com/llvm/llvm-project/issues/47793

As mentioned there it's due to a loop getting inlined into the function several hundred times, which the relooper struggles with. Removing it dramatically reduces the compilation time and memory usage for that file:

diff --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index 9fc22f2b6ea0..5ef71fb5c034 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -52,9 +52,6 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {

   auto PrintName = [&OS](const char *Name) {
     OS << Name;
-    for (long I = 0, N = strlen(Name); I < 30 - N; ++I) {
-      OS << ' ';
-    }
   };

   for (CodePtr Start = getCodeBegin(), PC = Start; PC != getCodeEnd();) {