Skip to content

Implement preliminary support for deserializing cc1 flags in Swift mo… #9088

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
merged 1 commit into from
Aug 12, 2024

Conversation

adrian-prantl
Copy link

@adrian-prantl adrian-prantl commented Aug 10, 2024

…dules.

There is no functional change on all other code paths. Support for cc1 flags isn't complete. Since cc1 flags are not stable it's not feasible to keep a list of all multi-arg flags, for example. It also makes it difficult to correctly identify where working directories and path remappings should applied. For all these reasons, using cc1 flags for anything but a local build with explicit modules and precise compiler invocations isn't supported yet.

rdar://133249595

@adrian-prantl
Copy link
Author

@swift-ci test

…dules.

There is no functional change on all other code paths.  Support for
cc1 flags isn't complete.  Since cc1 flags are not stable it's not
feasible to keep a list of all multi-arg flags, for example. It also
makes it difficult to correctly identify where working directories and
path remappings should applied. For all these reasons, using cc1 flags
for anything but a local build with explicit modules and precise
compiler invocations isn't supported yet.

rdar://133249595
@adrian-prantl
Copy link
Author

@swift-ci test

Copy link

@cachemeifyoucan cachemeifyoucan left a comment

Choose a reason for hiding this comment

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

LGTM

std::vector<std::string> &dest) {
std::vector<std::string> &dest,
bool cc1) {
// FIXME: Support for cc1 flags isn't complete. The uniquing

Choose a reason for hiding this comment

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

The flags from a normal build (that is planned by swift dependency scanner), this cc1 list is absolutely deterministic and have a stable ordering already but probably lldb should not rely on this fact.

What really should happen is for lldb to create a clang::CompilerInvocation and parse the args then it can be systematically collect/modify the flag values. I am ok to leave that for future improvement

Copy link
Author

Choose a reason for hiding this comment

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

What really should happen is for lldb to create a clang::CompilerInvocation and parse the args then it can be systematically collect/modify the flag values. I am ok to leave that for future improvement

That might work, and if it does that would be a better implementation. It's possible that some modifications have to happen before parsing though, because the unmodified arguments wouldn't pass validation.

Choose a reason for hiding this comment

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

Oh, you mean some old cc1 args that are no longer valid for current clang version? That would be tricky (even though we expect a version matching lldb for debugging swift).

Copy link
Author

Choose a reason for hiding this comment

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

That case is hopeless for explicit modules anyway (the pcms would be incompatible), and I wouldn't expect this mode to be used for anything but explicit modules.

Copy link
Author

Choose a reason for hiding this comment

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

That might work, and if it does that would be a better implementation. It's possible that some modifications have to happen before parsing though, because the unmodified arguments wouldn't pass validation.

I was thinking about a hypothetical scenario of the driver complaining if a path doesn't exist (which it probably doesn't do)

@adrian-prantl adrian-prantl merged commit 3751470 into swiftlang:swift/release/6.0 Aug 12, 2024
3 checks passed
// be merged with driver options.
bool fresh_invocation = importer_options.ExtraArgs.empty();
if (fresh_invocation && !ExtraArgs.empty() && ExtraArgs.front() == "-cc1")
importer_options.DirectClangCC1ModuleBuild = true;

Choose a reason for hiding this comment

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

should DirectClangCC1ModuleBuild always be set to try when ExtraArgs.front() == "-cc1"?

in other words, should the mixed mode treat extra args as frontend flags when -cc1 is first?

Copy link
Author

Choose a reason for hiding this comment

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

I think such a case is hopeless anyway. I'm planning to clean this up on the rebranch branch, where I'm going to rip out support for non-precise compiler invocations, which should allow us to simplify all this code quite a bit.

cachemeifyoucan added a commit to cachemeifyoucan/llvm-project that referenced this pull request Aug 20, 2024
Followup to swiftlang#9088, handle the cc1 flag deserialization when swift
caching is enabled. LLDB should ignore all the CAS related options from
embedded flags since LLDB doesn't receive the correct CAS configuration
and should just load the modules from disk directly.

rdar://134090397
cachemeifyoucan added a commit to cachemeifyoucan/llvm-project that referenced this pull request Aug 20, 2024
Followup to swiftlang#9088, handle the cc1 flag deserialization when swift
caching is enabled. LLDB should ignore all the CAS related options from
embedded flags since LLDB doesn't receive the correct CAS configuration
and should just load the modules from disk directly.

rdar://134090397
(cherry picked from commit 1162e50)
cachemeifyoucan added a commit to cachemeifyoucan/llvm-project that referenced this pull request Aug 20, 2024
Followup to swiftlang#9088, handle the cc1 flag deserialization when swift
caching is enabled. LLDB should ignore all the CAS related options from
embedded flags since LLDB doesn't receive the correct CAS configuration
and should just load the modules from disk directly.

rdar://134090397
(cherry picked from commit 1162e50)
cachemeifyoucan added a commit that referenced this pull request Aug 20, 2024
Followup to #9088, handle the cc1 flag deserialization when swift
caching is enabled. LLDB should ignore all the CAS related options from
embedded flags since LLDB doesn't receive the correct CAS configuration
and should just load the modules from disk directly.

rdar://134090397
(cherry picked from commit 1162e50)
cachemeifyoucan added a commit that referenced this pull request Aug 20, 2024
Followup to #9088, handle the cc1 flag deserialization when swift
caching is enabled. LLDB should ignore all the CAS related options from
embedded flags since LLDB doesn't receive the correct CAS configuration
and should just load the modules from disk directly.

rdar://134090397
(cherry picked from commit 1162e50)
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