@@ -469,103 +469,6 @@ void IRGenModule::emitSourceFile(SourceFile &SF) {
469
469
emitGlobalDecl (localDecl);
470
470
for (auto *opaqueDecl : SF.getOpaqueReturnTypeDecls ())
471
471
maybeEmitOpaqueTypeDecl (opaqueDecl);
472
-
473
- SF.collectLinkLibraries ([this ](LinkLibrary linkLib) {
474
- this ->addLinkLibrary (linkLib);
475
- });
476
-
477
- if (ObjCInterop)
478
- this ->addLinkLibrary (LinkLibrary (" objc" , LibraryKind::Library));
479
-
480
- // If C++ interop is enabled, add -lc++ on Darwin and -lstdc++ on linux.
481
- // Also link with C++ bridging utility module (Cxx) and C++ stdlib overlay
482
- // (std) if available.
483
- if (Context.LangOpts .EnableCXXInterop ) {
484
- const llvm::Triple &target = Context.LangOpts .Target ;
485
- if (target.isOSDarwin ())
486
- this ->addLinkLibrary (LinkLibrary (" c++" , LibraryKind::Library));
487
- else if (target.isOSLinux ())
488
- this ->addLinkLibrary (LinkLibrary (" stdc++" , LibraryKind::Library));
489
-
490
- // Do not try to link Cxx with itself.
491
- if (!getSwiftModule ()->getName ().is (" Cxx" )) {
492
- bool isStatic = false ;
493
- if (const auto *M = Context.getModuleByName (" Cxx" ))
494
- isStatic = M->isStaticLibrary ();
495
- this ->addLinkLibrary (LinkLibrary (target.isOSWindows () && isStatic
496
- ? " libswiftCxx"
497
- : " swiftCxx" ,
498
- LibraryKind::Library));
499
- }
500
-
501
- // Do not try to link CxxStdlib with the C++ standard library, Cxx or
502
- // itself.
503
- if (llvm::none_of (llvm::ArrayRef{" Cxx" , " CxxStdlib" , " std" },
504
- [M = getSwiftModule ()->getName ().str ()](StringRef Name) {
505
- return M == Name;
506
- })) {
507
- // Only link with CxxStdlib on platforms where the overlay is available.
508
- switch (target.getOS ()) {
509
- case llvm::Triple::Linux:
510
- if (!target.isAndroid ())
511
- this ->addLinkLibrary (LinkLibrary (" swiftCxxStdlib" ,
512
- LibraryKind::Library));
513
- break ;
514
- case llvm::Triple::Win32: {
515
- bool isStatic = Context.getModuleByName (" CxxStdlib" )->isStaticLibrary ();
516
- this ->addLinkLibrary (
517
- LinkLibrary (isStatic ? " libswiftCxxStdlib" : " swiftCxxStdlib" ,
518
- LibraryKind::Library));
519
- break ;
520
- }
521
- default :
522
- if (target.isOSDarwin ())
523
- this ->addLinkLibrary (LinkLibrary (" swiftCxxStdlib" ,
524
- LibraryKind::Library));
525
- break ;
526
- }
527
- }
528
- }
529
-
530
- // FIXME: It'd be better to have the driver invocation or build system that
531
- // executes the linker introduce these compatibility libraries, since at
532
- // that point we know whether we're building an executable, which is the only
533
- // place where the compatibility libraries take effect. For the benefit of
534
- // build systems that build Swift code, but don't use Swift to drive
535
- // the linker, we can also use autolinking to pull in the compatibility
536
- // libraries. This may however cause the library to get pulled in in
537
- // situations where it isn't useful, such as for dylibs, though this is
538
- // harmless aside from code size.
539
- if (!IRGen.Opts .UseJIT && !Context.LangOpts .hasFeature (Feature::Embedded)) {
540
- auto addBackDeployLib = [&](llvm::VersionTuple version,
541
- StringRef libraryName, bool forceLoad) {
542
- std::optional<llvm::VersionTuple> compatibilityVersion;
543
- if (libraryName == " swiftCompatibilityDynamicReplacements" ) {
544
- compatibilityVersion = IRGen.Opts .
545
- AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion;
546
- } else if (libraryName == " swiftCompatibilityConcurrency" ) {
547
- compatibilityVersion =
548
- IRGen.Opts .AutolinkRuntimeCompatibilityConcurrencyLibraryVersion ;
549
- } else {
550
- compatibilityVersion = IRGen.Opts .
551
- AutolinkRuntimeCompatibilityLibraryVersion;
552
- }
553
-
554
- if (!compatibilityVersion)
555
- return ;
556
-
557
- if (*compatibilityVersion > version)
558
- return ;
559
-
560
- this ->addLinkLibrary (LinkLibrary (libraryName,
561
- LibraryKind::Library,
562
- forceLoad));
563
- };
564
-
565
- #define BACK_DEPLOYMENT_LIB (Version, Filter, LibraryName, ForceLoad ) \
566
- addBackDeployLib (llvm::VersionTuple Version, LibraryName, ForceLoad);
567
- #include " swift/Frontend/BackDeploymentLibs.def"
568
- }
569
472
}
570
473
571
474
// / Emit all the top-level code in the synthesized file unit.
0 commit comments