LLD: targeting cygwin

Hello, I have a user who is trying to get LLD to link for the cygwin target: https://github.com/zig-lang/zig/issues/751

Currently the issue they are running into is needing to define a linker script, but the COFF driver (or MinGW driver) does not have support for that.

Is there documentation or advice for how to use LLD to link for cygwin? As a starting point, which driver to use?

Regards,
Andrew

COFF lld doesn’t support the linker script at the moment, and I’m sad to say that it is very unlikely to support that in the future. Linker script support is so huge that I can’t imagine we really want it for COFF. GNU BFD linker supports it because the linker is built as an interpreter for the built-in linker script (and that’s one of the reasons why GNU linker is by far more complicated than lld), but that’s not the case for lld.

So, “support linker script” is a huge feature request that we are very unlikely to fulfill. But I don’t think that you actually need all the features of the linker script. If you have some specific need, please explain. We may be able to help.

Here are the linker errors:

lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: data_start
lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: data_end
lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: bss_start
lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: bss_end
lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: RUNTIME_PSEUDO_RELOC_LIST
lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: RUNTIME_PSEUDO_RELOC_LIST_END
lld: warning: libcygwin.a(_cygwin_crt0_common.o): undefined symbol: image_base

They seem to come from the default cygwin ld linker script, pasted below:

GNU ld (GNU Binutils) 2.29.1.20171006
Supported emulations:
i386pep
i386pe
using internal linker script:

Is that the only problem to use lld to link cygwin programs?

I believe my user has forked LLD and is experimenting and will report back with findings.