https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/183598

>From 00c1cc73d48c889aa721ab1c41382e5aa4379500 Mon Sep 17 00:00:00 2001
From: Joseph Huber <[email protected]>
Date: Thu, 26 Feb 2026 13:08:01 -0600
Subject: [PATCH 1/2] [Clang] Add response file support to clang-linker-wrapper

Summary:
This is needed on some platforms like Windows when the generated command
line becomes too large. This seems to be occurring in practice so we
need to support this. Uses the same basic support clang does.

No test because there isn't any current infrastructure to support it,
will likely be "tested" by ROCBLAS builds not failing anymore on
Windows.
---
 .../ClangLinkerWrapper.cpp                    | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 619e539857fc6..a0502065c6724 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -247,10 +247,38 @@ Error executeCommands(StringRef ExecutablePath, 
ArrayRef<StringRef> Args) {
   if (Verbose || DryRun)
     printCommands(Args);
 
-  if (!DryRun)
+  if (DryRun)
+    return Error::success();
+
+  // If the command line fits within system limits, execute directly.
+  if (sys::commandLineFitsWithinSystemLimits(ExecutablePath, Args)) {
     if (sys::ExecuteAndWait(ExecutablePath, Args))
       return createStringError(
           "'%s' failed", sys::path::filename(ExecutablePath).str().c_str());
+    return Error::success();
+  }
+
+  // Write the arguments to a response file and pass that instead.
+  auto TempFileOrErr = createOutputFile("response", "txt");
+  if (!TempFileOrErr)
+    return TempFileOrErr.takeError();
+
+  SmallString<0> Contents;
+  raw_svector_ostream OS(Contents);
+  for (StringRef Arg : llvm::drop_begin(Args)) {
+    sys::printArg(OS, Arg, /*Quote=*/true);
+    OS << " ";
+  }
+
+  if (std::error_code EC = sys::writeFileWithEncoding(*TempFileOrErr, 
Contents))
+    return createStringError("failed to write response file: %s",
+                             EC.message().c_str());
+
+  std::string ResponseFile = ("@" + *TempFileOrErr).str();
+  SmallVector<StringRef, 2> NewArgs = {Args.front(), ResponseFile};
+  if (sys::ExecuteAndWait(ExecutablePath, NewArgs))
+    return createStringError("'%s' failed",
+                             
sys::path::filename(ExecutablePath).str().c_str());
   return Error::success();
 }
 

>From d6d32d763921970783ca8cd2f977faca2aeeb083 Mon Sep 17 00:00:00 2001
From: Joseph Huber <[email protected]>
Date: Thu, 26 Feb 2026 13:54:21 -0600
Subject: [PATCH 2/2] .rsp

---
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index a0502065c6724..c49ce44432e5a 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -259,7 +259,7 @@ Error executeCommands(StringRef ExecutablePath, 
ArrayRef<StringRef> Args) {
   }
 
   // Write the arguments to a response file and pass that instead.
-  auto TempFileOrErr = createOutputFile("response", "txt");
+  auto TempFileOrErr = createOutputFile("response", "rsp");
   if (!TempFileOrErr)
     return TempFileOrErr.takeError();
 

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

Reply via email to