Browse Source

objc: stop generating coalesced sections

When targeting >= Mac OS X 10.6, don't generate coalesced sections anymore
because they are deprecated. Resolves #39818
Jonas Maebe 2 years ago
parent
commit
136022a7b2
1 changed files with 14 additions and 1 deletions
  1. 14 1
      compiler/objcgutl.pas

+ 14 - 1
compiler/objcgutl.pas

@@ -1328,6 +1328,7 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_protocol(list: tasmlist; protocol:
     optclssym     : TAsmLabel;
     optclssym     : TAsmLabel;
     prottype      : tdef;
     prottype      : tdef;
     tcb           : ttai_typedconstbuilder;
     tcb           : ttai_typedconstbuilder;
+    sec           : TAsmSectiontype;
   begin
   begin
     gen_objc_protocol_list(list,protocol.ImplementedInterfaces,protolist);
     gen_objc_protocol_list(list,protocol.ImplementedInterfaces,protolist);
     gen_objc_protocol_elements(list,protocol,reqinstsym,optinstsym,reqclssym,optclssym);
     gen_objc_protocol_elements(list,protocol,reqinstsym,optinstsym,reqclssym,optclssym);
@@ -1367,10 +1368,22 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_protocol(list: tasmlist; protocol:
     { flags }
     { flags }
     tcb.emit_ord_const(0,u32inttype);
     tcb.emit_ord_const(0,u32inttype);
     tcb.maybe_end_aggregate(prottype);
     tcb.maybe_end_aggregate(prottype);
+    { coalesced sections are only required for ld-classic, because it does not
+      support "weak" bits on all symbols. They are deprecated in ld64 starting
+      from 2015: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151012/305992.html
+
+      While targeting 10.6 or higher does not guarantee we are using ld64,
+      we don't have a better heuristic available.
+    }
+    if not MacOSXVersionMin.isvalid or
+       (MacOSXVersionMin.relationto(10,6,0)>=0) then
+      sec:=sec_data
+    else
+      sec:=sec_data_coalesced;
     list.concatList(
     list.concatList(
       tcb.get_final_asmlist(
       tcb.get_final_asmlist(
         lbl,prottype,
         lbl,prottype,
-        sec_data_coalesced,'_OBJC_PROTOCOL',sizeof(pint)
+        sec,'_OBJC_PROTOCOL',sizeof(pint)
       )
       )
     );
     );
     tcb.free;
     tcb.free;