Skip to content

Commit f2bc62b

Browse files
compnerdrokhinip
authored andcommitted
DispatchStubs: make more Windows friendly
Provide an alias for the import symbol as the ObjC runtime is normally in a separate DLL and the compiler will annotate the function as being DLLImport. This allows us to resolve the symbols when building the SDK overlay. Signed-off-by: Kim Topley <[email protected]>
1 parent e570606 commit f2bc62b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/swift/DispatchStubs.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ extern "C" void * objc_retainAutoreleasedReturnValue(void *obj);
6767
// eventually call swift_release to balance the retain below. This is a
6868
// workaround until the compiler no longer emits this callout on non-ObjC
6969
// platforms.
70-
extern "C" void swift_retain(void *);
70+
extern "C"
71+
#if defined(_WIN32)
72+
__declspec(dllimport)
73+
#endif
74+
void swift_retain(void *);
7175

7276
DISPATCH_RUNTIME_STDLIB_INTERFACE
7377
extern "C" void * objc_retainAutoreleasedReturnValue(void *obj) {
@@ -78,4 +82,9 @@ extern "C" void * objc_retainAutoreleasedReturnValue(void *obj) {
7882
else return NULL;
7983
}
8084

85+
#if defined(_WIN32)
86+
extern "C" void *(*__imp_objc_retainAutoreleasedReturnValue)(void *) =
87+
&objc_retainAutoreleasedReturnValue;
88+
#endif
89+
8190
#endif // !USE_OBJC

0 commit comments

Comments
 (0)