[lld] [lld] Elide __swift_FORCE_LOAD_$ dyld fixups in __DATA, __const (PR #214584)

Richard Howell via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 06:34:39 PDT 2026


rmaz wrote:

> Yes, coalescing across modules is what I meant. The anchors are already `weak_odr` and the `_$_<module>` suffix is the only thing preventing it. A name derived from the referenced symbol alone (a fixed `_ref` suffix) should suffice. But that's just my read of the Swift compiler code, and I'm not sure it's 100% correct - I couldn't find any code comment or commit history clarifying why appending the module name is necessary.

I am also not clear on why we need the per module symbols. There should be coalescing within a module however (Swift module this is, which is comprised of multiple object files).

> Thanks for the pointer. I hadn't realized this mirrors ld64's behavior. Could we reference the ld64 code with a permalink in the commit message or a code comment, so later readers know the precedent? One difference stands out though: ld64 only nops the fixup and deliberately keeps the atoms and symbols "to ensure correct libraries are linked in". Since this PR goes further and removes the sections and symbols entirely, do you know what broke when ld64 tried stripping? I'd like to confirm the same hazard doesn't apply here (or is covered by the external-symbol guard) before we take the stronger approach.

Will do. I suspect the reason they left the atoms in place is because that is how their dylib load command mechanism works, which is the goal of the FORCE_LOAD symbols. The unit tests do validate that we are keeping the load commands around post stripping.



https://github.com/llvm/llvm-project/pull/214584


More information about the llvm-commits mailing list