[ScanDependency][canImport] Improve canImport handling in explicit build

Teach dependency scanner to report all the module canImport check result
to swift-frontend, so swift-frontend doesn't need to parse swiftmodule
or parse TBD file to determine the versions. This ensures dependency
scanner and swift-frontend will have the same resolution for all
canImport checks.

This also fixes two related issues:
* Previously, in order to get consistant results between scanner and
  frontend, scanner will request building the module in canImport check
  even it is not imported later. This slightly alters the definition of
  the canImport to only succeed when the module can be found AND be
  built. This also can affect the auto-link in such cases.
* For caching build, the location of the clang module is abstracted away
  so swift-frontend cannot locate the TBD file to resolve
  underlyingVersion.

rdar://128067152
This commit is contained in:
Steven Wu
2024-05-23 11:13:44 -07:00
parent 3b4a3a5578
commit 026fcd24fe
11 changed files with 381 additions and 47 deletions

View File

@@ -25,6 +25,7 @@
#include "swift/Strings.h"
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
@@ -2144,6 +2145,21 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
for (auto *A : Args.filtered(OPT_swift_module_cross_import))
Opts.CrossImportInfo[A->getValue(0)].push_back(A->getValue(1));
for (auto &Name : Args.getAllArgValues(OPT_module_can_import))
Opts.CanImportModuleInfo.push_back({Name, {}, {}});
for (auto *A: Args.filtered(OPT_module_can_import_version)) {
llvm::VersionTuple Version, UnderlyingVersion;
if (Version.tryParse(A->getValue(1)))
Diags.diagnose(SourceLoc(), diag::invalid_can_import_module_version,
A->getValue(1));
if (UnderlyingVersion.tryParse(A->getValue(2)))
Diags.diagnose(SourceLoc(), diag::invalid_can_import_module_version,
A->getValue(2));
Opts.CanImportModuleInfo.push_back(
{A->getValue(0), Version, UnderlyingVersion});
}
Opts.DisableCrossImportOverlaySearch |=
Args.hasArg(OPT_disable_cross_import_overlay_search);