@@ -483,7 +483,7 @@ SwiftDependencyScanningService::SwiftDependencyScanningService() {
483
483
}
484
484
485
485
bool
486
- swift::dependencies::checkImportNotTautological (const ImportPath::Module modulePath,
486
+ swift::dependencies::checkImportNotTautological (const ImportPath::Module modulePath,
487
487
const SourceLoc importLoc,
488
488
const SourceFile &SF,
489
489
bool isExported) {
@@ -509,6 +509,85 @@ swift::dependencies::checkImportNotTautological(const ImportPath::Module moduleP
509
509
return false ;
510
510
}
511
511
512
+ void
513
+ swift::dependencies::registerCxxInteropLibraries (
514
+ const llvm::Triple &Target,
515
+ StringRef mainModuleName,
516
+ bool hasStaticCxx, bool hasStaticCxxStdlib,
517
+ std::function<void (const LinkLibrary&)> RegistrationCallback) {
518
+ if (Target.isOSDarwin ())
519
+ RegistrationCallback (LinkLibrary (" c++" , LibraryKind::Library));
520
+ else if (Target.isOSLinux ())
521
+ RegistrationCallback (LinkLibrary (" stdc++" , LibraryKind::Library));
522
+
523
+ // Do not try to link Cxx with itself.
524
+ if (mainModuleName != " Cxx" ) {
525
+ RegistrationCallback (LinkLibrary (Target.isOSWindows () && hasStaticCxx
526
+ ? " libswiftCxx"
527
+ : " swiftCxx" ,
528
+ LibraryKind::Library));
529
+ }
530
+
531
+ // Do not try to link CxxStdlib with the C++ standard library, Cxx or
532
+ // itself.
533
+ if (llvm::none_of (llvm::ArrayRef{" Cxx" , " CxxStdlib" , " std" },
534
+ [mainModuleName](StringRef Name) {
535
+ return mainModuleName == Name;
536
+ })) {
537
+ // Only link with CxxStdlib on platforms where the overlay is available.
538
+ switch (Target.getOS ()) {
539
+ case llvm::Triple::Linux:
540
+ if (!Target.isAndroid ())
541
+ RegistrationCallback (LinkLibrary (" swiftCxxStdlib" ,
542
+ LibraryKind::Library));
543
+ break ;
544
+ case llvm::Triple::Win32: {
545
+ RegistrationCallback (
546
+ LinkLibrary (hasStaticCxxStdlib ? " libswiftCxxStdlib" : " swiftCxxStdlib" ,
547
+ LibraryKind::Library));
548
+ break ;
549
+ }
550
+ default :
551
+ if (Target.isOSDarwin ())
552
+ RegistrationCallback (LinkLibrary (" swiftCxxStdlib" ,
553
+ LibraryKind::Library));
554
+ break ;
555
+ }
556
+ }
557
+ }
558
+
559
+ void
560
+ swift::dependencies::registerBackDeployLibraries (
561
+ const IRGenOptions &IRGenOpts,
562
+ std::function<void (const LinkLibrary&)> RegistrationCallback) {
563
+ auto addBackDeployLib = [&](llvm::VersionTuple version,
564
+ StringRef libraryName, bool forceLoad) {
565
+ std::optional<llvm::VersionTuple> compatibilityVersion;
566
+ if (libraryName == " swiftCompatibilityDynamicReplacements" ) {
567
+ compatibilityVersion = IRGenOpts.
568
+ AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion;
569
+ } else if (libraryName == " swiftCompatibilityConcurrency" ) {
570
+ compatibilityVersion =
571
+ IRGenOpts.AutolinkRuntimeCompatibilityConcurrencyLibraryVersion ;
572
+ } else {
573
+ compatibilityVersion = IRGenOpts.
574
+ AutolinkRuntimeCompatibilityLibraryVersion;
575
+ }
576
+
577
+ if (!compatibilityVersion)
578
+ return ;
579
+
580
+ if (*compatibilityVersion > version)
581
+ return ;
582
+
583
+ RegistrationCallback ({libraryName, LibraryKind::Library, forceLoad});
584
+ };
585
+
586
+ #define BACK_DEPLOYMENT_LIB (Version, Filter, LibraryName, ForceLoad ) \
587
+ addBackDeployLib (llvm::VersionTuple Version, LibraryName, ForceLoad);
588
+ #include " swift/Frontend/BackDeploymentLibs.def"
589
+ }
590
+
512
591
void SwiftDependencyTracker::addCommonSearchPathDeps (
513
592
const SearchPathOptions &Opts) {
514
593
// Add SDKSetting file.
0 commit comments