From b01bac3506584402da98e874f52d8075beb145ff Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Sep 2021 11:27:30 +0200 Subject: Handle Emscripten -pthread mode --- libbuild2/cc/link-rule.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 76d8418..d8f22d4 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -1266,6 +1266,21 @@ namespace build2 if (wasm.path ().empty ()) wasm.derive_path (); + + // If we have -pthread then we get additional .worker.js file + // which is used for thread startup. In a somewhat hackish way we + // represent it as an exe{} member to make sure it gets installed + // next to the main .js file. + // + if (find_option ("-pthread", cmode) || + find_option ("-pthread", t, c_loptions) || + find_option ("-pthread", t, x_loptions)) + { + exe& worker (add_adhoc_member (t, "worker.js")); + + if (worker.path ().empty ()) + worker.derive_path (); + } } // Add VC's .pdb. Note that we are looking for the link.exe /DEBUG -- cgit v1.1