Skip to content

Commit 9be16a1

Browse files
[Caching] Workaround not needed modulemap not found
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
1 parent ea58ef8 commit 9be16a1

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ WARNING(nonmutating_without_mutable_fields,none,
117117
"attribute 'nonmutating' has no effect without any mutable fields", ())
118118

119119
ERROR(module_map_not_found, none, "module map file '%0' not found", (StringRef))
120+
WARNING(module_map_ignored, none, "module map file '%0' will be ignored", (StringRef))
120121

121122
WARNING(libc_not_found, none,
122123
"libc not found for '%0'; C stdlib may be unavailable",

lib/ClangImporter/ClangImporter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,12 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
11331133

11341134
std::vector<std::string> FilteredModuleMapFiles;
11351135
for (auto ModuleMapFile : CI->getFrontendOpts().ModuleMapFiles) {
1136-
if (TempVFS->exists(ModuleMapFile)) {
1136+
if (ctx.ClangImporterOpts.UseClangIncludeTree) {
1137+
// There is no need to add any module map file here. Issue a warning and
1138+
// drop the option.
1139+
importer->Impl.diagnose(SourceLoc(), diag::module_map_ignored,
1140+
ModuleMapFile);
1141+
} else if (TempVFS->exists(ModuleMapFile)) {
11371142
FilteredModuleMapFiles.push_back(ModuleMapFile);
11381143
} else {
11391144
importer->Impl.diagnose(SourceLoc(), diag::module_map_not_found,

test/CAS/cas-explicit-module-map.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110

111111
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Foo.swiftmodule -disable-implicit-swift-modules -module-cache-path %t.module-cache -explicit-swift-module-map-file @%t/map.casid -Rmodule-loading -Xcc -Rmodule-import %s -cache-compile-job -cas-path %t/cas -allow-unstable-cache-key-for-testing 2>&1 | %FileCheck %s
112112

113+
/// Test that if there are non-existing module-map file passed through -Xcc, this still compiles.
114+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Foo.swiftmodule -disable-implicit-swift-modules -module-cache-path %t.module-cache -explicit-swift-module-map-file @%t/map.casid -Rmodule-loading -Xcc -Rmodule-import %s -cache-compile-job -cas-path %t/cas -allow-unstable-cache-key-for-testing -Xcc -fmodule-map-file=%t/do-not-exist.modulemap 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=MODULEMAP-IGNORE
115+
116+
// MODULEMAP-IGNORE: warning: module map file '{{.*}}' will be ignored
117+
113118
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t/Foo.swiftinterface -disable-implicit-swift-modules -module-cache-path %t.module-cache -explicit-swift-module-map-file @%t/map.casid %s -cache-compile-job -cas-path %t/cas -allow-unstable-cache-key-for-testing -swift-version 5 -enable-library-evolution -o %t/Foo.swiftmodule
114119
// RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-output-keys -- \
115120
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t/Foo.swiftinterface -disable-implicit-swift-modules \

0 commit comments

Comments
 (0)