vgvassilev wrote:

Can you also try this patch on top of this PR:

```diff
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index 56f51e5d5311..68bfb871367d 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -57,7 +57,20 @@ bool link(llvm::ArrayRef<const char *> args, 
llvm::raw_ostream &stdoutOS,
 
 namespace clang {
 
-WasmIncrementalExecutor::WasmIncrementalExecutor() = default;
+WasmIncrementalExecutor::WasmIncrementalExecutor(llvm::Error &Err) {
+  llvm::ErrorAsOutParameter EAO(&Err);
+
+  if (Err)
+    return;
+
+  if (auto EC =
+          llvm::sys::fs::createUniqueDirectory("clang-wasm-exec-", TempDir))
+    Err = llvm::make_error<llvm::StringError>(
+        "Failed to create temporary directory for Wasm executor: " +
+            EC.message(),
+        llvm::inconvertibleErrorCode());
+}
+
 WasmIncrementalExecutor::~WasmIncrementalExecutor() = default;
 
 llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
@@ -74,11 +87,20 @@ llvm::Error 
WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
   llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
       PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
   PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
-  std::string ObjectFileName = PTU.TheModule->getName().str() + ".o";
-  std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm";
 
-  std::error_code Error;
-  llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), 
Error);
+  llvm::SmallString<256> ObjectFileName(TempDir);
+  llvm::sys::path::append(ObjectFileName,
+                          PTU.TheModule->getName() + ".o");
+
+  llvm::SmallString<256> BinaryFileName(TempDir);
+  llvm::sys::path::append(BinaryFileName,
+                          PTU.TheModule->getName() + ".wasm");
+
+  std::error_code EC;
+  llvm::raw_fd_ostream ObjectFileOutput(ObjectFileName, EC);
+
+  if (EC)
+    return llvm::errorCodeToError(EC);
 
   llvm::legacy::PassManager PM;
   if (TargetMachine->addPassesToEmitFile(PM, ObjectFileOutput, nullptr,
```

It should get rid of one of the downstream patches we have.

https://github.com/llvm/llvm-project/pull/175448
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to