@@ -243,16 +243,50 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
243
243
std::vector<std::string> LinkerFlags;
244
244
245
245
// 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" ,
255
285
};
286
+ std::unordered_map<std::string, bool > SwiftRuntimeLibraries;
287
+ for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
288
+ SwiftRuntimeLibraries[RuntimeLib] = false ;
289
+ }
256
290
257
291
// Extract the linker flags from the objects.
258
292
for (const auto &BinaryFileName : Invocation.getInputFilenames ()) {
@@ -289,9 +323,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
289
323
OutOS << Flag << ' \n ' ;
290
324
}
291
325
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
+ }
295
331
}
296
332
297
333
0 commit comments