Skip to content

[lldb] Prefer triple from module in precise invocations #8941

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

kastiglione
Copy link

@kastiglione kastiglione commented Jul 1, 2024

When using precise compiler invocations, prefer the triple of the dylib/framework (aka image/module), and not the target binary. This is particularly vital for explicitly built modules, where the pcms for the dylib target can differ from the main target. The difference in pcms can cause expression evaluation to fail.

rdar://130284825

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione kastiglione requested a review from adrian-prantl July 1, 2024 23:43
@kastiglione kastiglione marked this pull request as draft July 1, 2024 23:43
@@ -2909,20 +2909,32 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
return exe_module_sp->GetArchitecture().GetTriple();
};

ArchSpec active_arch;

Choose a reason for hiding this comment

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

I think it would be less confusing if we called this module_arch or maybe image_arch (even though module is a very overloaded term).

Copy link
Author

Choose a reason for hiding this comment

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

This is a variable that holds either the module/image arch, and if that's not available, holds the target arch. "Active" meaning, the one we found, in order of preference (module first, target second).

So it's not module_arch, but maybe active_arch is also not right.

Copy link
Author

Choose a reason for hiding this comment

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

I'm going to rename it to preferred_… hopefully you'll agree that's ok.

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione kastiglione requested a review from adrian-prantl July 2, 2024 20:31
@kastiglione kastiglione requested a review from fredriss July 3, 2024 18:42
@fredriss
Copy link

fredriss commented Jul 3, 2024

Should playgrounds just turn off precise compiler invocations rather than threading this as a different dimension in the API?

@kastiglione
Copy link
Author

@fredriss here's the new commit, which disables precise compiler invocation for playgrounds 9ec444b

The tests in TestSwiftPlaygrounds.py expect the semantics that the target's triple is used to evaluate Swift code, not the current module.

@kastiglione
Copy link
Author

Should playgrounds just turn off precise compiler invocations rather than threading this as a different dimension in the API?

@fredriss let me look into that.

@kastiglione
Copy link
Author

kastiglione commented Jul 3, 2024

@fredriss it turns out that the existing SymbolContext parameter itself controls whether a precise compiler invocation is used. I've changed the code to pass nullptr for the symbol context, whenever the expression is run from a playground (or repl). This avoids risks that could come with unprotected temporary mutation of a global (the swift-precise-compiler-invocation setting).

Thoughts?

@kastiglione
Copy link
Author

@swift-ci test

@fredriss
Copy link

fredriss commented Jul 3, 2024

LGTM

@kastiglione kastiglione marked this pull request as ready for review July 3, 2024 21:30
@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

The linux test failures need investigation.

@kastiglione
Copy link
Author

@swift-ci test linux

1 similar comment
@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test linux

1 similar comment
@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

@swift-ci test linux

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

@swift-ci test windows

@kastiglione
Copy link
Author

@fredriss the issues with playgrounds and linux have been resolved, this is ready to be squashed & merged.

@kastiglione kastiglione requested a review from fredriss July 9, 2024 19:45
@fredriss fredriss merged commit 450d470 into swift/release/6.0 Jul 9, 2024
3 checks passed
@kastiglione kastiglione deleted the dl/lldb-Prefer-triple-from-module-in-precise-invocations branch July 9, 2024 20:35
kastiglione added a commit that referenced this pull request Jul 10, 2024
(cherry-picked from PR #8941)

(cherry-picked from commit eed7d856bfb88baaa07addfe1664e4c7934ed4d6)
kastiglione added a commit that referenced this pull request Jul 10, 2024
(cherry-picked from PR #8941)

(cherry-picked from commit eed7d856bfb88baaa07addfe1664e4c7934ed4d6)
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.

3 participants