[clang] [Clang][Driver] Revise Cygwin ToolChain to call linker directly (PR #147960)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 24 08:41:32 PDT 2025


tyan0 wrote:

> > * 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.
> 
> This also happened today, and not only with LLD but also with BFD, so "due to different handling of `--wrap` compared to GNU ld" seems wrong. Unfortunately, I couldn't create a minimal reproducer, so I can't tell whether the issue lies in the linkers, libc++, or libcygwin.a. Other functionalities look good to me; this patch enables bootstrapping using LLD without hacky linker flags.

I am not sure why the issue happens; however, I doubt whether `-u _Znwm` etc. make any real difference.
```man
       -u symbol
       --undefined=symbol
           Force  symbol  to  be  entered  in  the  output file as an undefined
           symbol.  Doing this may, for example, trigger linking of  additional
           modules  from standard libraries.  -u may be repeated with different
           option arguments to enter additional undefined symbols.  This option
           is equivalent to the "EXTERN" linker script command.

           If this option is being used  to  force  additional  modules  to  be
           pulled into the link, and if it is an error for the symbol to remain
           undefined, then the option --require-defined should be used instead.
```
The symbol `_Znwm` itself does not exist in any libraries or modules, I think.

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


More information about the cfe-commits mailing list