@@ -503,24 +503,33 @@ swift::dependencies::checkImportNotTautological(const ImportPath::Module moduleP
503503 return false ;
504504}
505505
506- void
507- swift::dependencies::registerCxxInteropLibraries (
508- const llvm::Triple &Target,
509- StringRef mainModuleName,
510- bool hasStaticCxx, bool hasStaticCxxStdlib, CXXStdlibKind cxxStdlibKind,
511- std::function<void (const LinkLibrary&)> RegistrationCallback) {
512- if (cxxStdlibKind == CXXStdlibKind::Libcxx)
513- RegistrationCallback (LinkLibrary (" c++" , LibraryKind::Library));
514- else if (cxxStdlibKind == CXXStdlibKind::Libstdcxx)
515- RegistrationCallback (LinkLibrary (" stdc++" , LibraryKind::Library));
506+ void swift::dependencies::registerCxxInteropLibraries (
507+ const llvm::Triple &Target, StringRef mainModuleName, bool hasStaticCxx,
508+ bool hasStaticCxxStdlib, CXXStdlibKind cxxStdlibKind,
509+ std::function<void (const LinkLibrary &)> RegistrationCallback) {
510+
511+ switch (cxxStdlibKind) {
512+ case CXXStdlibKind::Libcxx:
513+ RegistrationCallback (
514+ LinkLibrary{" c++" , LibraryKind::Library, /* static=*/ false });
515+ break ;
516+ case CXXStdlibKind::Libstdcxx:
517+ RegistrationCallback (
518+ LinkLibrary{" stdc++" , LibraryKind::Library, /* static=*/ false });
519+ break ;
520+ case CXXStdlibKind::Msvcprt:
521+ // FIXME: should we be explicitly linking in msvcprt or will the module do
522+ // so?
523+ break ;
524+ case CXXStdlibKind::Unknown:
525+ // FIXME: we should probably emit a warning or a note here.
526+ break ;
527+ }
516528
517529 // Do not try to link Cxx with itself.
518- if (mainModuleName != CXX_MODULE_NAME) {
519- RegistrationCallback (LinkLibrary (Target.isOSWindows () && hasStaticCxx
520- ? " libswiftCxx"
521- : " swiftCxx" ,
522- LibraryKind::Library));
523- }
530+ if (mainModuleName != CXX_MODULE_NAME)
531+ RegistrationCallback (
532+ LinkLibrary{" swiftCxx" , LibraryKind::Library, hasStaticCxx});
524533
525534 // Do not try to link CxxStdlib with the C++ standard library, Cxx or
526535 // itself.
@@ -529,19 +538,9 @@ swift::dependencies::registerCxxInteropLibraries(
529538 return mainModuleName == Name;
530539 })) {
531540 // Only link with CxxStdlib on platforms where the overlay is available.
532- switch (Target.getOS ()) {
533- case llvm::Triple::Win32: {
534- RegistrationCallback (
535- LinkLibrary (hasStaticCxxStdlib ? " libswiftCxxStdlib" : " swiftCxxStdlib" ,
536- LibraryKind::Library));
537- break ;
538- }
539- default :
540- if (Target.isOSDarwin () || Target.isOSLinux ())
541- RegistrationCallback (LinkLibrary (" swiftCxxStdlib" ,
542- LibraryKind::Library));
543- break ;
544- }
541+ if (Target.isOSDarwin () || Target.isOSLinux () || Target.isOSWindows ())
542+ RegistrationCallback (LinkLibrary{" swiftCxxStdlib" , LibraryKind::Library,
543+ hasStaticCxxStdlib});
545544 }
546545}
547546
@@ -569,7 +568,8 @@ swift::dependencies::registerBackDeployLibraries(
569568 if (*compatibilityVersion > version)
570569 return ;
571570
572- RegistrationCallback ({libraryName, LibraryKind::Library, forceLoad});
571+ RegistrationCallback (
572+ {libraryName, LibraryKind::Library, /* static=*/ true , forceLoad});
573573 };
574574
575575#define BACK_DEPLOYMENT_LIB (Version, Filter, LibraryName, ForceLoad ) \
0 commit comments