From 585ddc892263e53d2b966bbf1257878868e924df Mon Sep 17 00:00:00 2001 From: Douglas Whittingham Date: Mon, 24 Aug 2026 01:45:22 -1000 Subject: [PATCH] Do not set an ELF cold-section name on Mach-O targets markColdFixup() names the FP fixup helpers ".text.unlikely." unconditionally. Mach-O section specifiers are "__SEGMENT,__section" and its writer rejects anything else outright, so on Darwin targets module emission aborts: LLVM ERROR: Global variable 'fix_pair_nan_f64' has an invalid section specifier '.text.unlikely.fix_pair_nan_f64': mach-o section specifier requires a segment and section separated by a comma. Building Luigi's Mansion for aarch64-apple-darwin died at chunk 57 of 4164; with the name suppressed on Mach-O all 4164 chunks emit and the module runs clean (foyer.sav, median 81.2 fps against 79.1 for the C backend on the same host). ELF and COFF both accept the name, so they keep it. The Cold and NoInline attributes carry the placement hint on every target regardless, which is why dropping only the name costs nothing. --- src/backend/llvm/fp_fixups.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/llvm/fp_fixups.cpp b/src/backend/llvm/fp_fixups.cpp index 4376667..f8cfc63 100644 --- a/src/backend/llvm/fp_fixups.cpp +++ b/src/backend/llvm/fp_fixups.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "common/types.h" @@ -18,7 +19,13 @@ static void markColdFixup(Function *function) { function->addFnAttr(Attribute::NoInline); function->addFnAttr(Attribute::NoUnwind); function->addFnAttr(Attribute::WillReturn); - function->setSection(".text.unlikely." + function->getName().str()); + // Mach-O section specifiers are "__SEGMENT,__section" and its writer rejects + // anything else outright, so a bare ".text.unlikely.*" name aborts emission on + // Darwin targets ("invalid section specifier"). ELF and COFF both accept the + // name, and the Cold plus NoInline attributes already carry the placement hint + // on every target, so dropping only the name on Mach-O costs nothing. + if (!Triple(function->getParent()->getTargetTriple()).isOSBinFormatMachO()) + function->setSection(".text.unlikely." + function->getName().str()); } Function *getPairNaNFixup(Module &module, Type *pairType) {