Skip to content

[sourcekitd-test] When setting -fmodules-cache-path also set -fmodules #29437

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
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,13 @@ static int handleTestInvocation(TestOptions Opts, TestOptions &InitOpts) {
sourcekitd_object_t Args = sourcekitd_request_array_create(nullptr, 0);
if (!Opts.ModuleCachePath.empty()) {
if (compilerArgsAreClang) {
// We need -fmodules or else the clang argument parsing does not honour
// -fmodules-cache-path. In reality, the swift ClangImporter will always
// enable modules when importing, so this should only impact the
// clang argument parsing. This is needed even if the header doesn't
// use modules, since Swift itself will import its shims module, and
// that needs to honour the -module-cache-path option when testing.
sourcekitd_request_array_set_string(Args, SOURCEKITD_ARRAY_APPEND, "-fmodules");
std::string opt = "-fmodules-cache-path=" + Opts.ModuleCachePath;
sourcekitd_request_array_set_string(Args, SOURCEKITD_ARRAY_APPEND, opt.c_str());
} else {
Expand Down