[cfe-dev] Why isn't LD.LLD a drop-in replacement for GNU LD when built on Windows as part of a MinGW-W64 based LLVM/Clang toolchain?
Reid Kleckner via cfe-dev
cfe-dev at lists.llvm.org
Fri Dec 14 11:18:24 PST 2018
Martin already replied, but I'll add this history. Apologies for any
Originally, there was a single LLD linker designed to handle all object
file formats, ELF, COFF, MachO, and perhaps a new "LLVM native" format. The
most active contributors at the time, Rui, Rafael, and maybe others I'm
forgetting, found this very limiting, and it was very difficult to achieve
their performance goals in that framework. So, a new COFF port was created,
with the initial goal of being faster than and compatible with the MSVC
linker. This effort was successful, so the same approach was applied to the
ELF linker, but the codebases remained separate to prevent too many
abstraction barriers from getting in the way of performance. I think there
was also a desire to radically simplify the design and push any competing
priorities, such as reusability as a library, out of scope.
Mingw support was added later as a secondary goal, and there is still a lot
of tension between doing things the "gnu" way and doing things the
Microsoft way. As a result, linker script support lives over in ELF land. I
think retrofitting it into the COFF linker would be a major challenge. My
understanding is that it was a large source of complexity for the ELF
linker as well.
On Fri, Dec 14, 2018 at 9:22 AM Ben Grasset via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> As far as I can tell, it is literally the only tool in the entire
> LLVM/Clang ecosystem for which this is the case.
> I.E. clang.exe works as a direct replacement for MinGW gcc.exe.
> clang++.exe works as a direct replacement for MinGW g++.exe. llvm-objcopy
> works as a direct replacement for MinGW objcopy.exe. llvm-objdump works as
> a direct replacement for MinGW objdump.exe. And so on.
> Is it just one of those unfortunate worked-out-that-way-historically sort
> of things? Looking at the source repository it seems like there are a lot
> of things developed in the ELF folder that probably shouldn't be
> ELF-specific, for example LinkerScript.cpp. To my mind linker script
> parsing has no reason to specifically by an "ELF" thing.
> Are there any current plans to bridge this compatibility gap in the
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev