[clang] [ClangLinkerWrapper] Use discrete steps in verbose mode (PR #204186)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 07:26:54 PDT 2026


================
@@ -790,8 +855,52 @@ wrapDeviceImages(ArrayRef<std::unique_ptr<MemoryBuffer>> Buffers,
   return *FileOrErr;
 }
 
+/// Perform the OpenMP bundling with 'llvm-offload-binary' in verbose mode.
 Expected<SmallVector<std::unique_ptr<MemoryBuffer>>>
-bundleOpenMP(ArrayRef<OffloadingImage> Images) {
+bundleOpenMPVerbose(ArrayRef<OffloadingImage> Images, const ArgList &Args) {
+  Expected<std::string> OffloadBinaryPath = findProgram(
+      "llvm-offload-binary", {getExecutableDir("llvm-offload-binary")});
+  if (!OffloadBinaryPath)
+    return OffloadBinaryPath.takeError();
+
+  BumpPtrAllocator Alloc;
+  StringSaver Saver(Alloc);
+  SmallVector<std::unique_ptr<MemoryBuffer>> Buffers;
+  for (const OffloadingImage &Image : Images) {
+    StringRef ImageFile = Image.Image->getBufferIdentifier();
+    auto BinaryOrErr =
+        createOutputFile(sys::path::stem(ImageFile) + "." +
+                             getOffloadKindName(Image.TheOffloadKind),
+                         "offload");
+    if (!BinaryOrErr)
+      return BinaryOrErr.takeError();
+
+    std::string ImageArg = ("--image=file=" + ImageFile +
----------------
yxsamliu wrote:

Could this preserve the image kind from the normal path? The non-verbose path records linked images as `IMG_Object` or `IMG_Bitcode`, but this verbose path sends a `.img` file through `llvm-offload-binary`, which appears to infer `IMG_None` from the extension. Even if the bytes are the same, the offload binary metadata may differ under `--wrapper-verbose --save-temps`.

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


More information about the cfe-commits mailing list