[llvm] [ORC] Add UUID support to MachOPlatform::HeaderOptions. (PR #191873)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 11:58:22 PDT 2026
https://github.com/lhames created https://github.com/llvm/llvm-project/pull/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.
>From 6768502e3fe3aefd81a64ff5cc751103f5f1303a Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Tue, 14 Apr 2026 04:45:22 +1000
Subject: [PATCH] [ORC] Add UUID support to MachOPlatform::HeaderOptions.
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.
---
llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h | 5 +++++
llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h | 5 +++++
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp | 3 +++
3 files changed, 13 insertions(+)
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