From bdfdbfbbac4a0f47d8b789167697d6dd70a39720 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 10 May 2019 09:08:28 -0700 Subject: Emit process ID in the filenames of byn* tempfiles (#1916) Helps to avoid trampling each other when binaryen is called multiple times from emcc, for example. --- src/passes/pass.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index eb49072ba..287dd1cf9 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef __linux__ +#include +#endif + #include "ir/hashed.h" #include "ir/module-utils.h" #include "pass.h" @@ -415,7 +419,12 @@ static void dumpWast(Name name, Module* wasm) { while (numstr.size() < 3) { numstr = '0' + numstr; } - auto fullName = std::string("byn-") + numstr + "-" + name.str + ".wasm"; + auto fullName = std::string("byn-"); +#ifdef __linux__ + // TODO: use _getpid() on windows, elsewhere? + fullName += std::to_string(getpid()) + '-'; +#endif + fullName += numstr + "-" + name.str + ".wasm"; Colors::disable(); ModuleWriter writer; writer.setBinary(false); // TODO: add an option for binary -- cgit v1.2.3