Skip to content

Fix sourcekitd interface generation crashing for modules that only have a .swiftinterface file #22514

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

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Feb 11, 2019

[ParseableInterface][sourcekitd] Set the DetailPreprocessor ClangImporter option on the sub invocation if it's set on the parent

In addition to capturing more detailed preprocessor info, the DetailedPreprocessorRecord option sets the clang module format to 'raw' rather than the default 'object'. Sourcekitd doesn't link the code generation libs, which it looks like the default 'object' format requires, so it sets this option to true. The subinvocation generated when loading a module from a .swiftinterface file still used the default prior to this change though, so it would end up crashing sourcekitd.

This change sets the DetailedProccessorRecord option if the DetailedRecord option is set on the preprocessor options of parent context's clang module loader. This fixes interface generation crashing for modules that only have a .swiftinterface file.

@nathawes
Copy link
Contributor Author

@swift-ci please smoke test

@jrose-apple
Copy link
Contributor

Hrm. This seems like a bad idea for pure compile times—now we're going to compile Clang modules twice.

@jrose-apple
Copy link
Contributor

Maybe forwarding on DetailedPreprocessingRecord is closer to the original intent anyway?

@akyrtzi
Copy link
Contributor

akyrtzi commented Feb 11, 2019

@adrian-prantl could you verify that it is actually useful for the swift compiler to build clang modules with 'object' format ?

@adrian-prantl
Copy link
Contributor

Yes, LLDB is using the DWARF debug info for the Clang types in the pcms to display Swift variables with Clang-backed types as Clang types when a .swiftmodule containing the Swift renditions of those types couldn't be found or loaded (e.g., because Swift and LLDB are out of sync or there is an irreconsilable option conflict).

@adrian-prantl
Copy link
Contributor

…langImporter option on the sub invocation if it's set on the parent

In addition to capturing more detailed preprocessor info, the
DetailedPreprocessorRecord option sets the clang module format to 'raw'
rather than the default 'object'. Sourcekitd doesn't link the code
generation libs, which it looks like the default 'object' format requires,
so it sets this option to true. The subinvocation generated when loading a
module from a .swiftinterface file still used the default prior to this
change though, so it would end up crashing sourcekitd.

This change sets the DetailedProccessorRecord option if the DetailedRecord
option is set on the preprocessor options of parent context's clang module
loader. This fixes interface generation crashing for modules that only have
a .swiftinterface file.

rdar://problem/43906499
@nathawes nathawes force-pushed the sourcekit-support-for-parseable-interfaces-pt-2 branch from 7f1d63c to d164c61 Compare February 13, 2019 22:18
@nathawes
Copy link
Contributor Author

@jrose-apple I updated the patch to not split the options and set the flag on the sub-invocation's clang importer options if it looks like it was set for the parent context. Does this seem ok?

@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7f1d63cae5b3601e98c0dd77b054a94ffd76f257

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7f1d63cae5b3601e98c0dd77b054a94ffd76f257

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that we're reaching into the Clang options in something that theoretically should be pure Swift, but I don't really see a better way other than saving that flag off somewhere to begin with. This looks good.

@nathawes nathawes merged commit 2ebd983 into swiftlang:master Feb 14, 2019
@nathawes nathawes deleted the sourcekit-support-for-parseable-interfaces-pt-2 branch February 14, 2019 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants