Do not set an ELF cold-section name on Mach-O targets - #26
Conversation
markColdFixup() names the FP fixup helpers ".text.unlikely.<fn>" 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.
|
Verified on Apple Silicon from a completely clean tree — no local workaround anywhere. Provenance first, because the previous session on that machine had a hand-applied hack and it mattered to rule it out: that hack was never in a git checkout. It lived in Generation now completes on two titles, 9,967 chunks, zero errors:
No occurrences of Performance from the clean build matches the patched build, so the fix costs nothing: Luigi's Mansion Two caveats worth recording rather than hiding:
|
Summary
Fixes #25 — the LLVM backend cannot emit a module on macOS.
markColdFixup()insrc/backend/llvm/fp_fixups.cppnames the FP fixup helpers".text.unlikely.<fn>"unconditionally. Mach-O section specifiers must be"__SEGMENT,__section", and its writer rejects anything else outright, so on Darwin targets emission aborts:Building Luigi's Mansion (GLME01) for
aarch64-apple-darwindied at chunk 57 of 4164.The change
Skip only the section name, and only on Mach-O. ELF and COFF both accept it and keep it, so x86-64 Windows and Linux codegen are byte-for-byte unchanged.
Attribute::ColdandAttribute::NoInlinestill apply everywhere, so the placement hint itself is not lost — only the ELF-shaped name that Mach-O cannot parse.Verification
foyer.sav, uncapped, interleaved blocks with a discarded warm run per arm: LLVM median 81.2 fps vs 79.1 for the C backend on the same host, no freeze, end frames advancing normally every run.One related observation while setting the macOS side up, not addressed here: at this commit the C backend emits calls to
ppc_fp_available_inline, which does not exist in the ModernGekko GXRuntime we build against (GXRuntime/include/core/cpu.hdeclares onlyppc_fp_available), so a same-commit C module could not be built on that checkout for comparison.