Skip to content

fix(codegen,ci): keep stale Apple cross runtimes from breaking iOS/tvOS links (#4856)#4859

Merged
proggeramlug merged 1 commit into
mainfrom
fix/4856-stale-apple-cross-runtime
Jun 9, 2026
Merged

fix(codegen,ci): keep stale Apple cross runtimes from breaking iOS/tvOS links (#4856)#4859
proggeramlug merged 1 commit into
mainfrom
fix/4856-stale-apple-cross-runtime

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Fixes #4856 — iOS/tvOS executable links at 0.5.1150 failed with undefined symbol: _perry_macos_bundle_chdir because the release pipeline shipped stale Apple cross runtime archives: Swatinem/rust-cache restored a target/ whose fingerprints let cargo skip rebuilding perry-runtime after #4833 added the symbol.

Implements all three fixes suggested in the issue:

1. Codegen: gate the perry_macos_bundle_chdir emission to macOS targets

entry.rs now emits the call in main's prelude only when the target triple is *-apple-macosx* / *-apple-darwin* (new is_macos_triple helper). The runtime fn is a documented no-op everywhere else, so behavior is unchanged — but iOS/tvOS/visionOS/watchOS/Linux/Android/Windows executables no longer reference a macOS-only symbol, which unblocks Apple-mobile links even against an already-stale runtime. New IR regression test (macos_bundle_chdir_gate.rs) asserts emit-on-macOS / omit-on-10-other-triples.

2. Release CI: bust the workspace portion of the restored cache

Both build: and build-cross: now delete the workspace crates' .fingerprint entries (host and target/<triple>/ layouts) right after the rust-cache restore, forcing perry-runtime/stdlib/UI/CLI to rebuild from the checkout every release while keeping the expensive external-dependency precompiles cached. Note cargo clean -p is not sufficient — verified locally that it only covers the host layout and never touches target/<triple>/ dirs.

3. Release CI: post-build symbol guard (defense in depth)

New scripts/check_runtime_symbols.sh asserts each built runtime archive defines sentinel #[no_mangle] symbols (js_gc_init, perry_macos_bundle_chdir). It reads the archive symbol index (nm --print-armap) with exact-token matching, so it works on Mach-O/ELF/COFF and — unlike a plain nm listing — on the thin-LTO bitcode members that Apple's nm can't parse (verified locally: Xcode's nm errors with Unknown attribute kind on the rustc-emitted bitcode, but the armap is plain data). Wired into both build: (verifies host + all cross archives the leg built) and build-cross: (per-triple). A stale archive now fails the release job instead of shipping.

Validation

  • cargo test --release -p perry-codegen — all 13 suites green, including the 2 new gate tests
  • cargo fmt --check, file-size gate, actionlint — no new findings vs base
  • Symbol guard tested positive (current libperry_runtime.a passes) and negative (synthetic archive without the sentinels fails with ::error::), including the system-nm-only fallback path used on CI macs
  • Hello-world compile + run on macOS host confirms the chdir call is still emitted and resolved there

Per maintainer convention, no version bump / changelog in this PR — folded in at merge time.

…OS links (#4856)

Three layers, per the issue's suggested fixes:

1. codegen: emit the perry_macos_bundle_chdir() call in main's prelude
   only for macOS triples (apple-macosx / apple-darwin). The runtime fn
   is a documented no-op everywhere else, and referencing it from every
   executable made iOS/tvOS links depend on non-macOS runtime archives
   carrying a macOS-only symbol — a stale cross runtime then failed the
   link with 'undefined symbol: _perry_macos_bundle_chdir'. New IR
   regression test covers macOS-emits / non-macOS-omits per triple.

2. release CI: evict workspace-crate fingerprints from the restored
   rust-cache in both the build: and build-cross: jobs. rust-cache's
   workspace cleanup misses target/<triple>/ dirs (and cargo clean -p
   only covers the host layout), so a restored cache could let cargo
   reuse a pre-#4833 libperry_runtime.a — exactly how v0.5.1150 shipped
   stale Apple cross runtime bundles. External dependency precompiles
   (the expensive part of the cache) stay cached.

3. release CI: post-build symbol guard (scripts/check_runtime_symbols.sh)
   asserts every built runtime archive defines sentinel #[no_mangle]
   symbols (js_gc_init, perry_macos_bundle_chdir) by reading the archive
   symbol index — works on Mach-O/ELF/COFF and on thin-LTO bitcode
   members that Apple's nm can't parse. A stale archive now fails the
   release instead of shipping.

Fixes #4856
@proggeramlug proggeramlug merged commit 10d9c97 into main Jun 9, 2026
13 checks passed
@proggeramlug proggeramlug deleted the fix/4856-stale-apple-cross-runtime branch June 9, 2026 21:44
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.

iOS/tvOS executable builds fail at 0.5.1150: undefined symbol _perry_macos_bundle_chdir (stale Apple cross runtime artifacts)

1 participant