mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[swift][AutoLinkExtract] Don't add autolink hint for frameworks. (#65051)
Default system linkers on non-Darwin platforms do not support the `-framework` argument for framework linking. This change updates autolinking to not emit `-framework` into the .o _swift1_autolink_entries metadata when there is no native linker support. This is related to rdar://106578342.
This commit is contained in:
@@ -1575,8 +1575,7 @@ void AutolinkKind::collectEntriesFromLibraries(
|
||||
llvm::LLVMContext &ctx = IGM.getLLVMContext();
|
||||
|
||||
switch (Value) {
|
||||
case AutolinkKind::LLVMLinkerOptions:
|
||||
case AutolinkKind::SwiftAutoLinkExtract: {
|
||||
case AutolinkKind::LLVMLinkerOptions: {
|
||||
// On platforms that support autolinking, continue to use the metadata.
|
||||
for (LinkLibrary linkLib : AutolinkEntries) {
|
||||
switch (linkLib.getKind()) {
|
||||
@@ -1597,6 +1596,24 @@ void AutolinkKind::collectEntriesFromLibraries(
|
||||
}
|
||||
return;
|
||||
}
|
||||
case AutolinkKind::SwiftAutoLinkExtract: {
|
||||
// On platforms that support autolinking, continue to use the metadata.
|
||||
for (LinkLibrary linkLib : AutolinkEntries) {
|
||||
switch (linkLib.getKind()) {
|
||||
case LibraryKind::Library: {
|
||||
llvm::SmallString<32> opt =
|
||||
getTargetDependentLibraryOption(IGM.Triple, linkLib.getName());
|
||||
Entries.insert(llvm::MDNode::get(ctx, llvm::MDString::get(ctx, opt)));
|
||||
continue;
|
||||
}
|
||||
case LibraryKind::Framework:
|
||||
// Frameworks are not supported with Swift Autolink Extract.
|
||||
continue;
|
||||
}
|
||||
llvm_unreachable("Unhandled LibraryKind in switch.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
case AutolinkKind::LLVMDependentLibraries: {
|
||||
for (LinkLibrary linkLib : AutolinkEntries) {
|
||||
switch (linkLib.getKind()) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
extern int APIFromLinkFramework;
|
||||
@@ -0,0 +1,4 @@
|
||||
framework module Link {
|
||||
umbrella header "Link.h"
|
||||
export *
|
||||
}
|
||||
11
test/AutolinkExtract/import_framework.swift
Normal file
11
test/AutolinkExtract/import_framework.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swiftc_driver -c %s -F %S/Inputs/Frameworks -o %t/import_framework.o
|
||||
// RUN: %target-swift-autolink-extract %t/import_framework.o -o - | %FileCheck --check-prefix CHECK-%target-object-format %s
|
||||
|
||||
// REQUIRES: autolink-extract
|
||||
|
||||
// CHECK-elf-NOT: Link
|
||||
// CHECK-coff-NOT: Link
|
||||
|
||||
import Link
|
||||
_ = Link.APIFromLinkFramework
|
||||
Reference in New Issue
Block a user