Skip to content

offload: automate additional steps#152777

Draft
ZuseZ4 wants to merge 4 commits intorust-lang:mainfrom
ZuseZ4:replace-clang-linker2
Draft

offload: automate additional steps#152777
ZuseZ4 wants to merge 4 commits intorust-lang:mainfrom
ZuseZ4:replace-clang-linker2

Conversation

@ZuseZ4
Copy link
Member

@ZuseZ4 ZuseZ4 commented Feb 18, 2026

No description provided.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 18, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 6701 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [style (compiler)]: /checkout/compiler/rustc_codegen_llvm/src/back/write.rs:921: `dbg!` macro is intended as a debugging tool. It should not be in version control.
tidy [style (compiler)]: /checkout/compiler/rustc_codegen_llvm/src/back/write.rs:926: `dbg!` macro is intended as a debugging tool. It should not be in version control.
tidy [style (compiler)]: /checkout/compiler/rustc_codegen_llvm/src/back/write.rs:927: `dbg!` macro is intended as a debugging tool. It should not be in version control.
tidy [style (compiler)]: /checkout/compiler/rustc_codegen_llvm/src/back/write.rs:940: `dbg!` macro is intended as a debugging tool. It should not be in version control.
tidy [style (compiler)]: /checkout/compiler/rustc_codegen_llvm/src/back/write.rs:942: `dbg!` macro is intended as a debugging tool. It should not be in version control.
tidy [style (compiler)]: /checkout/compiler/rustc_codegen_llvm/src/back/write.rs:955: `dbg!` macro is intended as a debugging tool. It should not be in version control.
tidy [style (compiler)]: FAIL
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (26.0.1)
linting python files
---
^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:205:5: error: code should be clang-formatted [-Wclang-format-violations]
  //LLVMContext Context;
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:206:5: error: code should be clang-formatted [-Wclang-format-violations]
  //Module M("offload.wrapper.module", Context);
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:207:5: error: code should be clang-formatted [-Wclang-format-violations]
  //M.setTargetTriple(llvm::Triple("x86_64-unknown-linux"));
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:208:13: error: code should be clang-formatted [-Wclang-format-violations]
  if (!MRef) return false;
            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:213:5: error: code should be clang-formatted [-Wclang-format-violations]
  //for (StringRef Input : InputFiles) {
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:213:41: error: code should be clang-formatted [-Wclang-format-violations]
  //for (StringRef Input : InputFiles) {
                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:214:57: error: code should be clang-formatted [-Wclang-format-violations]
    ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
                                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:215:45: error: code should be clang-formatted [-Wclang-format-violations]
        MemoryBuffer::getFileOrSTDIN(Input);
                                            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:216:53: error: code should be clang-formatted [-Wclang-format-violations]
    if (std::error_code EC = BufferOrErr.getError())
                                                    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:217:20: error: code should be clang-formatted [-Wclang-format-violations]
      return false;
                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:218:44: error: code should be clang-formatted [-Wclang-format-violations]
    std::unique_ptr<MemoryBuffer> &Buffer =
                                           ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:219:55: error: code should be clang-formatted [-Wclang-format-violations]
        Buffers.emplace_back(std::move(*BufferOrErr));
                                                      ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:220:32: error: code should be clang-formatted [-Wclang-format-violations]
    BuffersToWrap.emplace_back(
                               ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:223:5: error: code should be clang-formatted [-Wclang-format-violations]
  //static const char ImagePath[] = "/p/lustre1/drehwald1/prog/offload/r/image";
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:223:36: error: code should be clang-formatted [-Wclang-format-violations]
  //static const char ImagePath[] = "/p/lustre1/drehwald1/prog/offload/r/image";
                                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:225:5: error: code should be clang-formatted [-Wclang-format-violations]
  //ArrayRef<char> Buf(ImagePath, std::strlen(ImagePath));
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:226:5: error: code should be clang-formatted [-Wclang-format-violations]
  //ArrayRef<ArrayRef<char>> BuffersToWrap(Buf);
    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:266:81: error: code should be clang-formatted [-Wclang-format-violations]
  // Try to extract each device image specified by the user from the input file.
                                                                                ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:267:28: error: code should be clang-formatted [-Wclang-format-violations]
---
                                                ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:271:50: error: code should be clang-formatted [-Wclang-format-violations]
    SmallVector<const OffloadBinary *> Extracted;
                                                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:272:47: error: code should be clang-formatted [-Wclang-format-violations]
    for (const OffloadFile &File : Binaries) {
                                              ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:273:45: error: code should be clang-formatted [-Wclang-format-violations]
      const auto *Binary = File.getBinary();
                                            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:274:66: error: code should be clang-formatted [-Wclang-format-violations]
      // We handle the 'file' and 'kind' identifiers differently.
                                                                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:275:55: error: code should be clang-formatted [-Wclang-format-violations]
      bool Match = llvm::all_of(Args, [&](auto &Arg) {
                                                      ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:276:39: error: code should be clang-formatted [-Wclang-format-violations]
        const auto [Key, Value] = Arg;
                                      ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:277:27: error: code should be clang-formatted [-Wclang-format-violations]
        if (Key == "file")
                          ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:278:23: error: code should be clang-formatted [-Wclang-format-violations]
          return true;
                      ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:279:27: error: code should be clang-formatted [-Wclang-format-violations]
        if (Key == "kind")
                          ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:280:68: error: code should be clang-formatted [-Wclang-format-violations]
          return Binary->getOffloadKind() == getOffloadKind(Value);
                                                                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:281:48: error: code should be clang-formatted [-Wclang-format-violations]
        return Binary->getString(Key) == Value;
                                               ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:282:10: error: code should be clang-formatted [-Wclang-format-violations]
      });
         ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:283:17: error: code should be clang-formatted [-Wclang-format-violations]
---
                                           ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:288:29: error: code should be clang-formatted [-Wclang-format-violations]
    if (Extracted.empty()) {
                            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:289:52: error: code should be clang-formatted [-Wclang-format-violations]
      llvm::errs() << "Didn't extract anything!\n";
                                                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:290:57: error: code should be clang-formatted [-Wclang-format-violations]
      return createStringError(inconvertibleErrorCode(),
                                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:291:79: error: code should be clang-formatted [-Wclang-format-violations]
---
     ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:293:36: error: code should be clang-formatted [-Wclang-format-violations]
    llvm::errs() << "extracted!\n";
                                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:295:57: error: code should be clang-formatted [-Wclang-format-violations]
    if (auto It = Args.find("file"); It != Args.end()) {
                                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:296:34: error: code should be clang-formatted [-Wclang-format-violations]
      if (Extracted.size() > 1) {
                                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:297:36: error: code should be clang-formatted [-Wclang-format-violations]
        llvm::errs() << "panic!\n";
                                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:298:8: error: code should be clang-formatted [-Wclang-format-violations]
      }
       ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:299:73: error: code should be clang-formatted [-Wclang-format-violations]
      if (Error E = writeFile(It->second, Extracted.back()->getImage()))
                                                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:300:18: error: code should be clang-formatted [-Wclang-format-violations]
        return E;
                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:301:13: error: code should be clang-formatted [-Wclang-format-violations]
    } else {
            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:302:24: error: code should be clang-formatted [-Wclang-format-violations]
      uint64_t Idx = 0;
                       ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:303:54: error: code should be clang-formatted [-Wclang-format-violations]
      for (const OffloadBinary *Binary : Extracted) {
                                                     ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:304:29: error: code should be clang-formatted [-Wclang-format-violations]
        StringRef Filename =
                            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:305:80: error: code should be clang-formatted [-Wclang-format-violations]
            Saver.save(sys::path::stem(InputFile) + "-" + Binary->getTriple() +
                                                                               ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:306:79: error: code should be clang-formatted [-Wclang-format-violations]
                       "-" + Binary->getArch() + "." + std::to_string(Idx++) +
                                                                              ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:307:72: error: code should be clang-formatted [-Wclang-format-violations]
                       "." + getImageKindName(Binary->getImageKind()));
                                                                       ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:308:63: error: code should be clang-formatted [-Wclang-format-violations]
        if (Error E = writeFile(Filename, Binary->getImage()))
                                                              ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:309:20: error: code should be clang-formatted [-Wclang-format-violations]
          return E;
                   ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:310:8: error: code should be clang-formatted [-Wclang-format-violations]
      }
       ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:316:64: error: code should be clang-formatted [-Wclang-format-violations]
extern "C" bool LLVMRustUnbundleImages(const char *HostOutPath, size_t PathLen) {
                                                               ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:318:38: error: code should be clang-formatted [-Wclang-format-violations]
  llvm::errs() << "file: " << file <<"\n";
                                     ^

clang-format linting failed! Printing diff suggestions:
--- /checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp (actual)
+++ /checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp (formatted)
---
 #include "llvm/Frontend/Offloading/OffloadWrapper.h"
 #include "llvm/Frontend/Offloading/Utility.h"
 #include "llvm/Object/OffloadBinary.h"
@@ -201,30 +199,32 @@
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/TargetParser/Host.h"
 extern "C" bool LLVMRustWrapImages(LLVMModuleRef MRef) {
-  //LLVMContext Context;
-  //Module M("offload.wrapper.module", Context);
-  //M.setTargetTriple(llvm::Triple("x86_64-unknown-linux"));
-  if (!MRef) return false;
+  // LLVMContext Context;
+  // Module M("offload.wrapper.module", Context);
+  // M.setTargetTriple(llvm::Triple("x86_64-unknown-linux"));
+  if (!MRef)
+    return false;
   Module &M = *unwrap(MRef);
   SmallVector<std::unique_ptr<MemoryBuffer>> Buffers;
   SmallVector<ArrayRef<char>> BuffersToWrap;
   StringRef Input = "/p/lustre1/drehwald1/prog/offload/r/image";
-  //for (StringRef Input : InputFiles) {
-    ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
-        MemoryBuffer::getFileOrSTDIN(Input);
-    if (std::error_code EC = BufferOrErr.getError())
-      return false;
-    std::unique_ptr<MemoryBuffer> &Buffer =
-        Buffers.emplace_back(std::move(*BufferOrErr));
-    BuffersToWrap.emplace_back(
-        ArrayRef<char>(Buffer->getBufferStart(), Buffer->getBufferSize()));
+  // for (StringRef Input : InputFiles) {
+  ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
+      MemoryBuffer::getFileOrSTDIN(Input);
+  if (std::error_code EC = BufferOrErr.getError())
+    return false;
+  std::unique_ptr<MemoryBuffer> &Buffer =
+      Buffers.emplace_back(std::move(*BufferOrErr));
+  BuffersToWrap.emplace_back(
+      ArrayRef<char>(Buffer->getBufferStart(), Buffer->getBufferSize()));
   //}
-  //static const char ImagePath[] = "/p/lustre1/drehwald1/prog/offload/r/image";
+  // static const char ImagePath[] =
+  // "/p/lustre1/drehwald1/prog/offload/r/image";
 
-  //ArrayRef<char> Buf(ImagePath, std::strlen(ImagePath));
-  //ArrayRef<ArrayRef<char>> BuffersToWrap(Buf);
+  // ArrayRef<char> Buf(ImagePath, std::strlen(ImagePath));
+  // ArrayRef<ArrayRef<char>> BuffersToWrap(Buf);
   llvm::errs() << "wraping\n";
 
   if (Error Err = offloading::wrapOpenMPBinaries(
           M, BuffersToWrap, offloading::getOffloadEntryArray(M),
@@ -263,60 +263,61 @@
     return Err;
   llvm::errs() << "got Binary\n";
 
   // Try to extract each device image specified by the user from the input file.
-    BumpPtrAllocator Alloc;
-    StringSaver Saver(Alloc);
-    auto Args = getImageArguments(Image, Saver);
+  BumpPtrAllocator Alloc;
+  StringSaver Saver(Alloc);
+  auto Args = getImageArguments(Image, Saver);
 
-    SmallVector<const OffloadBinary *> Extracted;
-    for (const OffloadFile &File : Binaries) {
-      const auto *Binary = File.getBinary();
-      // We handle the 'file' and 'kind' identifiers differently.
-      bool Match = llvm::all_of(Args, [&](auto &Arg) {
-        const auto [Key, Value] = Arg;
-        if (Key == "file")
-          return true;
-        if (Key == "kind")
-          return Binary->getOffloadKind() == getOffloadKind(Value);
-        return Binary->getString(Key) == Value;
-      });
-      if (Match)
-        Extracted.push_back(Binary);
-    }
-    llvm::errs() << "before I extracted\n";
+  SmallVector<const OffloadBinary *> Extracted;
+  for (const OffloadFile &File : Binaries) {
+    const auto *Binary = File.getBinary();
+    // We handle the 'file' and 'kind' identifiers differently.
+    bool Match = llvm::all_of(Args, [&](auto &Arg) {
+      const auto [Key, Value] = Arg;
+      if (Key == "file")
+        return true;
+      if (Key == "kind")
+        return Binary->getOffloadKind() == getOffloadKind(Value);
+      return Binary->getString(Key) == Value;
+    });
+    if (Match)
+      Extracted.push_back(Binary);
+  }
+  llvm::errs() << "before I extracted\n";
+
+  if (Extracted.empty()) {
+    llvm::errs() << "Didn't extract anything!\n";
+    return createStringError(inconvertibleErrorCode(),
+                             "Offload binary has invalid size alignment");
+  }
+  llvm::errs() << "extracted!\n";
 
-    if (Extracted.empty()) {
-      llvm::errs() << "Didn't extract anything!\n";
-      return createStringError(inconvertibleErrorCode(),
-                                 "Offload binary has invalid size alignment");
+  if (auto It = Args.find("file"); It != Args.end()) {
+    if (Extracted.size() > 1) {
+      llvm::errs() << "panic!\n";
     }
-    llvm::errs() << "extracted!\n";
-
-    if (auto It = Args.find("file"); It != Args.end()) {
-      if (Extracted.size() > 1) {
-        llvm::errs() << "panic!\n";
-      }
-      if (Error E = writeFile(It->second, Extracted.back()->getImage()))
+    if (Error E = writeFile(It->second, Extracted.back()->getImage()))
+      return E;
+  } else {
+    uint64_t Idx = 0;
+    for (const OffloadBinary *Binary : Extracted) {
+      StringRef Filename =
+          Saver.save(sys::path::stem(InputFile) + "-" + Binary->getTriple() +
+                     "-" + Binary->getArch() + "." + std::to_string(Idx++) +
+                     "." + getImageKindName(Binary->getImageKind()));
+      if (Error E = writeFile(Filename, Binary->getImage()))
         return E;
-    } else {
-      uint64_t Idx = 0;
-      for (const OffloadBinary *Binary : Extracted) {
-        StringRef Filename =
-            Saver.save(sys::path::stem(InputFile) + "-" + Binary->getTriple() +
-                       "-" + Binary->getArch() + "." + std::to_string(Idx++) +
-                       "." + getImageKindName(Binary->getImageKind()));
-        if (Error E = writeFile(Filename, Binary->getImage()))
-          return E;
-      }
     }
+  }
 
   return Error::success();
 }
 
-extern "C" bool LLVMRustUnbundleImages(const char *HostOutPath, size_t PathLen) {
+extern "C" bool LLVMRustUnbundleImages(const char *HostOutPath,
+                                       size_t PathLen) {
   StringRef file = StringRef(HostOutPath, PathLen);
-  llvm::errs() << "file: " << file <<"\n";
+  llvm::errs() << "file: " << file << "\n";
   auto image = "file=dev.o,arch=gfx90a";
   if (Error E = unbundleImages(image, file)) {
     return false;
   }

rerun tidy with `--extra-checks=cpp:fmt --bless` to reformat C++ code
tidy [extra_checks]: checks with external tool 'clang-format' failed
tidy [extra_checks]: FAIL
tidy: The following checks failed: extra_checks, style (compiler)
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1365:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:23
  local time: Wed Feb 18 04:50:23 UTC 2026
  network time: Wed, 18 Feb 2026 04:50:23 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants