[llvm] 1b1d450 - [ORC] Add UUID support to MachOPlatform::HeaderOptions. (#191873)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 12:45:56 PDT 2026


Author: Lang Hames
Date: 2026-04-13T20:44:43+01:00
New Revision: 1b1d450fbf9125ee35d05876b16d5c521084a521

URL: https://github.com/llvm/llvm-project/commit/1b1d450fbf9125ee35d05876b16d5c521084a521
DIFF: https://github.com/llvm/llvm-project/commit/1b1d450fbf9125ee35d05876b16d5c521084a521.diff

LOG: [ORC] Add UUID support to MachOPlatform::HeaderOptions. (#191873)

MachOPlatform::HeaderOptions now includes an optional UUID field. If
set, this will be used to build an LC_UUID load command for the
JITDylib's MachO header.

No testcase: MachOPlatform construction requires the ORC runtime, which
we can't require in LLVM regression or unit tests. In the future we
should test this through the ORC runtime.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h
    llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
    llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h
index 3d833348b9b2d..2af2dfed1c41a 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h
@@ -88,6 +88,11 @@ struct MachOBuilderLoadCommand<MachO::LC_UUID>
       : MachOBuilderLoadCommandImplBase<MachO::LC_UUID>() {
     memcpy(uuid, UUID, sizeof(uuid));
   }
+
+  MachOBuilderLoadCommand(const std::array<uint8_t, 16> &UUID)
+      : MachOBuilderLoadCommandImplBase<MachO::LC_UUID>() {
+    memcpy(uuid, UUID.data(), sizeof(uuid));
+  }
 };
 
 template <MachO::LoadCommandType LCType>

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h b/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
index 753c322a9121f..944f099c38b61 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
@@ -20,7 +20,9 @@
 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
 #include "llvm/Support/Compiler.h"
 
+#include <array>
 #include <future>
+#include <optional>
 #include <thread>
 #include <vector>
 
@@ -88,6 +90,9 @@ class LLVM_ABI MachOPlatform : public Platform {
     /// List of LC_BUILD_VERSIONs.
     std::vector<BuildVersionOpts> BuildVersions;
 
+    /// Optional UUID. If set, this will be used to add an LC_UUID command.
+    std::optional<std::array<uint8_t, 16>> UUID;
+
     HeaderOptions() = default;
     HeaderOptions(Dylib D) : IDDylib(std::move(D)) {}
   };

diff  --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index f8bdb6e541df1..410f972589531 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -1765,6 +1765,9 @@ jitlink::Block &createHeaderBlock(MachOPlatform &MOP,
   else
     B.template addLoadCommand<MachO::LC_ID_DYLIB>(JD.getName(), 0, 0, 0);
 
+  if (Opts.UUID)
+    B.template addLoadCommand<MachO::LC_UUID>(*Opts.UUID);
+
   for (auto &BV : Opts.BuildVersions)
     B.template addLoadCommand<MachO::LC_BUILD_VERSION>(
         BV.Platform, BV.MinOS, BV.SDK, static_cast<uint32_t>(0));


        


More information about the llvm-commits mailing list