2626
2727using namespace swift ;
2828
29- static LibPrespecializedData<InProcess> *findLibPrespecialized () {
29+ static const LibPrespecializedData<InProcess> *findLibPrespecialized () {
3030 if (!runtime::environment::SWIFT_DEBUG_ENABLE_LIB_PRESPECIALIZED ())
3131 return nullptr ;
3232
33- void *dataPtr = nullptr ;
33+ const void *dataPtr = nullptr ;
3434#if USE_DLOPEN
3535 auto path = runtime::environment::SWIFT_DEBUG_LIB_PRESPECIALIZED_PATH ();
3636 if (path && path[0 ]) {
@@ -41,29 +41,30 @@ static LibPrespecializedData<InProcess> *findLibPrespecialized() {
4141 dataPtr = dlsym (handle, LIB_PRESPECIALIZED_TOP_LEVEL_SYMBOL_NAME);
4242 }
4343#if DYLD_GET_SWIFT_PRESPECIALIZED_DATA_DEFINED
44- else {
44+ else if ( SWIFT_RUNTIME_WEAK_CHECK (_dyld_get_swift_prespecialized_data)) {
4545 // Disable the prespecializations library if anything in the shared cache is
4646 // overridden. Eventually we want to be cleverer and only disable the
4747 // prespecializations that have been invalidated, but we'll start with the
4848 // simplest approach.
4949 if (!dyld_shared_cache_some_image_overridden ())
50- dataPtr = _dyld_get_swift_prespecialized_data ();
50+ dataPtr = SWIFT_RUNTIME_WEAK_USE ( _dyld_get_swift_prespecialized_data () );
5151 }
5252#endif
5353#endif
5454
5555 if (!dataPtr)
5656 return nullptr ;
5757
58- auto *data = reinterpret_cast <LibPrespecializedData<InProcess> *>(dataPtr);
58+ auto *data =
59+ reinterpret_cast <const LibPrespecializedData<InProcess> *>(dataPtr);
5960 if (data->majorVersion !=
6061 LibPrespecializedData<InProcess>::currentMajorVersion)
6162 return nullptr ;
6263
6364 return data;
6465}
6566
66- LibPrespecializedData<InProcess> *swift::getLibPrespecializedData () {
67+ const LibPrespecializedData<InProcess> *swift::getLibPrespecializedData () {
6768 return SWIFT_LAZY_CONSTANT (findLibPrespecialized ());
6869}
6970
0 commit comments