Restore dyld image functions and Mach-O headers on iOS #5606
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
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
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.
:warning: Warning :warning:
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!
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?
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
Yes, this should not be gated, it's available on tvOS, watchOS and visionOS too.
See also a bit of background in https://github.com/rust-lang/libc/pull/5612#pullrequestreview-5426901503.
I think this is correct, modulo the cfg-gating, these symbols are available on the other Apple platforms too.
Reminder, once the PR becomes ready for a review, use @rustbot ready.
This PR hasn't been updated with the request, but is unusually formed anyway - the test is redundant and we don't do changelog entries like that. Closing in favor of https://github.com/rust-lang/libc/pull/5636.
valentynkit
artile
Fixes rust-lang/libc#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.