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-3773] Class definition not included when running -emit-sil #46358
Comments
Try adding the -primary-file flag. I believe this behavior might be intentional. |
FWIW, adding |
Maybe @jckarter has some ideas. |
I haven't touched the SIL printer in a while. It was never particularly thorough about printing needed decls, though. |
Would it be expected, though, for the printer to print the class definition? |
Yeah, printed SIL ought to be parsable, and parsing it requires the declarations it references. |
Emitted SIL files deliberately don't print declarations if there might be more than one file in the project, because we have no way to represent that in a single file. The short-term thing to do might just be to print the declarations from the current file, since we do (?) support a SIL -primary-file input and .swift files for other inputs. Even that's not quite correct for 'private', though, which currently mangles symbol names based on the name of the current file. I'm okay with partial improvements in this area, though. |
Alex noted that -primary-file didn't seem to address the issue in this case. Maybe we could introduce a |
I think you need to not use -primary-file today. |
I just played around with the flags a little more and the class definition is correctly included if you add the |
Comment by David Sweeris (JIRA) Is this still considered a bug? |
Yes. In principle the output of -emit-sil ought to be parsable by passing it back into swiftc as a |
The issue associated with this ticket is resolved for me since the class definitions are printed for the A short summary of what different combinations do right now:
|
-primary-file is a frontend-only flag. Basically 'swift -emit-silgen foo.swift' is equivalent to 'swift -frontend -primary-file -emit-silgen foo.swift'. |
OK, I guess then it boils down to that the class definitions should when the |
Specifically, the class definitions from the current file, I suppose. |
Comment by Bartosz Polaczyk (JIRA) Can you please check PR-14595? |
Comment by Bartosz Polaczyk (JIRA) Merged 14595 |
Environment
swift-DEVELOPMENT-SNAPSHOT-2017-01-27-a
Additional Detail from JIRA
md5: 33a0544be27949ad4e2a8cc6c6d09653
Issue Description:
Running
swiftc -emit-sil
on the following file generates a SIL file that is missing the class definition, i.e. the bit that looks like Swift code without function bodies:The resulting SIL file is:
This can't be parsed using the
-parse-sil
command line flag and fails with a bunch of errors like:Adding the
-frontend
flag to theswiftc
call resolves the issue.The text was updated successfully, but these errors were encountered: