[lld] [lld] check the format of libary and skip the wrong one (PR #78874)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 18:12:42 PST 2024


MaskRay wrote:

> > I think GNU ld supports some "wrong e_machine, skip" logic for `-lfoo` and we have rejected supporting this fishy behavior. We cannot think of a reasonable case this is ever desired. The solution is always to fix the build system to not provide dubious `-L` paths in the first place. For linker scripts, I think GNU ld tries skipping an incompatible script if an incompatible `OUTPUT_FORMAT` is seen. However, a question arises about what we should do if we have parsed something before `OUTPUT_FORMAT`.
> 
> I have some questions about that. What I see in the code is that the library is added and then parsed. Will the link script change the behavior of the lld?

No behavior change. `OUTPUT_FORMAT` does cause lld to check whether input files have compatible emachine/ekind with `OUTPUT_FORMAT`.
I haven't checked GNU ld behavior. I do not know whether it may have accrued some state before an incompatible `OUTPUT_FORMAT` is seen.

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


More information about the llvm-commits mailing list