Skip to content

Partially revert 70d2ba016129e54dbb35947d5c44d8ae5f17e47c. #4083

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

adrian-prantl
Copy link

This fixes a regression in framework path discovery. It turns out that
either ClangImporter or other Swift module loaders can discover
additional framework search paths and add them to an existing
CompilerInvocation on the fly. When 70d2ba0 switched to directly
deserializing the compiler invocation it lost those additional
late-discovered framework paths from the module contexts.

rdar://89836973

@adrian-prantl adrian-prantl requested review from kastiglione, JDevlieghere and jimingham and removed request for kastiglione March 16, 2022 23:34
@adrian-prantl
Copy link
Author

I'm still working on a testcase. Evidently, we need one...

@adrian-prantl adrian-prantl force-pushed the 89836973-framework-paths branch from 90bf837 to 89b9ada Compare March 17, 2022 01:27
@adrian-prantl
Copy link
Author

Added a test!
@jimingham FYI, the test seems to be similar to one of the situations you were describing in #4077

@adrian-prantl
Copy link
Author

@swift-ci test

3 similar comments
@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test macOS

2 similar comments
@adrian-prantl
Copy link
Author

@swift-ci test macOS

@adrian-prantl
Copy link
Author

@swift-ci test macOS

Copy link

@jimingham jimingham left a comment

Choose a reason for hiding this comment

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

Interesting. That's a nice twisty example.

You need to explain why the CoreAgentUnitTests is special, that just looks weird.

And I don't think you intend warmup_astcontexts to be used outside the handled_sdk_path test, but that isn't clear from the way you've structured the code.

@@ -2144,7 +2173,26 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
handled_sdk_path = true;
}

auto warmup_astcontexts = [&]() {
Copy link

@jimingham jimingham Mar 17, 2022

Choose a reason for hiding this comment

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

As a standalone routine, this would be an inefficient way to make sure that all the ASTContexts which we know about have been made, since once they have been made, you're spinning up a thread pool and adding a job to it for each module, when the call GetModuleSwiftASTContext which will just return the already made AST context.

The routine isn't a problem in this context, so far as I can tell, because its actual use is gated by handled_sdk_path, and so it only happens for the first module of the first big load where we discover the SDK. But the structure of the code doesn't make that clear.

You could make that clear by moving the definition of warmup_astcontexts into the if (!handled_sdk_path) scope so it can't be misused, or maybe just add a better comment.

You could make warmup_astcontexts cheap by having a GetModuleSwiftASTContext(bool can_build) which you call passing false before starting up the thread pool, so that you only set up the thread pool if there's work to do. But I don't think you intend this as a generally useful routine so that seems overkill.

Copy link
Author

Choose a reason for hiding this comment

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

For context, the warmup code I put back in in this commit is identical to the code I removed a month ago.

Choose a reason for hiding this comment

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

Okay. As long as this only gets run once it's okay. I had to think some to ensure that it wasn't, but since it's a temporary hack not many other people will have to warm up their brain pans over it so that's fine.

@adrian-prantl
Copy link
Author

@swift-ci test

Copy link

@jimingham jimingham left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -2144,7 +2173,26 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
handled_sdk_path = true;
}

auto warmup_astcontexts = [&]() {

Choose a reason for hiding this comment

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

Okay. As long as this only gets run once it's okay. I had to think some to ensure that it wasn't, but since it's a temporary hack not many other people will have to warm up their brain pans over it so that's fine.

This fixes a regression in framework path discovery. It turns out that
either ClangImporter or other Swift module loaders can discover
additional framework search paths and add them to an existing
CompilerInvocation on the fly. When 70d2ba0 switched to directly
deserializing the compiler invocation it lost those additional
late-discovered framework paths from the module contexts.

rdar://89836973
@adrian-prantl adrian-prantl force-pushed the 89836973-framework-paths branch from 7f6714f to cc20c75 Compare March 18, 2022 02:03
@adrian-prantl
Copy link
Author

Forgot to git-add main.swift

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl merged commit 3358d3e into swiftlang:stable/20211026 Mar 18, 2022
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.

2 participants