fix(codegen,ci): keep stale Apple cross runtimes from breaking iOS/tvOS links (#4856)#4859
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4856 — iOS/tvOS executable links at 0.5.1150 failed with
undefined symbol: _perry_macos_bundle_chdirbecause the release pipeline shipped stale Apple cross runtime archives:Swatinem/rust-cacherestored atarget/whose fingerprints let cargo skip rebuildingperry-runtimeafter #4833 added the symbol.Implements all three fixes suggested in the issue:
1. Codegen: gate the
perry_macos_bundle_chdiremission to macOS targetsentry.rsnow emits the call inmain's prelude only when the target triple is*-apple-macosx*/*-apple-darwin*(newis_macos_triplehelper). 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:andbuild-cross:now delete the workspace crates'.fingerprintentries (host andtarget/<triple>/layouts) right after therust-cacherestore, forcing perry-runtime/stdlib/UI/CLI to rebuild from the checkout every release while keeping the expensive external-dependency precompiles cached. Notecargo clean -pis not sufficient — verified locally that it only covers the host layout and never touchestarget/<triple>/dirs.3. Release CI: post-build symbol guard (defense in depth)
New
scripts/check_runtime_symbols.shasserts 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 plainnmlisting — on the thin-LTO bitcode members that Apple'snmcan't parse (verified locally: Xcode's nm errors withUnknown attribute kindon the rustc-emitted bitcode, but the armap is plain data). Wired into bothbuild:(verifies host + all cross archives the leg built) andbuild-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 testscargo fmt --check, file-size gate,actionlint— no new findings vs baselibperry_runtime.apasses) and negative (synthetic archive without the sentinels fails with::error::), including the system-nm-only fallback path used on CI macsPer maintainer convention, no version bump / changelog in this PR — folded in at merge time.