Skip to content

Added new frontend flag to accelerate clang importer #5316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/swift/ClangImporter/ClangImporterOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class ClangImporterOptions {

/// If true ignore the swift bridged attribute.
bool DisableSwiftBridgeAttr = false;

/// When set, don't validate module system headers. If a header is modified
/// and this is not set, clang will rebuild the module.
bool DisableModulesValidateSystemHeaders = false;
};

} // end namespace swift
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ def disable_sil_linking : Flag<["-"], "disable-sil-linking">,
def dump_clang_diagnostics : Flag<["-"], "dump-clang-diagnostics">,
HelpText<"Dump Clang diagnostics to stderr">;

def disable_modules_validate_system_headers : Flag<["-"], "disable-modules-validate-system-headers">,
HelpText<"Disable validating system headers in the Clang importer">;

def emit_verbose_sil : Flag<["-"], "emit-verbose-sil">,
HelpText<"Emit locations during SIL emission">;

Expand Down
5 changes: 4 additions & 1 deletion lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,

// Enable modules
"-fmodules",
"-fmodules-validate-system-headers",
"-Werror=non-modular-include-in-framework-module",
// Enable implicit module maps (implied by "-fmodules")
"-fimplicit-module-maps",
Expand Down Expand Up @@ -484,6 +483,10 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
invocationArgStrs.back().append(moduleCachePath);
}

if (!importerOpts.DisableModulesValidateSystemHeaders) {
invocationArgStrs.push_back("-fmodules-validate-system-headers");
}

if (importerOpts.DetailedPreprocessingRecord) {
invocationArgStrs.insert(invocationArgStrs.end(), {
"-Xclang", "-detailed-preprocessing-record",
Expand Down
2 changes: 2 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,

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

Opts.DisableModulesValidateSystemHeaders |= Args.hasArg(OPT_disable_modules_validate_system_headers);

return false;
}

Expand Down