Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include toolchain's standard library path in the CLI binary #282

Open
juyan opened this issue Jan 26, 2022 · 2 comments
Open

Include toolchain's standard library path in the CLI binary #282

juyan opened this issue Jan 26, 2022 · 2 comments
Labels
enhancement Feature request or improvement

Comments

@juyan
Copy link
Contributor

juyan commented Jan 26, 2022

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.

@juyan juyan added the enhancement Feature request or improvement label Jan 26, 2022
@andrewchang-bird
Copy link
Contributor

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.

@juyan
Copy link
Contributor Author

juyan commented Feb 10, 2022

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improvement
Projects
None yet
Development

No branches or pull requests

2 participants