@@ -245,43 +245,48 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
245
245
// Keep track of whether we've already added the common
246
246
// Swift libraries that usually have autolink directives
247
247
// in most object files
248
- std::unordered_map<std::string, bool > SwiftRuntimeLibraries = {
248
+
249
+ std::vector<std::string> SwiftRuntimeLibsOrdered = {
249
250
// XCTest runtime libs (must be first due to http://github.com/apple/swift-corelibs-xctest/issues/432)
250
- { " -lXCTest" , false } ,
251
+ " -lXCTest" ,
251
252
// Common Swift runtime libs
252
- { " -lswiftSwiftOnoneSupport" , false } ,
253
- { " -lswiftCore" , false } ,
254
- { " -lswift_Concurrency" , false } ,
255
- { " -lswift_StringProcessing" , false } ,
256
- { " -lswift_RegexBuilder" , false } ,
257
- { " -lswift_RegexParser" , false } ,
258
- { " -lswift_Backtracing" , false } ,
259
- { " -lswiftGlibc" , false } ,
260
- { " -lBlocksRuntime" , false } ,
253
+ " -lswiftSwiftOnoneSupport" ,
254
+ " -lswiftCore" ,
255
+ " -lswift_Concurrency" ,
256
+ " -lswift_StringProcessing" ,
257
+ " -lswift_RegexBuilder" ,
258
+ " -lswift_RegexParser" ,
259
+ " -lswift_Backtracing" ,
260
+ " -lswiftGlibc" ,
261
+ " -lBlocksRuntime" ,
261
262
// Dispatch-specific Swift runtime libs
262
- { " -ldispatch" , false } ,
263
- { " -lDispatchStubs" , false } ,
264
- { " -lswiftDispatch" , false } ,
263
+ " -ldispatch" ,
264
+ " -lDispatchStubs" ,
265
+ " -lswiftDispatch" ,
265
266
// CoreFoundation and Foundation Swift runtime libs
266
- { " -lCoreFoundation" , false } ,
267
- { " -lFoundation" , false } ,
268
- { " -lFoundationNetworking" , false } ,
269
- { " -lFoundationXML" , false } ,
267
+ " -lCoreFoundation" ,
268
+ " -lFoundation" ,
269
+ " -lFoundationNetworking" ,
270
+ " -lFoundationXML" ,
270
271
// Foundation support libs
271
- { " -lcurl" , false } ,
272
- { " -lxml2" , false } ,
273
- { " -luuid" , false } ,
272
+ " -lcurl" ,
273
+ " -lxml2" ,
274
+ " -luuid" ,
274
275
// ICU Swift runtime libs
275
- { " -licui18nswift" , false } ,
276
- { " -licuucswift" , false } ,
277
- { " -licudataswift" , false } ,
276
+ " -licui18nswift" ,
277
+ " -licuucswift" ,
278
+ " -licudataswift" ,
278
279
// Common-use ordering-agnostic Linux system libs
279
- { " -lm" , false } ,
280
- { " -lpthread" , false } ,
281
- { " -lutil" , false } ,
282
- { " -ldl" , false } ,
283
- { " -lz" , false } ,
280
+ " -lm" ,
281
+ " -lpthread" ,
282
+ " -lutil" ,
283
+ " -ldl" ,
284
+ " -lz" ,
284
285
};
286
+ std::unordered_map<std::string, bool > SwiftRuntimeLibraries;
287
+ for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
288
+ SwiftRuntimeLibraries[RuntimeLib] = false ;
289
+ }
285
290
286
291
// Extract the linker flags from the objects.
287
292
for (const auto &BinaryFileName : Invocation.getInputFilenames ()) {
@@ -318,9 +323,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
318
323
OutOS << Flag << ' \n ' ;
319
324
}
320
325
321
- for (const auto &RuntimeLib : SwiftRuntimeLibraries) {
322
- if (RuntimeLib.second )
323
- 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
+ }
324
331
}
325
332
326
333
0 commit comments