Skip to content

[Serialization] Always list the bridging header before any imports #17186

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

Merged

Conversation

jrose-apple
Copy link
Contributor

This mirrors how a bridging header is processed when compiling source files: before any of the imports. This is important for LLDB to recreate the source environment as closely as possible to how the compiler does it; in the test case being added involving a non-modular header file, failure to do so resulted in a deserialization cross-reference crash.

Note that Serialization still sorts imports, which normal resolution of imports in source does not do. So we're still not consistent. But this is less important than handling textual includes (bridging headers) before modular imports.

rdar://problem/40471329

@jrose-apple
Copy link
Contributor Author

Thanks to Adrian for heroically coming up with a reduced test case!

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

// #if __clang__
//
// #ifndef AP
// #define AP
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, left some testing code in.

@jrose-apple jrose-apple force-pushed the bridge-over-troubled-imports branch from a06dd61 to 801e323 Compare June 13, 2018 20:56
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a06dd61bca8015c95f3ebd4aecfa8e4188c273bd

Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

Whoa, you fixed it? Awesome!

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a06dd61bca8015c95f3ebd4aecfa8e4188c273bd

This can only happen in one case today: a module imports a bridging
header, but the header on disk has disappeared, and now we need to
fall back to the (often inadequate) version that's stored inside the
swiftmodule file. Even if the module fails to load, the bridging
header has already been imported, and so anything else that happens
might still emit diagnostics and need that text to be alive, which
means we need to keep the buffer alive too.
This mirrors how a bridging header is processed when compiling source
files: before any of the imports. This is important for LLDB to
recreate the source environment as closely as possible to how the
compiler does it; in the test case being added involving a non-modular
header file, failure to do so resulted in a deserialization
cross-reference crash.

Note that Serialization still sorts imports, which normal resolution
of imports in source does not do. So we're still not consistent. But
this is less important than handling textual includes (bridging
headers) before modular imports.

rdar://problem/40471329
@jrose-apple jrose-apple force-pushed the bridge-over-troubled-imports branch from 801e323 to 6dcda93 Compare June 13, 2018 23:20
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 801e323df384c8e157c8a6dcb5499ea0e7727195

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 801e323df384c8e157c8a6dcb5499ea0e7727195

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@DougGregor
Copy link
Member

This looks good to me. I like that it syncs up the behavior with normal compiles, to cope with any textual include weirdness in bridging headers. Thanks!

@jrose-apple jrose-apple merged commit e5cec5f into swiftlang:master Jun 18, 2018
@jrose-apple jrose-apple deleted the bridge-over-troubled-imports branch June 18, 2018 17:42
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Jun 18, 2018
…led-imports

[Serialization] Always list the bridging header before any imports

rdar://problem/40471329
(cherry picked from commit e5cec5f)
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Jun 18, 2018
…led-imports

[Serialization] Always list the bridging header before any imports

rdar://problem/40471329
(cherry picked from commit e5cec5f)
jrose-apple added a commit that referenced this pull request Jun 18, 2018
…ts (#17299)

[Serialization] Always list the bridging header before any imports

rdar://problem/40471329
(cherry picked from commit e5cec5f)
jrose-apple added a commit that referenced this pull request Jun 18, 2018
…ts (#17300)

[Serialization] Always list the bridging header before any imports

rdar://problem/40471329
(cherry picked from commit e5cec5f)
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.

4 participants