mattgallagher / CwlPreconditionTesting

A Mach exception handler that allows Swift precondition failures to be caught and tested.
ISC License
175 stars 46 forks source link

Compiler Error with Swift 5.5: symbol 'NDR_record' (NDR_record) is in generated IR file, but not in TBD file #22

Closed theMomax closed 3 years ago

theMomax commented 3 years ago

This package does not compile with the latest Swift 5.5 toolchain on macOS 12. This seems to be a compiler-bug. I created a bug on the Swift bug tracker.

It seems to have something to do with usage of NDR_record in CwlCatchBadInstruction.swift. Refer to the linked bug for more details.

mattgallagher commented 3 years ago

Running Xcode 13 beta 5 on macOS Monterey beta 5, I'm no longer able to reproduce this issue.

iosdevben commented 3 years ago

CwlPreconditionTesting is used by Nimble.

When I try to build Nimble with Carthage (carthage update Nimble --use-xcframeworks --no-use-binaries --platform iOS) on macOS Monterey with Xcode 13 beta 5 I'm seeing the error below.

@mattgallagher, am I holding it wrong?

duplicate symbol '_NDR_record' in:

/Users/ben/Library/Caches/org.carthage.CarthageKit/DerivedData/13.0_13A5212g/Nimble/v9.2.0/Build/Intermediates.noindex/Nimble.build/Release-iphonesimulator/Nimble-iOS.build/Objects-normal/x86_64/CwlDarwinDefinitions.o

/Users/ben/Library/Caches/org.carthage.CarthageKit/DerivedData/13.0_13A5212g/Nimble/v9.2.0/Build/Intermediates.noindex/Nimble.build/Release-iphonesimulator/Nimble-iOS.build/Objects-normal/x86_64/CwlCatchBadInstruction.o ld: 1 duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

mattgallagher commented 3 years ago

@iosdevben Aah, okay, I can reproduce. It's a Release build issue. I'll try to fix.

mattgallagher commented 3 years ago

I've moved the access to NDR_record into Objective-C to hide it from whatever weirdness is affecting Swift 5.5. With a bit of luck, that'll make the issue go away. I've optimistically tagged the new commit 2.0.1.

https://github.com/mattgallagher/CwlPreconditionTesting/commit/0630439888c94657a235ffcd5977d6047ef3c87b

mattgallagher commented 3 years ago

I think this is resolved.