Skip to content

Commit 9de4f60

Browse files
authored
Merge pull request #24216 from mikeash/remote-mirror-weak-link-swift_reflection_classIsSwiftMask
[RemoteMirror] Mark swift_reflection_classIsSwiftMask as a weak import.
2 parents 96ef201 + 8b0ab1c commit 9de4f60

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
extern "C" {
3838
#endif
3939

40-
SWIFT_REMOTE_MIRROR_LINKAGE
40+
SWIFT_REMOTE_MIRROR_LINKAGE __attribute__((__weak_import__))
4141
extern unsigned long long swift_reflection_classIsSwiftMask;
4242

4343
/// Get the metadata version supported by the Remote Mirror library.

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#define SWIFT_CLASS_IS_SWIFT_MASK swift_reflection_classIsSwiftMask
1616
extern "C" {
17-
SWIFT_REMOTE_MIRROR_LINKAGE
17+
SWIFT_REMOTE_MIRROR_LINKAGE __attribute__((__weak_import__))
1818
unsigned long long swift_reflection_classIsSwiftMask = 2;
1919
}
2020

stdlib/tools/swift-reflection-test/swift-reflection-test.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,10 @@ int main(int argc, char *argv[]) {
576576

577577
const char *BinaryFilename = argv[1];
578578

579-
swift_reflection_classIsSwiftMask = computeClassIsSwiftMask();
579+
// swift_reflection_classIsSwiftMask is weak linked so we can work
580+
// with older Remote Mirror dylibs.
581+
if (&swift_reflection_classIsSwiftMask != NULL)
582+
swift_reflection_classIsSwiftMask = computeClassIsSwiftMask();
580583

581584
uint16_t Version = swift_reflection_getSupportedMetadataVersion();
582585
printf("Metadata version: %u\n", Version);

0 commit comments

Comments
 (0)