Skip to content

Commit

Permalink
Work around Swift 5.9+ compiler bug that causes some tests to fail on…
Browse files Browse the repository at this point in the history
… Linux.

Resolves #4.
  • Loading branch information
fumoboy007 committed Jun 8, 2024
1 parent ee5ae8d commit c948d14
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/MessagePack/MessageWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public struct MessageWriter: ~Copyable {
// because it needs to perform runtime checks to enforce exclusivity.
private(set) var message = Data()

// Hack: This is a workaround for an issue (https://github.com/fumoboy007/msgpack-swift/issues/4)
// related to Whole Module Optimization in Swift 5.9+. Although the issue only
// appeared on Linux so far, add the workaround for every platform to be safe.
//
// TODO: Remove this workaround after the root cause has been fixed. See
// https://github.com/apple/swift/issues/70979 for more details.
#if swift(>=5.9)
@inline(never)
#endif
public mutating func write(byte: UInt8) {
withUnsafePointer(to: byte) {
message.append($0, count: 1)
Expand Down

0 comments on commit c948d14

Please sign in to comment.