@@ -1459,21 +1459,33 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) {
14591459 // emit it into the IR of debugger expressions.
14601460 if (Context.LangOpts .DebuggerSupport )
14611461 return ;
1462-
1463- switch (linkLib.getKind ()) {
1464- case LibraryKind::Library: {
1465- AutolinkEntries.emplace_back (linkLib);
1466- break ;
1467- }
1468- case LibraryKind::Framework: {
1469- // If we're supposed to disable autolinking of this framework, bail out.
1470- auto &frameworks = IRGen.Opts .DisableAutolinkFrameworks ;
1471- if (std::find (frameworks.begin (), frameworks.end (), linkLib.getName ())
1472- != frameworks.end ())
1473- return ;
1474- AutolinkEntries.emplace_back (linkLib);
1475- break ;
1476- }
1462+
1463+ if (Context.LangOpts .hasFeature (Feature::Embedded))
1464+ return ;
1465+
1466+ // '-disable-autolinking' means we will not auto-link
1467+ // any loaded library at all.
1468+ if (!IRGen.Opts .DisableAllAutolinking ) {
1469+ switch (linkLib.getKind ()) {
1470+ case LibraryKind::Library: {
1471+ auto &libraries = IRGen.Opts .DisableAutolinkLibraries ;
1472+ if (llvm::find (libraries, linkLib.getName ()) != libraries.end ())
1473+ return ;
1474+ AutolinkEntries.emplace_back (linkLib);
1475+ break ;
1476+ }
1477+ case LibraryKind::Framework: {
1478+ // 'disable-autolink-frameworks' means we will not auto-link
1479+ // any loaded framework.
1480+ if (!IRGen.Opts .DisableFrameworkAutolinking ) {
1481+ auto &frameworks = IRGen.Opts .DisableAutolinkFrameworks ;
1482+ if (llvm::find (frameworks, linkLib.getName ()) != frameworks.end ())
1483+ return ;
1484+ AutolinkEntries.emplace_back (linkLib);
1485+ }
1486+ break ;
1487+ }
1488+ }
14771489 }
14781490
14791491 if (linkLib.shouldForceLoad ()) {
0 commit comments