Skip to content

Restore dyld image functions and Mach-O headers on iOS - #5606

Open
artile wants to merge 2 commits into
rust-lang:libc-0.2from
tao-io:fix/ios-dyld-availability
Open

artile wants to merge 2 commits into
rust-lang:libc-0.2from
tao-io:fix/ios-dyld-availability

Conversation

@artile

@artile artile commented Oct 5, 2026 •

Copy link
Copy Markdown

Fixes #5601. The Xcode26.5 iPhoneSimulator SDK mach-o/dyld.h60-63 marks these4 functions __API_AVAILABLE(macos(10.1),ios(2.0)); mach-o/loader.h defines both header layouts. Restore only these public APIs/types on iOS, preserving macOS support and leaving unsupported mach_vm APIs restricted. Adds compile/signature/layout regression for iOS+macOS. Observed backtrace0.3.76 failed E0425 for all4 functions with libc0.2.190 when building actual iOS app. This branch is based on0.2.190 to permit downstream git pin; no unrelated bindings changes.

@rustbot

rustbot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in an Android module

cc @maurer

Some changes occurred in a solarish module

cc @jclulow, @pfmooney

Some changes occurred in an OpenBSD module

cc @semarie

@artile

artile commented Oct 5, 2026

Copy link
Copy Markdown
Author

Focused Rust1.95.0 checks passed for aarch64-apple-ios-sim and aarch64-apple-ios; macOS apple_dyld integration test passed1/1. Added iOS semver symbol coverage per CONTRIBUTING. @rustbot label stable-nominated

@artile

artile commented Oct 5, 2026

Copy link
Copy Markdown
Author

Retargeted this regression restoration to libc-0.2: it is based on the released0.2.190 API used by consumers. Targeting main(v1.0) produced an unrelated release-branch diff, so this PR intentionally targets the stable branch for a minimal platform restoration. If maintainer policy requires main first, this needs a separately mapped API patch there rather than any0.2->1.0 reversion.

@rustbot

rustbot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • Pull requests are usually filed against the main branch for this repo, but this one is against libc-0.2. Please double check that you specified the right target!

@trypsynth

Copy link
Copy Markdown

Just chiming in to say this fixes a very real bug in the wild 🙂 Renovate's routine lock file update moved Paperback (an ebook reader) to libc 0.2.190, and our iOS build promptly fell over with E0425 on all four _dyld_* functions, by way of backtrace 0.3.76. We're holding libc back for now, so thanks for jumping on this, and here's hoping it makes it into 0.2.191!

Comment thread src/unix/bsd/apple/mod.rs

#[exhaustive] // FIXME(exhaustive): review for 1.0
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]

@valentynkit valentynkit Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any specific reason to keep it gated to macos/ios, instead of making it available on all Apple targets by getting rid of this cfg?

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dyld.h doesn't mark these functions unavailable on tvOS/watchOS, the tvOS, watchOS and visionOS SDKs declare them. It specify __API_AVAILABLE but it looks like it sets the minimum version for the macos, ios, not restricting to these platforms, in case of restrictions __API_UNAVAILABLE is used:
https://github.com/apple-oss-distributions/dyld/blob/dyld-1378/include/mach-o/dyld.h#L166

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should not be gated, it's available on tvOS, watchOS and visionOS too.

@madsmtm madsmtm left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also a bit of background in #5612 (review).

I think this is correct, modulo the cfg-gating, these symbols are available on the other Apple platforms too.

View changes since this review

@rustbot

rustbot commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.2.190: _dyld_image_count and the other dyld image functions are now macOS-only, breaking backtrace on iOS

5 participants