summaryrefslogtreecommitdiff
path: root/src/passes/pass.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-05-10 09:08:28 -0700
committerGitHub <noreply@github.com>2019-05-10 09:08:28 -0700
commitbdfdbfbbac4a0f47d8b789167697d6dd70a39720 (patch)
tree8f9aa2d8ddb509d885c67bb4c85c366e8e76c23d /src/passes/pass.cpp
parent14a286971d203e3caf6f49089fe6ddc16024861f (diff)
downloadbinaryen-bdfdbfbbac4a0f47d8b789167697d6dd70a39720.tar.gz
binaryen-bdfdbfbbac4a0f47d8b789167697d6dd70a39720.tar.bz2
binaryen-bdfdbfbbac4a0f47d8b789167697d6dd70a39720.zip
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.
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r--src/passes/pass.cpp11
1 files changed, 10 insertions, 1 deletions
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 <chrono>
#include <sstream>
+#ifdef __linux__
+#include <unistd.h>
+#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