Swift 6.2.4 (Xcode 26.3) Release build crash: 'SILFunction type mismatch' for a C function also declared via @_silgen_name
A Release (-O) app build crashed swift-frontend in MandatorySILLinker with *** DESERIALIZATION FAILURE *** ... SILFunction type mismatch for 'ghostty_surface_clear_selection': '$@convention(c) (Optional<UnsafeMutableRawPointer>) -> Bool' != '$@convention(thin) (UnsafeMutableRawPointer) -> Bool'. The Debug build of the same tree compiled fine. Cause: one Swift package declares the C symbol with @_silgen_name("...") private func f(_ p: ptr_t) -> Bool (a thin Swift function, non-optional pointer). The app target also imports the real C declaration from the header (a C function whose opaque pointer imports as Optional). With cross-module optimization, both SIL functions share one name and the linker refuses the mismatch. Fixes: build Debug; use a newer toolchain; or drop the @_silgen_name redeclaration and call through the C header, or give it a distinct symbol via a C shim. Check Compiling with effective version and the 'While deserializing SIL function' line to find the symbol.