rust-apple.yml / rust-osx.yml: post-link strip breaks the arm64 macOS code signature, so RetroArch is killed loading Rust cores

Open
#2,154 1 comment 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
macos, rust, shell

Research direction

Read the rust-apple.yml and rust-osx.yml templates, especially the arm64 job variables and post-build strip commands. Compare the confirmed STRIP_CORE_LIB: "0" build result with the stripped artifact behavior; the report points to disabling stripping for arm64 macOS as a working fix. Done means the produced arm64 dylib verifies and loads in RetroArch without being killed.

Written by the indexing model from the issue text.

Description

Summary

The two Rust macOS templates strip the core after cargo build:

  • rust-apple.yml, .libretro-rust-apple-base: if [ "$STRIP_CORE_LIB" -eq 1 ]; then $STRIP -S ${CORENAME}_libretro.dylib; fi, with STRIP_CORE_LIB: 1 from .libretro-rust-apple-osx-base
  • rust-osx.yml, .libretro-rust-osx-base: $STRIP --strip-unneeded ... with STRIP_CORE_LIB: 1

For aarch64-apple-darwin, the linker has already ad-hoc signed the dylib (CodeDirectory flags 0x20002, adhoc + linker-signed). The image's strip ($AARCH64_DARWIN_STRIP, the osxcross cctools port running on Linux) rewrites the file and does not re-sign it. On Apple Silicon, macOS kills any process that maps arm64 code whose page hashes do not match its CodeDirectory. So RetroArch is SIGKILLed the moment it loads the core: it freezes and exits, with no error dialog.

Evidence

rustynes_libretro.dylib from nightly/apple/osx/arm64/latest/ (built 2026-10-20 05:14 UTC). We recomputed each 4 KiB page's SHA-256 and compared it with the CodeDirectory in LC_CODE_SIGNATURE:

core pages mismatched signed range ends at the signature
rustynes (rust-apple.yml) 538 101 no (codeLimit 2201840, signature at 2201872)
gambatte (osx-arm64.yml, native Mac runner) 949 0 yes
snes9x (osx-arm64.yml, native Mac runner) 707 0 yes

The x86_64 cores are unaffected: an x86_64 dylib carries no signature and needs none.

Fix options

  1. Don't strip arm64 macOS cores (STRIP_CORE_LIB: 0 for .libretro-rust-osx-arm64-default). This is what RustyNES now does in its own .gitlab-ci.yml (job variables outrank the template). A release profile without debug info gives -S little to remove.
  2. Re-sign after stripping, if the image has a signer: rcodesign sign <dylib> (apple-codesign) or ldid -S <dylib>.
  3. Strip at link time (-Wl,-S / -Wl,-x through RUSTFLAGS), so the linker signs the final bytes.

Any Rust core cross-built for aarch64-apple-darwin from these templates with stripping on is likely affected the same way. iOS/tvOS dylibs are re-signed when they are bundled into the App Store app, so this shows up on macOS through the Online Updater.

Confirmed on the buildbot with option 1: with STRIP_CORE_LIB: "0" on the arm64 job (doublegate/RustyNES#623), libretro's pipeline 125851 produced an arm64 dylib that verifies: 538 pages, 0 mismatched, codeLimit equal to the signature offset, flags 0x20002 (linker-signed). Separately, the pre-fix buildbot core, re-signed ad-hoc and changed in nothing else, loads in RetroArch on an M5 Max running macOS 27.0.1, where the unmodified file got RetroArch killed.

These templates live in libretro-infrastructure/ci-templates on git.libretro.com, whose issue tracker needs an account. This seemed the closest public place to report it. Please move it wherever it belongs.

Dominant language
Shell
Stars
475
Forks
355
Avg merge
1d 15h
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libretro/libretro-super

All issues in libretro/libretro-super

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.