[Openmp-commits] [openmp] [Libomptarget] Remove temporary files in AMDGPU JIT impl (PR #77980)

Jan Patrick Lehr via Openmp-commits openmp-commits at lists.llvm.org
Mon Jan 15 04:43:53 PST 2024


================
@@ -2039,12 +2045,20 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
     std::string Error;
     int RC = sys::ExecuteAndWait(LLDPath, Args, std::nullopt, {}, 0, 0, &Error);
     if (RC)
-      return createStringError(inconvertibleErrorCode(),
-                               "Linking optimized bitcode failed: %s",
-                               Error.c_str());
+      return Plugin::error("Linking optimized bitcode failed: %s",
+                           Error.c_str());
+
+    auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(LinkerOutputFilePath);
+    if (!BufferOrErr)
+      return Plugin::error("Failed to open temporary file for lld");
+
+    // Clean up the temporary files afterwards.
+    if (sys::fs::remove(LinkerOutputFilePath))
+      return Plugin::error("Failed to remove temporary file for lld");
+    if (sys::fs::remove(LinkerInputFilePath))
+      return Plugin::error("Failed to remove temporary file for lld");
----------------
jplehr wrote:

```suggestion
      return Plugin::error("Failed to remove temporary input file for lld");
```

Or whatever is appropriate here. Though it may not be super helpful for the end-user, maybe it can be for a developer.

https://github.com/llvm/llvm-project/pull/77980


More information about the Openmp-commits mailing list