Skip to content

[5.1][RemoteMirror] Mark swift_reflection_classIsSwiftMask as a weak import. #24244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ extern "C" {
#endif

SWIFT_REMOTE_MIRROR_LINKAGE
#if !defined(_WIN32)
__attribute__((__weak_import__))
#endif
extern unsigned long long swift_reflection_classIsSwiftMask;

/// Get the metadata version supported by the Remote Mirror library.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "swift/SwiftRemoteMirror/Platform.h"
#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"

#define SWIFT_CLASS_IS_SWIFT_MASK swift_reflection_classIsSwiftMask
extern "C" {
Expand All @@ -22,7 +23,6 @@ unsigned long long swift_reflection_classIsSwiftMask = 2;
#include "swift/Reflection/TypeLowering.h"
#include "swift/Remote/CMemoryReader.h"
#include "swift/Runtime/Unreachable.h"
#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"

using namespace swift;
using namespace swift::reflection;
Expand Down
5 changes: 4 additions & 1 deletion stdlib/tools/swift-reflection-test/swift-reflection-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,10 @@ int main(int argc, char *argv[]) {

const char *BinaryFilename = argv[1];

swift_reflection_classIsSwiftMask = computeClassIsSwiftMask();
// swift_reflection_classIsSwiftMask is weak linked so we can work
// with older Remote Mirror dylibs.
if (&swift_reflection_classIsSwiftMask != NULL)
swift_reflection_classIsSwiftMask = computeClassIsSwiftMask();

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