Skip to content

Fix "Too many personality routines for compact unwind" link error for iOS#154

Merged
ruccho merged 2 commits into
mainfrom
feature/fix_personality
Jul 13, 2026
Merged

Fix "Too many personality routines for compact unwind" link error for iOS#154
ruccho merged 2 commits into
mainfrom
feature/fix_personality

Conversation

@ruccho

@ruccho ruccho commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Background

The previous PR #152 localized the bundled mimalloc in the iOS libunienc_c.a via ld -r -exported_symbols_list _unienc* — i.e. it kept only _unienc* global and made everything else local, including the Rust runtime's exception-handling personality routines.

That over-localizes. When a downstream Xcode project statically links this .a alongside other static libraries, each lib ends up carrying its own local personality routine. The Mach-O compact-unwind format can encode at most 3 personality routines per image, so the extra copies overflow that limit and the link fails:

ld: Too many personality routines for compact unwind to encode. Found routines:

Fix

Localize only mimalloc's own symbols, and leave everything else (the _unienc* FFI entry points and the Rust runtime / personality symbols) global so the linker can coalesce them normally.

  • Switched ld -r from -exported_symbols_list to -unexported_symbols_list, listing just the mimalloc symbol families:
    _mi_*
    __mi_*
    ___mi_*
    _heap_main
    _theap_main
    
    These five globs cover all 432 mimalloc symbols in the current unity-fork build with zero false positives (verified with nm).
  • Renamed apple-exports.txtapple-mimalloc-unexports.txt.

Result after localization (verified on macos-15 / ld-prime):

  • mimalloc: 432 → 0 external (all local; no longer coalesces with Unity's mimalloc)
  • _unienc*: 34 kept global
  • Rust runtime / personality: kept global → coalesced by the linker, so no compact-unwind overflow

@ruccho ruccho requested a review from hkmt-mmy July 13, 2026 02:44
@ruccho ruccho merged commit 7d08620 into main Jul 13, 2026
1 check passed
@ruccho ruccho deleted the feature/fix_personality branch July 13, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants