Skip to content

Commit f8ebc98

Browse files
committed
[sourcekitd-test] When setting -fmodules-cache-path also set -fmodules
When doing header interface generation, we interpret clang command-line arguments in `initInvocationByClangArguments` and attempt to setup a matching Swift compiler invocation. One important argument is the module cache, but clang will only interpret `-fmodules-cache-path` if modules are enabled (typically with `-fmodules`). While the header itself might not need modules, Swift will import its own shims module and during testing this needs to honour lit's provided cache. So we add -fmodules in sourcekitd-test anytime we add -fmodules-cache-path. rdar://58836540
1 parent 7b611fc commit f8ebc98

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,13 @@ static int handleTestInvocation(TestOptions Opts, TestOptions &InitOpts) {
987987
sourcekitd_object_t Args = sourcekitd_request_array_create(nullptr, 0);
988988
if (!Opts.ModuleCachePath.empty()) {
989989
if (compilerArgsAreClang) {
990+
// We need -fmodules or else the clang argument parsing does not honour
991+
// -fmodules-cache-path. In reality, the swift ClangImporter will always
992+
// enable modules when importing, so this should only impact the
993+
// clang argument parsing. This is needed even if the header doesn't
994+
// use modules, since Swift itself will import its shims module, and
995+
// that needs to honour the -module-cache-path option when testing.
996+
sourcekitd_request_array_set_string(Args, SOURCEKITD_ARRAY_APPEND, "-fmodules");
990997
std::string opt = "-fmodules-cache-path=" + Opts.ModuleCachePath;
991998
sourcekitd_request_array_set_string(Args, SOURCEKITD_ARRAY_APPEND, opt.c_str());
992999
} else {

0 commit comments

Comments
 (0)