May 15, 2022
https://issues.dlang.org/show_bug.cgi?id=23110

          Issue ID: 23110
           Summary: src/dmd/link.d tries to use MSVC linker on Windows
                    when MinGW is used
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: brecht@sanders.org

In `src/dmd/link.d` the section `version (Windows)` assumes MSVC is used, causing the `link` to be used when building MinGW-w64. When doing this in MSYS2 shell it will call the `link` command, which makes file links (part of GNU coreutils).

The `version (Posix)` won't work for MinGW-w64 since it uses pipes and forks to run the linker, which won't work on Windows.

So I think a `version (MinGW)` is needed (before `version (Windows)` since that
will match too) that uses GCC linking, called in a Windows way (`executecmd()`)
and with the right flags for MinGW (which is probably (mostly) the same as
Posix.

--