Skip to content

Commit 7dfe832

Browse files
committed
[Explicit Module Builds] Add 'ClangImporter' setting for explicitly-built modules
This will mean that '-disable-implicit-swift-modules' also automatically implies two things: 1. Clang modules must also be explicit, and the importer's clang instance will get '-fno-implicit-modules' and '-fno-implicit-module-maps' 2. The importer's clang instance will no longer get a '-fmodules-cache-path=', since it is not needed in explicit builds
1 parent 1426980 commit 7dfe832

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

include/swift/Basic/LangOptions.h

+4
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@ namespace swift {
878878
/// and completely bypass the Clang driver.
879879
bool DirectClangCC1ModuleBuild = false;
880880

881+
/// Disable implicitly-built Clang modules because they are explicitly
882+
/// built and provided to the compiler invocation.
883+
bool DisableImplicitClangModules = false;
884+
881885
/// Return a hash code of any components from these options that should
882886
/// contribute to a Swift Bridging PCH hash.
883887
llvm::hash_code getPCHHashComponents() const {

include/swift/Frontend/FrontendOptions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ class FrontendOptions {
322322
/// By default, we include ImplicitObjCHeaderPath directly.
323323
llvm::Optional<std::string> BridgingHeaderDirForPrint;
324324

325-
/// Disable implicitly built Swift modules because they are explicitly
326-
/// built and given to the compiler invocation.
325+
/// Disable implicitly-built Swift modules because they are explicitly
326+
/// built and provided to the compiler invocation.
327327
bool DisableImplicitModules = false;
328328

329329
/// Disable building Swift modules from textual interfaces. This should be

lib/ClangImporter/ClangImporter.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,16 @@ importer::getNormalInvocationArguments(
669669
}
670670

671671
const std::string &moduleCachePath = importerOpts.ModuleCachePath;
672-
if (!moduleCachePath.empty()) {
672+
if (!moduleCachePath.empty() && !importerOpts.DisableImplicitClangModules) {
673673
invocationArgStrs.push_back("-fmodules-cache-path=");
674674
invocationArgStrs.back().append(moduleCachePath);
675675
}
676676

677+
if (importerOpts.DisableImplicitClangModules) {
678+
invocationArgStrs.push_back("-fno-implicit-modules");
679+
invocationArgStrs.push_back("-fno-implicit-module-maps");
680+
}
681+
677682
if (ctx.SearchPathOpts.DisableModulesValidateSystemDependencies) {
678683
invocationArgStrs.push_back("-fno-modules-validate-system-headers");
679684
} else {

lib/Frontend/CompilerInvocation.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,9 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
14601460
Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation);
14611461
}
14621462

1463+
if (FrontendOpts.DisableImplicitModules)
1464+
Opts.DisableImplicitClangModules = true;
1465+
14631466
Opts.ValidateModulesOnce |= Args.hasArg(OPT_validate_clang_modules_once);
14641467
if (auto *A = Args.getLastArg(OPT_clang_build_session_file))
14651468
Opts.BuildSessionFilePath = A->getValue();

0 commit comments

Comments
 (0)