From 66a019967695807ee37b80c3b0fca7b9d09bff26 Mon Sep 17 00:00:00 2001 From: Jason Li Date: Tue, 2 Jul 2024 16:31:50 -0400 Subject: [PATCH] [SYCL][ClangLinkerWrapper] Make all temp files use different names (#14243) Resolve issue with -save-temps regarding a temp file being linked to itself. --------- Co-authored-by: Marcos Maronas --- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 158e3978e70e7..e24b1c034275f 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -211,7 +211,9 @@ Expected createOutputFile(const Twine &Prefix, StringRef Extension) { std::scoped_lock Lock(TempFilesMutex); SmallString<128> OutputFile; if (SaveTemps) { - (Prefix + "." + Extension).toNullTerminatedStringRef(OutputFile); + // Generate a unique path name without creating a file + sys::fs::createUniquePath(Prefix + "-%%%%%%." + Extension, OutputFile, + /*MakeAbsolute=*/false); } else { if (std::error_code EC = sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))