File D50559.diff of Package llvm6

https://bugzilla.opensuse.org/show_bug.cgi?id=1067478

make gnustep-libobjc2 compile reproducibly

ordering of selectors varied with ASLR

Index: lib/CodeGen/CGObjCGNU.cpp
===================================================================
--- lib/CodeGen/CGObjCGNU.cpp.orig
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -2438,12 +2438,16 @@ llvm::Function *CGObjCGNU::ModuleInitFun
     ConstantInitBuilder builder(CGM);
     auto selectors = builder.beginArray(selStructTy);
     auto &table = SelectorTable; // MSVC workaround
-    for (auto &entry : table) {
+    std::vector<Selector> allSelectors;
+    for (auto &entry : table)
+      allSelectors.push_back(entry.first);
+    std::sort(allSelectors.begin(), allSelectors.end());
 
-      std::string selNameStr = entry.first.getAsString();
+    for (auto &untypedSel : allSelectors) {
+      std::string selNameStr = untypedSel.getAsString();
       llvm::Constant *selName = ExportUniqueString(selNameStr, ".objc_sel_name");
 
-      for (TypedSelector &sel : entry.second) {
+      for (TypedSelector &sel : table[untypedSel]) {
         llvm::Constant *selectorTypeEncoding = NULLPtr;
         if (!sel.first.empty())
           selectorTypeEncoding =