forked from typealiased/mockingbird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to bundle dylibs into CLI binary and load at startup
Adding SwiftSyntax to the generator requires the dylib `_InternalSwiftSyntaxParser` which is normally bundled as part of the Xcode toolchain. Due to instability and crashing in SwiftSyntax for Swift 5.1, we are using SwiftSyntax for Swift 5.2 and thus requires the Xcode 11.4 toolchain. See also: realm/SwiftLint#3105 Several potential solutions I reviewed: 1. Only support running with Xcode 11.4 This is unacceptable because we want the CLI to run mostly independently of what Xcode toolchain is currently installed on the machine. 2. Provide the dylib when installing the CLI This is a straightforward option and works out-of-the-box if the dylib is in the same directory as the CLI (due to the order of rpath expansion by dyld). However, now the CLI is no longer easily portable and we'd need to create an installation method for all supported package managers. 3. Embed the dylib into the CLI This incurs a small complexity in the launch process but provides the most streamlined experience for developers. At a high level it involves embedding the dylib into the source and at runtime outputting it into a directory under a custom rpath. Once all dependent dylibs exist, it's not possible to just use runtime loading calls `dlopen` / `dlsym` unless we fork SwiftSyntax to pull the symbols dynamically. It's also not possible to call into dyld APIs to replace the loaded but unbound symbol references after the program has launched (`__dyld_start` has already completed). https://opensource.apple.com/source/dyld The best approach here seems to be to relaunch the current process as a subprocess with the same args and env.
- Loading branch information
1 parent
c609218
commit b778623
Showing
17 changed files
with
594 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.