1bdd1243dSDimitry Andric================= 2bdd1243dSDimitry Andricld64 vs LLD-MachO 3bdd1243dSDimitry Andric================= 4bdd1243dSDimitry Andric 5bdd1243dSDimitry AndricThis doc lists all significant deliberate differences in behavior between ld64 6bdd1243dSDimitry Andricand LLD-MachO. 7bdd1243dSDimitry Andric 8bdd1243dSDimitry AndricDead Stripping Duplicate Symbols 9bdd1243dSDimitry Andric******************************** 10bdd1243dSDimitry Andricld64 strips dead code before reporting duplicate symbols. By default, LLD does 11bdd1243dSDimitry Andricthe opposite. ld64's behavior hides ODR violations, so we have chosen not 12bdd1243dSDimitry Andricto follow it. But, to make adoption easy, LLD can mimic this behavior via 13bdd1243dSDimitry Andricthe ``--dead-strip-duplicates`` flag. Usage of this flag is discouraged, and 14bdd1243dSDimitry Andricthis behavior should be fixed in the source. However, for sources that are not 15bdd1243dSDimitry Andricwithin the user's control, this will mitigate users for adoption. 16bdd1243dSDimitry Andric 17bdd1243dSDimitry Andric``-no_deduplicate`` Flag 18bdd1243dSDimitry Andric************************ 19bdd1243dSDimitry Andric- ld64: This turns off ICF (deduplication pass) in the linker. 20bdd1243dSDimitry Andric- LLD: This turns off ICF and string merging in the linker. 21bdd1243dSDimitry Andric 22bdd1243dSDimitry AndricString Alignment 23bdd1243dSDimitry Andric**************** 24bdd1243dSDimitry AndricLLD is `slightly less conservative about aligning cstrings 25bdd1243dSDimitry Andric<https://reviews.llvm.org/D121342>`_, allowing it to pack them more compactly. 26bdd1243dSDimitry AndricThis should not result in any meaningful semantic difference. 27bdd1243dSDimitry Andric 28bdd1243dSDimitry AndricObjC Symbols Treatment 29bdd1243dSDimitry Andric********************** 30bdd1243dSDimitry AndricThere are differences in how LLD and ld64 handle ObjC symbols loaded from 31bdd1243dSDimitry Andricarchives. 32bdd1243dSDimitry Andric 33bdd1243dSDimitry Andric- ld64: 34bdd1243dSDimitry Andric 1. Duplicate ObjC symbols from the same archives will not raise an error. 35bdd1243dSDimitry Andric ld64 will pick the first one. 36bdd1243dSDimitry Andric 2. Duplicate ObjC symbols from different archives will raise a "duplicate 37bdd1243dSDimitry Andric symbol" error. 38bdd1243dSDimitry Andric- LLD: Duplicate symbols, regardless of which archives they are from, will 39bdd1243dSDimitry Andric raise errors. 40bdd1243dSDimitry Andric 41bdd1243dSDimitry AndricAliases 42bdd1243dSDimitry Andric======= 43bdd1243dSDimitry Andricld64 treats all aliases as strong extern definitions. Having two aliases of the 44bdd1243dSDimitry Andricsame name, or an alias plus a regular extern symbol of the same name, both 45bdd1243dSDimitry Andricresult in duplicate symbol errors. LLD does not check for duplicate aliases; 46bdd1243dSDimitry Andricinstead we perform alias resolution first, and only then do we check for 47bdd1243dSDimitry Andricduplicate symbols. In particular, we will not report a duplicate symbol error if 48bdd1243dSDimitry Andricthe aliased symbols turn out to be weak definitions, but ld64 will. 49bdd1243dSDimitry Andric 50bdd1243dSDimitry Andric``ZERO_AR_DATE`` enabled by default 51bdd1243dSDimitry Andric*********************************** 52bdd1243dSDimitry Andricld64 has a special mode where it sets some stabs modification times to 0 for 53bdd1243dSDimitry Andrichermetic builds, enabled by setting any value for the ``ZERO_AR_DATE`` 54*06c3fb27SDimitry Andricenvironment variable. LLD flips this default to prefer hermetic builds, but 55bdd1243dSDimitry Andricallows disabling this behavior by setting ``ZERO_AR_DATE=0``. Any other value 56bdd1243dSDimitry Andricof ``ZERO_AR_DATE`` will be ignored. 57