Skip to content

[ClangImporter] Consolidate clang invocation creation #70456

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 3 commits into from
Dec 20, 2023

Conversation

cachemeifyoucan
Copy link
Contributor

Update how clang-importer is created from clang arguments by always using cc1 option. This allows simplified logics and unified code whether direct-cc1-module-build is used or not. This also allow implementing a workaround for one of the caching build issue.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

ping

@artemcm
Copy link
Contributor

artemcm commented Dec 18, 2023

@swift-ci Please Test Source Compatibility

@artemcm
Copy link
Contributor

artemcm commented Dec 18, 2023

@swift-ci Test

Re-write and clean up how clang-importer is created from clang
arguments. Previously, it is unclear if `getClangArguments` will return
CC1 args or driver args and the logic is unnecessarily compilicated when
creating clang invocation. Now clang invocation is always created from
cc1 arguments, which can be directly provided via direct-cc1-mode or
converted from driver args.

There is no functional changes in this patch, other than
`-dump-clang-diagnostics` now will always print cc1 args, and also
driver args if that is applicable.
Currently,  `-direct-clang-cc1-module-build` and `-only-use-extra-clang-opts`
have to be passed together for clang importer creation to succeed.
Missing either will result in error. Simplified the swift-frontend flags
by removing `-only-use-extra-clang-opts` and let
`-direct-clang-cc1-module-build` to do both.
When caching + clang include tree is enabled, don't take module map file
from command-line in clang importer. Those are resulted from `-Xcc`
arguments and do not needed in compilation since module maps are
included in include-tree.

rdar://119577349
@cachemeifyoucan
Copy link
Contributor Author

Rebase to resolve merge conflict. @ian-twilightcoder this should fix your test failures that you try to XFAIL.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please smoke test

@ian-twilightcoder
Copy link
Contributor

Rebase to resolve merge conflict. @ian-twilightcoder this should fix your test failures that you try to XFAIL.

Woohoo! Does it also fix test/ModuleInterface/no-implicit-extra-clang-opts.swift in Windows?

getClangArguments(ASTContext &ctx, bool ignoreClangTarget = false);
getClangDriverArguments(ASTContext &ctx, bool ignoreClangTarget = false);

static std::optional<std::vector<std::string>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why static with an importer arg instead of making it an instance method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is called from static create function.

@cachemeifyoucan cachemeifyoucan merged commit a37aa1c into swiftlang:main Dec 20, 2023
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