Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] [Linux] (Cherry Pick) Merge pull request #64633 from gwynne/patch-2-5.9 #65030

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 48 additions & 11 deletions lib/DriverTool/autolink_extract_main.cpp
Expand Up @@ -243,15 +243,50 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
std::vector<std::string> LinkerFlags;

// Keep track of whether we've already added the common
// Swift libraries that ususally have autolink directives
// in most object fiels
std::unordered_map<std::string, bool> SwiftRuntimeLibraries = {
{"-lswiftSwiftOnoneSupport", false},
{"-lswiftCore", false},
{"-lswift_Concurrency", false},
{"-lswift_StringProcessing", false},
{"-lswift_RegexParser", false}
// Swift libraries that usually have autolink directives
// in most object files

std::vector<std::string> SwiftRuntimeLibsOrdered = {
// Common Swift runtime libs
"-lswiftSwiftOnoneSupport",
"-lswiftCore",
"-lswift_Concurrency",
"-lswift_StringProcessing",
"-lswift_RegexBuilder",
"-lswift_RegexParser",
"-lswift_Backtracing",
"-lswiftGlibc",
"-lBlocksRuntime",
// Dispatch-specific Swift runtime libs
"-ldispatch",
"-lDispatchStubs",
"-lswiftDispatch",
// CoreFoundation and Foundation Swift runtime libs
"-lCoreFoundation",
"-lFoundation",
"-lFoundationNetworking",
"-lFoundationXML",
// Foundation support libs
"-lcurl",
"-lxml2",
"-luuid",
// XCTest runtime libs (must be first due to http://github.com/apple/swift-corelibs-xctest/issues/432)
"-lXCTest",
// ICU Swift runtime libs
"-licui18nswift",
"-licuucswift",
"-licudataswift",
// Common-use ordering-agnostic Linux system libs
"-lm",
"-lpthread",
"-lutil",
"-ldl",
"-lz",
};
std::unordered_map<std::string, bool> SwiftRuntimeLibraries;
for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
SwiftRuntimeLibraries[RuntimeLib] = false;
}

// Extract the linker flags from the objects.
for (const auto &BinaryFileName : Invocation.getInputFilenames()) {
Expand Down Expand Up @@ -288,9 +323,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
OutOS << Flag << '\n';
}

for (const auto &RuntimeLib : SwiftRuntimeLibraries) {
if (RuntimeLib.second)
OutOS << RuntimeLib.first << '\n';
for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
auto entry = SwiftRuntimeLibraries.find(RuntimeLib);
if (entry != SwiftRuntimeLibraries.end() && entry->second) {
OutOS << entry->first << '\n';
}
}


Expand Down