26
26
27
27
using namespace swift ;
28
28
29
- static LibPrespecializedData<InProcess> *findLibPrespecialized () {
29
+ static const LibPrespecializedData<InProcess> *findLibPrespecialized () {
30
30
if (!runtime::environment::SWIFT_DEBUG_ENABLE_LIB_PRESPECIALIZED ())
31
31
return nullptr ;
32
32
33
- void *dataPtr = nullptr ;
33
+ const void *dataPtr = nullptr ;
34
34
#if USE_DLOPEN
35
35
auto path = runtime::environment::SWIFT_DEBUG_LIB_PRESPECIALIZED_PATH ();
36
36
if (path && path[0 ]) {
@@ -41,29 +41,30 @@ static LibPrespecializedData<InProcess> *findLibPrespecialized() {
41
41
dataPtr = dlsym (handle, LIB_PRESPECIALIZED_TOP_LEVEL_SYMBOL_NAME);
42
42
}
43
43
#if DYLD_GET_SWIFT_PRESPECIALIZED_DATA_DEFINED
44
- else {
44
+ else if ( SWIFT_RUNTIME_WEAK_CHECK (_dyld_get_swift_prespecialized_data)) {
45
45
// Disable the prespecializations library if anything in the shared cache is
46
46
// overridden. Eventually we want to be cleverer and only disable the
47
47
// prespecializations that have been invalidated, but we'll start with the
48
48
// simplest approach.
49
49
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 () );
51
51
}
52
52
#endif
53
53
#endif
54
54
55
55
if (!dataPtr)
56
56
return nullptr ;
57
57
58
- auto *data = reinterpret_cast <LibPrespecializedData<InProcess> *>(dataPtr);
58
+ auto *data =
59
+ reinterpret_cast <const LibPrespecializedData<InProcess> *>(dataPtr);
59
60
if (data->majorVersion !=
60
61
LibPrespecializedData<InProcess>::currentMajorVersion)
61
62
return nullptr ;
62
63
63
64
return data;
64
65
}
65
66
66
- LibPrespecializedData<InProcess> *swift::getLibPrespecializedData () {
67
+ const LibPrespecializedData<InProcess> *swift::getLibPrespecializedData () {
67
68
return SWIFT_LAZY_CONSTANT (findLibPrespecialized ());
68
69
}
69
70
0 commit comments