[PATCH] bfd: recognize *-*-windows* Windows targets

Pedro Alves pedro@palves.net
Tue Jul 14 00:49:15 GMT 2026


FYI, the motivation for this patch is this GDB patch series:

 https://inbox.sourceware.org/gdb-patches/20260714004507.1323332-1-pedro@palves.net/T/

The relevant bit is this:

~~~
The motivation is to be able to build a MinGW-hosted GDB that defaults
to debugging MSVC-ABI binaries, and to run the testsuite with such a
GDB and a matching Clang.  IOW, to build GDB with:

 --host=x86_64-w64-mingw32 --target=x86_64-pc-windows-msvc

To be clear, this does _not_ propose making it possible to build GDB
with --host=x86_64-pc-windows-msvc.  That's a different can of worms.
~~~

(I realize that I forgot to copy that snippet into this bfd patch's commit log.)

Thanks,
Pedro Alves

On 2026-07-14 00:15, Pedro Alves wrote:
> Clang's default target on Windows uses the "windows-msvc" OS in its
> triplet, e.g. x86_64-pc-windows-msvc, i686-pc-windows-msvc, and
> aarch64-pc-windows-msvc.  This is different from MinGW triplets -- it
> means that the compiler produces binaries following the Windows/MSVC
> ABI, not the GNU ABI.  config.sub already canonicalizes these, but
> config.bfd doesn't map them to a BFD target vector, so configuring for
> one of these targets fails to select a default vector.
> 
> Fix this by extending the i386, x86_64 and aarch64 PE entries to also
> match "*-windows*", so that Windows targets spelled with the "windows"
> OS select the same PE vectors as their mingw counterparts.
> 
> Note: even though config.sub does not support "windows-gnu" today,
> Clang and Rust support it, as an alias for MinGW.  Clang also accepts
> plain "windows", treating it as MSVC.  That's why the patch matches
> "windows*".  Also, this is what is already used in bfd, anyhow:
> 
>  bfd/configure.host:81:*-*-windows*)
>  bfd/acinclude.m4:24:*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
> 
> Change-Id: Ibc48f0c8fb0dbfda5f752ea6e8374d75c57b8bb7
> ---
>  bfd/config.bfd | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/bfd/config.bfd b/bfd/config.bfd
> index 02a1a68525e..c8a0e577ebc 100644
> --- a/bfd/config.bfd
> +++ b/bfd/config.bfd
> @@ -254,7 +254,7 @@ case "${targ}" in
>      targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec aarch64_pei_le_vec aarch64_pe_le_vec"
>      want64=true
>      ;;
> -  aarch64-*-pe* | aarch64-*-mingw*)
> +  aarch64-*-pe* | aarch64-*-mingw* | aarch64-*-windows*)
>      targ_defvec=aarch64_pe_le_vec
>      targ_selvecs="aarch64_pe_le_vec aarch64_pei_le_vec aarch64_pe_bigobj_le_vec aarch64_elf64_le_vec aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec pdb_vec"
>      want64=true
> @@ -634,7 +634,7 @@ case "${targ}" in
>      # FIXME: This should eventually be checked at runtime.
>      targ_cflags=-DSTRICT_PE_FORMAT
>      ;;
> -  i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
> +  i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe | i[3-7]86-*-windows*)
>      targ_defvec=i386_pe_vec
>      targ_selvecs="i386_pe_vec i386_pe_big_vec i386_pei_vec i386_elf32_vec pdb_vec"
>      targ_underscore=yes
> @@ -1361,7 +1361,7 @@ case "${targ}" in
>      targ_selvecs="i386_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec"
>      want64=true
>      ;;
> -  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
> +  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | x86_64-*-windows*)
>      targ_defvec=x86_64_pe_vec
>      targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec i386_pe_vec i386_pe_big_vec i386_pei_vec i386_elf32_vec pdb_vec"
>      want64=true
> 
> base-commit: 490469846dcef89fe53668bdbba73591c64bed61



More information about the Binutils mailing list