|
1 | | -//! Runtime version checking ABI for other compilers. |
| 1 | +//! # Runtime version checking ABI for other compilers. |
2 | 2 | //! |
3 | 3 | //! The symbols in this file are useful for us to expose to allow linking code written in the |
4 | 4 | //! following languages when using their version checking functionality: |
5 | | -//! - Objective-C's `@available`. |
6 | 5 | //! - Clang's `__builtin_available` macro. |
| 6 | +//! - Objective-C's `@available`. |
7 | 7 | //! - Swift's `#available`, |
8 | 8 | //! |
| 9 | +//! Without Rust exposing these symbols, the user would encounter a linker error when linking to |
| 10 | +//! C/Objective-C/Swift libraries using these features. |
| 11 | +//! |
| 12 | +//! The presence of these are mostly considered a quality-of-implementation detail, and should not |
| 13 | +//! be relied upon to be available. |
| 14 | +//! |
| 15 | +//! ## Background |
| 16 | +//! |
9 | 17 | //! The original discussion of this feature can be found at: |
10 | 18 | //! - <https://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html> |
11 | 19 | //! - <https://reviews.llvm.org/D27827> |
12 | 20 | //! - <https://reviews.llvm.org/D30136> |
13 | 21 | //! |
14 | | -//! The implementation of these is a bit weird, since they're actually implemented in `compiler-rt`: |
| 22 | +//! And the upstream implementation of these can be found in `compiler-rt`: |
15 | 23 | //! <https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/compiler-rt/lib/builtins/os_version_check.c> |
16 | 24 | //! |
17 | | -//! While they probably should've been part of `libSystem.dylib`, both because they link to symbols |
18 | | -//! from that, and because their implementation is quite complex, using allocation, environment |
19 | | -//! variables, file access and dynamic library loading (and emitting all of this into every binary). |
| 25 | +//! Ideally, these symbols should probably have been a part of Apple's `libSystem.dylib`, both |
| 26 | +//! because their implementation is quite complex, using allocation, environment variables, file |
| 27 | +//! access and dynamic library loading (and emitting all of this into every binary). |
20 | 28 | //! |
21 | 29 | //! The reason why Apple chose to not do that originally is lost to the sands of time, but a good |
22 | 30 | //! reason would be that implementing it as part of `compiler-rt` allowed them to back-deploy this |
|
27 | 35 | //! in `std` makes sense, since then we can implement it using `std` utilities, and we can avoid |
28 | 36 | //! having `compiler-builtins` depend on `libSystem.dylib`. |
29 | 37 | //! |
30 | | -//! This does mean that users that attempt to link Objective-C code _and_ use `#![no_std]` in all |
31 | | -//! their crates may get a linker error because these symbols are missing. Using `no_std` is quite |
32 | | -//! uncommon on Apple systems though, so it's probably fine to not support this use-case. |
| 38 | +//! This does mean that users that attempt to link C/Objective-C/Swift code _and_ use `#![no_std]` |
| 39 | +//! in all their crates may get a linker error because these symbols are missing. Using `no_std` is |
| 40 | +//! quite uncommon on Apple systems though, so it's probably fine to not support this use-case. |
33 | 41 | //! |
34 | 42 | //! The workaround would be to link `libclang_rt.osx.a` or otherwise use Clang's `compiler-rt`. |
35 | 43 | //! |
36 | 44 | //! See also discussion in <https://github.com/rust-lang/compiler-builtins/pull/794>. |
37 | 45 | //! |
38 | | -//! --- |
| 46 | +//! ## Implementation details |
39 | 47 | //! |
40 | 48 | //! NOTE: Since macOS 10.15, `libSystem.dylib` _has_ actually provided the undocumented |
41 | 49 | //! `_availability_version_check` via `libxpc` for doing the version lookup (zippered, which is why |
|
0 commit comments