Skip to content

Commit 29088d9

Browse files
committed
Added new Frontend flag to remove -fmodules-validate-system-headers from clang importer flags
1 parent 464a474 commit 29088d9

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class ClangImporterOptions {
7070

7171
/// If true ignore the swift bridged attribute.
7272
bool DisableSwiftBridgeAttr = false;
73+
74+
/// When set, don't validate module system headers. If a header is modified
75+
/// and this is not set, clang will rebuild the module.
76+
bool DisableModulesValidateSystemHeaders = false;
7377
};
7478

7579
} // end namespace swift

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ def disable_sil_linking : Flag<["-"], "disable-sil-linking">,
227227
def dump_clang_diagnostics : Flag<["-"], "dump-clang-diagnostics">,
228228
HelpText<"Dump Clang diagnostics to stderr">;
229229

230+
def disable_modules_validate_system_headers : Flag<["-"], "disable-modules-validate-system-headers">,
231+
HelpText<"Disable modules validate system headers in the clang importer">;
232+
230233
def emit_verbose_sil : Flag<["-"], "emit-verbose-sil">,
231234
HelpText<"Emit locations during SIL emission">;
232235

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
326326

327327
// Enable modules
328328
"-fmodules",
329-
"-fmodules-validate-system-headers",
330329
"-Werror=non-modular-include-in-framework-module",
331330
// Enable implicit module maps (implied by "-fmodules")
332331
"-fimplicit-module-maps",
@@ -345,6 +344,10 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
345344
SHIMS_INCLUDE_FLAG, searchPathOpts.RuntimeResourcePath,
346345
});
347346

347+
if (!importerOpts.DisableModulesValidateSystemHeaders) {
348+
invocationArgStrs.push_back("-fmodules-validate-system-headers");
349+
}
350+
348351
// Set C language options.
349352
if (triple.isOSDarwin()) {
350353
invocationArgStrs.insert(invocationArgStrs.end(), {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
965965

966966
Opts.DisableSwiftBridgeAttr |= Args.hasArg(OPT_disable_swift_bridge_attr);
967967

968+
Opts.DisableModulesValidateSystemHeaders |= Args.hasArg(OPT_disable_modules_validate_system_headers);
969+
968970
return false;
969971
}
970972

0 commit comments

Comments
 (0)