mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Frontend] Add -public-autolink-library option (#35936)
Foundation imports CoreFoundation with `@_implementationOnly`, so CoreFoundation's modulemap won't be read, and the dependent libraries of CoreFoundation will not be automatically linked when using static linking. For example, CoreFoundation depends on libicui18n and it's modulemap has `link "icui18n"` statement. If Foundation imports CoreFoundation with `@_implementationOnly` as a private dependency, the toolchain doesn't have CoreFoundation's modulemap and Foundation's swiftmodule doesn't import CoreFoundation. So the swiftc can't know that libicui18n is required. This new option will add LINK_LIBRARY entry in swiftmodule to specify dependent libraries (in the example case, Foundation's swiftmodule should have LINK_LIBRARY entry of libicui18n) See also: [Autolinking behavior of @_implementationOnly with static linking](https://forums.swift.org/t/autolinking-behavior-of-implementationonly-with-static-linking/44393)
This commit is contained in:
@@ -1759,6 +1759,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
for (const auto &Lib : Args.getAllArgValues(options::OPT_autolink_library))
|
||||
Opts.LinkLibraries.push_back(LinkLibrary(Lib, LibraryKind::Library));
|
||||
|
||||
for (const auto &Lib : Args.getAllArgValues(options::OPT_public_autolink_library)) {
|
||||
Opts.PublicLinkLibraries.push_back(Lib);
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_type_info_dump_filter_EQ)) {
|
||||
StringRef mode(A->getValue());
|
||||
if (mode == "all")
|
||||
|
||||
Reference in New Issue
Block a user