https://github.com/wenju-he created 
https://github.com/llvm/llvm-project/pull/224502

runSYCLLink's AOT path built .out with a fixed deterministic name but never 
registered it with TempFiles, so it was deleted unconditionally at end-of-run, 
unlike every other intermediate in the pipeline.

Add registerTempFile() to record an already-named path into TempFiles without 
generating createTempFile's own random suffix, which would otherwise break 
callers relying on the deterministic "<stem>_<index>.out" name.

>From 84380337f301cea31eafde826965e8710e139ec0 Mon Sep 17 00:00:00 2001
From: Wenju He <[email protected]>
Date: Fri, 18 Sep 2026 05:11:03 +0200
Subject: [PATCH] [clang-sycl-linker] Keep AOT .out temp files under
 -save-temps

runSYCLLink's AOT path built .out with a fixed deterministic name but
never registered it with TempFiles, so it was deleted unconditionally
at end-of-run, unlike every other intermediate in the pipeline.

Add registerTempFile() to record an already-named path into TempFiles
without generating createTempFile's own random suffix, which would
otherwise break callers relying on the deterministic
"<stem>_<index>.out" name.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
---
 clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp 
b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
index 70afc6d6c4cea0..5690ee7788d64f 100644
--- a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
+++ b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
@@ -156,6 +156,13 @@ createTempFile(const ArgList &Args, const Twine &Prefix, 
StringRef Extension) {
   return TempFiles.back();
 }
 
+/// Registers an already fixed-named path for the same end-of-run cleanup
+/// createTempFile above provides, without its random suffix.
+static StringRef registerTempFile(std::string Path) {
+  TempFiles.emplace_back(Path);
+  return TempFiles.back();
+}
+
 static Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
                                          ArrayRef<StringRef> Paths) {
   if (DryRun)
@@ -1001,7 +1008,8 @@ static Error 
runSYCLLink(ArrayRef<std::unique_ptr<MemoryBuffer>> Inputs,
 
     SplitModules[I].ModuleFilePath = CodeGenFile;
     if (IsAOTCompileNeeded) {
-      std::string AOTFile = (Stem + "_" + Twine(I) + ".out").str();
+      StringRef AOTFile =
+          registerTempFile((Stem + "_" + Twine(I) + ".out").str());
       if (Error Err = runAOTCompile(CodeGenFile, AOTFile, Args))
         return Err;
       SplitModules[I].ModuleFilePath = AOTFile;

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

Reply via email to