|
17 | 17 | # pragma GCC system_header |
18 | 18 | #endif |
19 | 19 |
|
20 | | -// Libc++ is shipped by various vendors. In particular, it is used as a system |
21 | | -// library on macOS, iOS and other Apple platforms. In order for users to be |
22 | | -// able to compile a binary that is intended to be deployed to an older version |
23 | | -// of a platform, Clang provides availability attributes [1]. These attributes |
24 | | -// can be placed on declarations and are used to describe the life cycle of a |
25 | | -// symbol in the library. |
26 | | -// |
27 | | -// The main goal is to ensure a compile-time error if a symbol that hasn't been |
28 | | -// introduced in a previously released library is used in a program that targets |
29 | | -// that previously released library. Normally, this would be a load-time error |
30 | | -// when one tries to launch the program against the older library. |
31 | | -// |
32 | | -// For example, the filesystem library was introduced in the dylib in LLVM 9. |
33 | | -// On Apple platforms, this corresponds to macOS 10.15. If a user compiles on |
34 | | -// a macOS 10.15 host but targets macOS 10.13 with their program, the compiler |
35 | | -// would normally not complain (because the required declarations are in the |
36 | | -// headers), but the dynamic loader would fail to find the symbols when actually |
37 | | -// trying to launch the program on macOS 10.13. To turn this into a compile-time |
38 | | -// issue instead, declarations are annotated with when they were introduced, and |
39 | | -// the compiler can produce a diagnostic if the program references something that |
40 | | -// isn't available on the deployment target. |
41 | | -// |
42 | | -// This mechanism is general in nature, and any vendor can add their markup to |
43 | | -// the library (see below). Whenever a new feature is added that requires support |
44 | | -// in the shared library, two macros are added below to allow marking the feature |
45 | | -// as unavailable: |
46 | | -// 1. A macro named `_LIBCPP_AVAILABILITY_HAS_<feature>` which must be defined |
47 | | -// to `_LIBCPP_INTRODUCED_IN_<version>` for the appropriate LLVM version. |
48 | | -// 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must be defined to |
49 | | -// `_LIBCPP_INTRODUCED_IN_<version>_MARKUP` for the appropriate LLVM version. |
50 | | -// |
51 | | -// When vendors decide to ship the feature as part of their shared library, they |
52 | | -// can update the `_LIBCPP_INTRODUCED_IN_<version>` macro (and the markup counterpart) |
53 | | -// based on the platform version they shipped that version of LLVM in. The library |
54 | | -// will then use this markup to provide an optimal user experience on these platforms. |
55 | | -// |
56 | | -// Furthermore, many features in the standard library have corresponding |
57 | | -// feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_<feature>` macros |
58 | | -// are checked by the corresponding feature-test macros generated by |
59 | | -// generate_feature_test_macro_components.py to ensure that the library |
60 | | -// doesn't announce a feature as being implemented if it is unavailable on |
61 | | -// the deployment target. |
62 | | -// |
63 | | -// Note that this mechanism is disabled by default in the "upstream" libc++. |
64 | | -// Availability annotations are only meaningful when shipping libc++ inside |
65 | | -// a platform (i.e. as a system library), and so vendors that want them should |
66 | | -// turn those annotations on at CMake configuration time. |
67 | | -// |
68 | | -// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability |
| 20 | +// Documentation for this utility can be found at https://libcxx.llvm.org/DesignDocs/Availability.html |
69 | 21 |
|
70 | 22 | // Availability markup is disabled when building the library, or when a non-Clang |
71 | 23 | // compiler is used because only Clang supports the necessary attributes. |
|
0 commit comments