typealiased / mockingbird

A Swifty mocking framework for Swift and Objective-C.

Home Page:https://mockingbirdswift.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include toolchain's standard library path in the CLI binary

juyan opened this issue · comments

New Feature Request Checklist

Overview

The downloaded mockingbird CLI binary doesn't seem to include the toolchain's std library path. Run otool -l mockingbird

....
Load command 34
          cmd LC_RPATH
      cmdsize 32
         path @loader_path (offset 12)
Load command 35
          cmd LC_RPATH
      cmdsize 32
         path @executable_path (offset 12)
Load command 36
          cmd LC_RPATH
      cmdsize 40
         path @executable_path/Libraries (offset 12)
Load command 37
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 8161216
 datasize 49648
Load command 38
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 8210864
 datasize 4776
Load command 39
          cmd LC_RPATH
      cmdsize 40
         path /usr/lib/mockingbird/0.19.2 (offset 12)
Load command 40
          cmd LC_RPATH
      cmdsize 48
         path /var/tmp/lib/mockingbird/0.19.2 (offset 12)
Load command 41
          cmd LC_RPATH
      cmdsize 40
         path /tmp/lib/mockingbird/0.19.2 (offset 12)
Load command 42
      cmd LC_CODE_SIGNATURE
  cmdsize 16
  dataoff 22385920
 datasize 193312

If I build the CLI from source using the following command, Swift will by default include toolchain's library path as rpath

MKB_BUILD_EXECUTABLES=1 swift build -c release

And otool -l mockingbird outputs

...
Load command 35
          cmd LC_RPATH
      cmdsize 112
         path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx (offset 12)

Not sure why did we strip this path during binary release? The benefits of including toolchain's library rpath is that you no longer need to worry about SwiftSyntax dylib as long as you have Xcode installed. This will make installation & distribution of mockingbird CLI much simpler.

We distribute the _InternalSwiftSyntaxParser library with the binary because SwiftSyntax has strict version requirements. For example, SwiftSyntax for Swift 5.4 cannot be load the parser from the Swift 5.5 toolchain or it’ll exit out. More specifically, the Swift syntax node layout isn’t guaranteed to be stable.

@andrewchang-bird Understood. How about considering the idea of distributing Swift version-specific binaries in addition to the existing release model? For example: mockingbird-swift-5.5.zip