[BrdigingHeader] Auto bridging header chaining

Add ability to automatically chaining the bridging headers discovered from all
dependencies module when doing swift caching build. This will eliminate all
implicit bridging header imports from the build and make the bridging header
importing behavior much more reliable, while keep the compatibility at maximum.

For example, if the current module A depends on module B and C, and both B and
C are binary modules that uses bridging header, when building module A,
dependency scanner will construct a new header that chains three bridging
headers together with the option to build a PCH from it. This will make all
importing errors more obvious while improving the performance.
This commit is contained in:
Steven Wu
2025-01-06 15:52:32 -08:00
parent 8534f29ef5
commit 9d59044bb1
44 changed files with 1094 additions and 275 deletions

View File

@@ -1029,7 +1029,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableTargetOSChecking
= A->getOption().matches(OPT_enable_target_os_checking);
}
Opts.EnableNewOperatorLookup = Args.hasFlag(OPT_enable_new_operator_lookup,
OPT_disable_new_operator_lookup,
/*default*/ false);
@@ -1436,7 +1436,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
if (const Arg *A = Args.getLastArg(OPT_clang_target)) {
Opts.ClangTarget = llvm::Triple(A->getValue());
}
Opts.setCxxInteropFromArgs(Args, Diags);
Opts.EnableObjCInterop =
@@ -1486,7 +1486,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
auto getDefaultMinimumInliningTargetVersion =
[&](const llvm::Triple &triple) -> llvm::VersionTuple {
const auto targetVersion = getVersionTuple(triple);
// In API modules, default to the version when Swift first became available.
if (Opts.LibraryLevel == LibraryLevel::API) {
if (auto minVersion = minimumAvailableOSVersionForTriple(triple))
@@ -1973,6 +1973,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
if (auto *A = Args.getLastArg(OPT_import_objc_header))
Opts.BridgingHeader = A->getValue();
if (auto *A = Args.getLastArg(OPT_import_pch))
Opts.BridgingHeaderPCH = A->getValue();
Opts.DisableSwiftBridgeAttr |= Args.hasArg(OPT_disable_swift_bridge_attr);
Opts.DisableOverlayModules |= Args.hasArg(OPT_emit_imported_modules);
@@ -2294,7 +2296,9 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
Opts.ScannerModuleValidation |= Args.hasFlag(OPT_scanner_module_validation,
OPT_no_scanner_module_validation,
CASOpts.EnableCaching);
Opts.BridgingHeaderChaining |=
Args.hasFlag(OPT_auto_bridging_header_chaining,
OPT_no_auto_bridging_header_chaining, false);
bool buildingFromInterface =
FrontendOpts.InputMode ==
FrontendOptions::ParseInputMode::SwiftModuleInterface;
@@ -2993,7 +2997,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
Opts.NoAllocations = Args.hasArg(OPT_no_allocations);
Opts.EnableExperimentalSwiftBasedClosureSpecialization =
Opts.EnableExperimentalSwiftBasedClosureSpecialization =
Args.hasArg(OPT_enable_experimental_swift_based_closure_specialization);
// If these optimizations are enabled never preserve functions for the