mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fine-grained autolinking control
This change adds the following options to allow for greater control over the compiler's autolinking directive use: - '-disable-autolink-library': equivalent to an existing '-disable-autolink-framework', this option takes a library name as input and ensures the compiler does not produce an autolink directive '-l<library-name>'. - '-disable-autolink-frameworks': a boolean disable flag which turns off insertion of autolinking directives for all imported frameworks (of the type '-framework <framework-name>') - '-disable-all-autolinking': a boolean disable flag which turns off insertion of *any* autolinking directives. Resolves rdar://100859983
This commit is contained in:
@@ -1466,21 +1466,30 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) {
|
||||
|
||||
if (Context.LangOpts.hasFeature(Feature::Embedded))
|
||||
return;
|
||||
|
||||
switch (linkLib.getKind()) {
|
||||
case LibraryKind::Library: {
|
||||
AutolinkEntries.emplace_back(linkLib);
|
||||
break;
|
||||
}
|
||||
case LibraryKind::Framework: {
|
||||
// If we're supposed to disable autolinking of this framework, bail out.
|
||||
auto &frameworks = IRGen.Opts.DisableAutolinkFrameworks;
|
||||
if (std::find(frameworks.begin(), frameworks.end(), linkLib.getName())
|
||||
!= frameworks.end())
|
||||
return;
|
||||
AutolinkEntries.emplace_back(linkLib);
|
||||
break;
|
||||
}
|
||||
|
||||
// '-disable-autolinking' means we will not auto-link
|
||||
// any loaded library at all.
|
||||
if (!IRGen.Opts.DisableAllAutolinking) {
|
||||
switch (linkLib.getKind()) {
|
||||
case LibraryKind::Library: {
|
||||
auto &libraries = IRGen.Opts.DisableAutolinkLibraries;
|
||||
if (llvm::find(libraries, linkLib.getName()) != libraries.end())
|
||||
return;
|
||||
AutolinkEntries.emplace_back(linkLib);
|
||||
break;
|
||||
}
|
||||
case LibraryKind::Framework: {
|
||||
// 'disable-autolink-frameworks' means we will not auto-link
|
||||
// any loaded framework.
|
||||
if (!IRGen.Opts.DisableFrameworkAutolinking) {
|
||||
auto &frameworks = IRGen.Opts.DisableAutolinkFrameworks;
|
||||
if (llvm::find(frameworks, linkLib.getName()) != frameworks.end())
|
||||
return;
|
||||
AutolinkEntries.emplace_back(linkLib);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (linkLib.shouldForceLoad()) {
|
||||
|
||||
Reference in New Issue
Block a user