Skip to content

Commit ba6bed1

Browse files
authored
Merge pull request #64633 from al45tair/gwynne/patch-2-5.9
[Linux] (Cherry Pick) Merge pull request #64312 from gwynne/patch-2
2 parents 461fe0a + a4cae45 commit ba6bed1

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

lib/DriverTool/autolink_extract_main.cpp

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,50 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
243243
std::vector<std::string> LinkerFlags;
244244

245245
// Keep track of whether we've already added the common
246-
// Swift libraries that ususally have autolink directives
247-
// in most object fiels
248-
std::unordered_map<std::string, bool> SwiftRuntimeLibraries = {
249-
{"-lswiftSwiftOnoneSupport", false},
250-
{"-lswiftCore", false},
251-
{"-lswift_Concurrency", false},
252-
{"-lswift_StringProcessing", false},
253-
{"-lswift_RegexParser", false},
254-
{"-lswift_Backtracing", false},
246+
// Swift libraries that usually have autolink directives
247+
// in most object files
248+
249+
std::vector<std::string> SwiftRuntimeLibsOrdered = {
250+
// Common Swift runtime libs
251+
"-lswiftSwiftOnoneSupport",
252+
"-lswiftCore",
253+
"-lswift_Concurrency",
254+
"-lswift_StringProcessing",
255+
"-lswift_RegexBuilder",
256+
"-lswift_RegexParser",
257+
"-lswift_Backtracing",
258+
"-lswiftGlibc",
259+
"-lBlocksRuntime",
260+
// Dispatch-specific Swift runtime libs
261+
"-ldispatch",
262+
"-lDispatchStubs",
263+
"-lswiftDispatch",
264+
// CoreFoundation and Foundation Swift runtime libs
265+
"-lCoreFoundation",
266+
"-lFoundation",
267+
"-lFoundationNetworking",
268+
"-lFoundationXML",
269+
// Foundation support libs
270+
"-lcurl",
271+
"-lxml2",
272+
"-luuid",
273+
// XCTest runtime libs (must be first due to http://github.com/apple/swift-corelibs-xctest/issues/432)
274+
"-lXCTest",
275+
// ICU Swift runtime libs
276+
"-licui18nswift",
277+
"-licuucswift",
278+
"-licudataswift",
279+
// Common-use ordering-agnostic Linux system libs
280+
"-lm",
281+
"-lpthread",
282+
"-lutil",
283+
"-ldl",
284+
"-lz",
255285
};
286+
std::unordered_map<std::string, bool> SwiftRuntimeLibraries;
287+
for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
288+
SwiftRuntimeLibraries[RuntimeLib] = false;
289+
}
256290

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

292-
for (const auto &RuntimeLib : SwiftRuntimeLibraries) {
293-
if (RuntimeLib.second)
294-
OutOS << RuntimeLib.first << '\n';
326+
for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
327+
auto entry = SwiftRuntimeLibraries.find(RuntimeLib);
328+
if (entry != SwiftRuntimeLibraries.end() && entry->second) {
329+
OutOS << entry->first << '\n';
330+
}
295331
}
296332

297333

0 commit comments

Comments
 (0)