[clang] [Clang][Driver] Revise Cygwin ToolChain to call linker directly (PR #147960)
Tomohiro Kashiwada via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 11 03:34:52 PDT 2025
kikairoya wrote:
Thanks.
It looks like some linker options might still be missing or need adjustments:
- `--enable-auto-import`, `--disable-high-entropy-va`, and `--dll-search-prefix=cyg` are generally required on Cygwin.
- `-pie` has no effect when targeting PE/COFF and can be ignored.
Also, a few options should be handled in both `class Cygwin` and in the linker job construction:
- `-mwindows` should be translated into `--subsystem=windows`.
- `-shared` and `-mdll` are subtly different in what they instruct GCC to link with.
> I confirmed 'clang++ -fuse-ld=lld` works. What is your concern about LLD?
Here are a few issues I've seen when using LLD:
- LLD requires passing `-u _Znwm` and other operators explicitly, otherwise [`default_cygwin_cxx_malloc` defined in `libcygwin.a`](https://github.com/mirror/newlib-cygwin/blob/1b7c72fdcc4bde7520407d2d3364146f04fb8312/winsup/cygwin/cxx.cc#L92) pulls wrong reference (at least as of a month ago), due to [different handling of `--wrap` compared to GNU ld](https://maskray.me/blog/2020-12-19-lld-and-gnu-linker-incompatibilities). This may surface in `check-cxx` failures.
- LLD doesn’t have built-in default search paths, so `-L/usr/lib/w32api` needs to be specified.
- [Binaries linked with LLD can't be rebased](https://cygwin.com/pipermail/cygwin/2025-June/258268.html), which means we shouldn’t use `--disable-dynamicbase` (currently it's fine, as this option isn't set).
It would be great if this patch could be adjusted to support bootstrapping without requiring extra linker flags.
https://github.com/llvm/llvm-project/pull/147960
More information about the cfe-commits
mailing list