[clang] [llvm] [HIP][MacOS] Mach-O support and Darwin toolchain fixes (PR #183991)
Paulius Velesko via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 07:30:14 PDT 2026
================
@@ -121,13 +123,26 @@ offloading::getOffloadEntryArray(Module &M, StringRef SectionName) {
auto Linkage = Triple.isOSBinFormatCOFF() ? GlobalValue::WeakODRLinkage
: GlobalValue::ExternalLinkage;
+ // Mach-O uses linker-defined section boundary symbols with a special naming
+ // convention: \1section$start$<segment>$<section> (the \1 prefix suppresses
+ // the leading underscore that Mach-O normally adds to C symbols).
+ std::string MachOSection = "__LLVM,offload_entries";
+ std::string StartName, StopName;
+ if (Triple.isOSBinFormatMachO()) {
+ StartName = "\1section$start$__LLVM$offload_entries";
+ StopName = "\1section$end$__LLVM$offload_entries";
+ } else {
+ StartName = ("__start_" + SectionName).str();
+ StopName = ("__stop_" + SectionName).str();
+ }
+
auto *EntriesB =
new GlobalVariable(M, EntryType, /*isConstant=*/true, Linkage, EntryInit,
- "__start_" + SectionName);
+ StartName);
----------------
pvelesko wrote:
Added helper `getOffloadEntrySection`
https://github.com/llvm/llvm-project/pull/183991
More information about the llvm-commits
mailing list