-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
[ClangImporter] Consolidate clang invocation creation #70456
Conversation
6b8647b
to
5fce646
Compare
@swift-ci please smoke test |
5fce646
to
e9e7577
Compare
@swift-ci please smoke test |
e9e7577
to
65121d2
Compare
@swift-ci please smoke test |
65121d2
to
28ca611
Compare
@swift-ci please smoke test |
ping |
@swift-ci Please Test Source Compatibility |
@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
28ca611
to
9be16a1
Compare
Rebase to resolve merge conflict. @ian-twilightcoder this should fix your test failures that you try to XFAIL. |
@swift-ci please smoke test |
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>> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.