To disable lazy definition sym resolution in ld.lld within the archive?

@MaskRay and @ruiu ,

We recently moved from GNU ld to LLVM ld and
comes across the scenario like archive.a has the objects file with same strong symbol “foo” in two object files like strong1.o (in data) and strong2.o(in bss)

and archive processing goes like
ref1.o (has some defs and requires strong symbol name like “bar”(undefined))
strong1.o(Has the “foo” definition adds the foo lazy definition to symbol) and not sure why ld.lld picks it from archive …at this point …we don’t have any reference to “foo” or any other definitions of strong1.o.

ref2.o (Refers sym like “foo” and so its reference binds to strong1.o(foo))
strong2.o (has definition for “foo” and “bar”) and ld.lld error out with here multiple definitions for “foo” .

In GNU ld case , it pick the list like ref1.o then ref2.o and strong2.o and linkage goes without error .

We can refactor the our archive in this case to work by having one strong symbol “foo” in archive or we have any way to back out this lazy definition sym resolution within archive in ld.lld ?

Thank you

Perhaps you can rephrase the problem as using split-file and some llvm-mc and ld.lld commands so that people can play with your example…

If I understand you correctly, your build will be flagged by --warn-backrefs:

I call it a linking sandwich problem. It’s a brittle build issue that should be avoided. Believing in the GNU ld/gold way would actually be very tricky for modern linkers. And I haven’t ever heard a convincing argument.