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
[SR-10470] Segmentation fault in Swift 5 compiler (MACH_O_TYPE staticlib) #52870
Comments
Comment by Shai Mishali (JIRA) P.S. the `NOT_IN_PLAYGROUND` flag is unrelated, it's something internal: |
I think this is just "you can't import static libraries into the JIT because dlopen doesn't know how to load them". If you use |
Comment by Shai Mishali (JIRA) I'm not knowledgable enough with JIT or swiftc, but this isn't actually using Playground. What the script does is just merge all Swift files into a single Swift file and compile it as a regular Swift script, not a Playground. The segmentation fault is clearly not the expected outcome here 🙂 Even after disabling this failing script, we're failing with what seems to be a known issue in Swift 5 (47598583): > Linking against a static Swift library might create a binary with missing type metadata because the object files that define the metadata inside the static archive are mistakenly considered unused. |
It's not compiling the file; it's interpreting it. That's the difference between |
Comment by Shai Mishali (JIRA) And that's something not possible with a Static Library ? We've never had an issue with Dynamic Libraries here. Thanks for your patience and for understanding to me non-compiler brain 😃 |
A static library is basically a ball of object files that haven't been turned into a proper library yet by the linker, and dlopen (the underlying APIs the interpreter uses to load libraries) only understands linker outputs. In theory the compiler could do some kind of on-the-fly linking I suppose, but no other interpreter or REPL that I know works like that, so it wouldn't be a priority. You're right that a diagnostic would be nice; maybe if the interpreter fails to find a dynamic library it can look for a static one just to tell the developer that it's not supported. |
Comment by Shai Mishali (JIRA) Is there any way to make that pass though? e.g. using swiftc instead of swift and linking the static libraries ? |
I'm not sure what you mean. |
Environment
macOS 10.4.4 (or macOS 10.10 on Travis CI)
Xcode 10.2, Swift 5 compiler
Additional Detail from JIRA
md5: dc85e87a4ac8578d2653604c9563ff15
Issue Description:
In RxSwift's CI, there is a script that validates the Playground swift code is correct.
It does this by building RxSwift with Release configuration and then concatenating all playground pages into a single swift file and trying to build it using the following command.
We tried switching from a dynamic library to a static library by changing `MACH_O_TYPE` from `mh_dylib` to `staticlib`, which works fine for simply building the project, but fails in this specific case, breaking our CI.
When using the above command with a `staticlib` MACH_O_TYPE, here's the error I'm getting:
The easiest way to reproduce this is cloning RxSwift and using the `staticlib` branch, then run `./scripts/validate-playgrounds.sh`: https://github.com/ReactiveX/RxSwift/tree/staticlib
The text was updated successfully, but these errors were encountered: