-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Workaround dyld warning about SwiftSyntax classes #4901
Workaround dyld warning about SwiftSyntax classes #4901
Conversation
Generated by 🚫 Danger |
ab32ccd
to
5de0031
Compare
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 #4782
5de0031
to
fe4e25e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont love this solution but I don’t have any better ideas. Thanks!
I think the other option is to link against Xcode's version, but that obviously has the same downside as the previous internal dylib |
Yeah and I’d rather have this workaround if it means we control the version of SwiftSyntax we ship with. |
Doesn't seem to apply to tests: $ bazel test --test_output=streamed //Tests:GeneratedTests
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Analyzed target //Tests:GeneratedTests (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Test Suite 'All tests' started at 2023-04-18 13:21:47.833
Test Suite 'GeneratedTests.xctest' started at 2023-04-18 13:21:47.834
Test Suite 'AccessibilityLabelForImageRuleGeneratedTests' started at 2023-04-18 13:21:47.834
Test Case '-[GeneratedTests.AccessibilityLabelForImageRuleGeneratedTests testWithDefaultConfiguration]' started.
objc[25929]: Class _TtC11SwiftSyntax16BumpPtrAllocator is implemented in both /private/var/tmp/_bazel_jsimard/7034bb326caf3934edced22f6f4dd368/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/Tests/GeneratedTests.xctest/Contents/MacOS/GeneratedTests (0x1079759c0) and /Applications/Xcode-14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftSyntax.dylib (0x10a100a10). One of the two will be used. Which one is undefined.
objc[25929]: Class _TtC11SwiftSyntax35IncrementalParseReusedNodeCollector is implemented in both /private/var/tmp/_bazel_jsimard/7034bb326caf3934edced22f6f4dd368/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/Tests/GeneratedTests.xctest/Contents/MacOS/GeneratedTests (0x107975b78) and /Applications/Xcode-14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftSyntax.dylib (0x10a100bc0). One of the two will be used. Which one is undefined.
objc[25929]: Class _TtC11SwiftSyntax26IncrementalParseTransition is implemented in both /private/var/tmp/_bazel_jsimard/7034bb326caf3934edced22f6f4dd368/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/Tests/GeneratedTests.xctest/Contents/MacOS/GeneratedTests (0x107975c10) and /Applications/Xcode-14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftSyntax.dylib (0x10a100c58). One of the two will be used. Which one is undefined.
... |
Unfortunately it looks like the handling is such that only the main binary is consulted for this: My assumption is that in this case the main binary is |
Similar to #4901 but updated with a new warning from Xcode 15 beta 1. Unfortunately this doesn't appear to work, even with this change the warning is still logged. It might have something to do with how long the symbol name is.
Similar to #4901 but updated with a new warning from Xcode 15 beta 1. Increase dupclass max name length from 64 to 128
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 #4782