Skip to content

Commit 7ce04dc

Browse files
committed
[Clang Importer] Set IsSystem module flag for Clang input files when precompiling a clang module
This bit is important when we are pre-building system modules to be loaded later in Explicit Module Builds.
1 parent 55c39c1 commit 7ce04dc

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,11 +1624,12 @@ bool ClangImporter::emitPrecompiledModule(StringRef moduleMapPath,
16241624
LangOpts->CurrentModule = LangOpts->ModuleName;
16251625

16261626
auto language = getLanguageFromOptions(LangOpts);
1627-
auto inputFile = clang::FrontendInputFile(
1628-
moduleMapPath, clang::InputKind(
1629-
language, clang::InputKind::ModuleMap, false));
16301627

16311628
auto &FrontendOpts = invocation.getFrontendOpts();
1629+
auto inputFile = clang::FrontendInputFile(
1630+
moduleMapPath, clang::InputKind(
1631+
language, clang::InputKind::ModuleMap, false),
1632+
FrontendOpts.IsSystemModule);
16321633
FrontendOpts.Inputs = {inputFile};
16331634
FrontendOpts.OriginalModuleMap = moduleMapPath.str();
16341635
FrontendOpts.OutputFile = outputPath.str();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Emit the explicit system module.
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-emit-pcm -module-name script -Xcc -Xclang -Xcc -emit-module -Xcc -Xclang -Xcc -fsystem-module -o %t/script.pcm %S/Inputs/custom-modules/module.map
4+
5+
// Verify that the input modulemap if marked [System] in the output of the -dump-pcm action.
6+
// RUN: %swift-dump-pcm %t/script.pcm | %FileCheck %s --check-prefix=CHECK-SYSTEM-INPUT
7+
// CHECK-SYSTEM-INPUT: Input file: {{.*[/\\]}}ClangImporter{{/|\\}}Inputs{{/|\\}}custom-modules{{/|\\}}module.map [System]
8+
import script

0 commit comments

Comments
 (0)