forked from realm/SwiftLint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround dyld warning about SwiftSyntax classes (realm#4901)
This uses a recent but unannounced (also read as private) feature of dyld where it ignores duplicate Objective-C classes when they're in a special format in the binary. https://github.com/apple-oss-distributions/dyld/blob/c8a445f88f9fc1713db34674e79b00e30723e79d/dyld/PrebuiltLoader.cpp#L1660-L1662 I think this is generally safe because hopefully people aren't actually using the SwiftSyntax classes through the Objective-C runtime, but if they are we'd still probably prefer to silence the noise and accept the UB. Fixes realm#4782
- Loading branch information
Showing
5 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifdef __APPLE__ | ||
|
||
#include "objc_dupclass.h" | ||
|
||
OBJC_DUPCLASS(_TtC11SwiftSyntax11SyntaxArena); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax13SyntaxVisitor); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax14SyntaxRewriter); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax16BumpPtrAllocator); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax16SyntaxAnyVisitor); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax18ParsingSyntaxArena); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax23SourceLocationConverter); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax26IncrementalParseTransition); | ||
OBJC_DUPCLASS(_TtC11SwiftSyntax35IncrementalParseReusedNodeCollector); | ||
|
||
#endif // __APPLE__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// https://github.com/keith/objc_dupclass | ||
#include <stdint.h> | ||
|
||
// TODO: This isn't entirely accurate, but I'm not sure how to more accurately determine | ||
#if (defined(__arm64__) || defined(DUPCLASS_FORCE_DATA_CONST)) && !defined(DUPCLASS_FORCE_DATA) | ||
#define SECTION "__DATA_CONST" | ||
#else | ||
#define SECTION "__DATA" | ||
#endif | ||
|
||
// Struct layout from https://github.com/apple-oss-distributions/objc4/blob/8701d5672d3fd3cd817aeb84db1077aafe1a1604/runtime/objc-abi.h#L175-L183 | ||
#define OBJC_DUPCLASS(kclass) \ | ||
__attribute__((used)) __attribute__((visibility("hidden"))) \ | ||
static struct { uint32_t version; uint32_t flags; const char name[64]; } \ | ||
const __duplicate_class_##kclass = { 0, 0, #kclass }; \ | ||
\ | ||
__attribute__((used)) __attribute__((visibility("hidden"))) \ | ||
__attribute__((section (SECTION",__objc_dupclass"))) \ | ||
const void* __set___objc_dupclass_sym___duplicate_class_##kclass = &__duplicate_class_##kclass |