Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-276

Implement workaround for Swift 5.0 byte alignment cap



    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.1.0
    • Component/s: None
    • Labels:


      As I learned from this forum discussion with some of Swift's developers, Swift 5.0 caps alignment at 16 bytes, and any C types with a larger alignment that may have previously been fully imported will be imported as OpaquePointers instead. This affects libbson types such as bson_t and bson_iter_t.

      Initially, I thought a simple workaround could be using typealiases to conditionally define what pointer type to use based on Swift version, as described in SWIFT-269.

      However, May Hoque pointed out that OpaquePointers cannot be dereferenced, and that being able to deference various libbson types is crucial to the driver.

       Therefore, we will need a more robust workaround. Matt Broadstone suggests finding a way to specify the libbson/libmongoc interfaces ourselves, based on the Swift 4 interfaces XCode generates, that would be used instead of the ones the Swift compiler generates.

      We should figure out how to do this, and ideally complete this work in the near future before people start switching their applications over to Swift 5.


          Issue Links



              • Votes:
                0 Vote for this issue
                11 Start watching this issue


                • Created: