Unifying Windows Target Triples

Hi,

After a discussion with David, Id like to propose a rework of the Windows target triples. The current set of Windows triples are somewhat less uniform than their Linux counterparts. With multiple ABIs and environments on Windows, they are also slightly awkward. Obviously, certain ones might be nice to keep around for compatibility (e.g. the mingw triple).

Just to ensure that everyone has the same understanding, the canonical format for a triple is: arch-vendor-os-environment .

We have the following environment on Windows:

As far as I know, everyone conforms to the MS C ABI.
- There is the MS C++ ABI which is still being developed.
- There is the IA-64 ABI which is incompatible with msvcprt.
- There is the MinGW sub environment which supplies additional UNIX-y functions and uses IA-64 ABI for C++.

The Windows environment is uniformly (COFF)/PE.

As for the OS, Windows is slightly generic. Windows 9x, Windows NT, and Windows CE are all slightly different. However, given that Microsoft has taken a unifying strategy with Windows NT, I *think* sticking to Windows for the OS should be okay. That said, I could be convinced to use winnt or windowsnt.

So, one way to clearly define a naming scheme for this space would be something along the lines of:

{armv7,i686,x86_64}-windows-{ia,mingw,ms}pe

This allows us to uniformly take any of the combination IA-64 or MS C++ ABI + MS C ABI or the MinGW environment (which is IA-64 ABI and its supplementary libraries).

I understand that this may be controversial since it can potentially break existing code bases, but I think that the result of this is worth it.

I like this direction in general, but:

{armv7,i686,x86_64}-windows-{ia,mingw,ms}pe

First a correction, I assume you mean:
{armv7,i686,x86_64}-<vendor>-windows-{ia,mingw,ms}pe

I think these are the wrong ABI names. And if the environments are
uniformly PE, I don't think we should bother with it.

I would suggest:

...-windows-{msvc,gnu,itanium}

MSVC is obvious.
Itanium is obvious.
GNU -> mingw's oddity.

Rationale:
The "Min" isn't relevant to the ABI. The "W" is redundant. The "G" is the
only relevant part, and it stands for GNU.

I like this direction in general, but:

Excellent!

{armv7,i686,x86_64}-windows-{ia,mingw,ms}pe

First a correction, I assume you mean: {armv7,i686,x86_64}-<vendor>-windows-{ia,mingw,ms}pe

That is indeed what I meant.

I think these are the wrong ABI names. And if the environments are uniformly PE, I don't think we should bother with it.

I should have been more clear, the currently supported environments are PE. There are versions of Windows which use other formats, and so I would prefer to retain the PE.

I would suggest:

...-windows-{msvc,gnu,itanium}

MSVC is obvious.
Itanium is obvious.
GNU -> mingw's oddity.

Rationale:
The "Min" isn't relevant to the ABI. The "W" is redundant. The "G" is the only relevant part, and it stands for GNU.

The rational is entirely valid. You raise an excellent point that I failed to consider, MinGW is really "Minimalist GNU on Windows”. I find ia (or ia64) to be nicer, but, Id be happy enough with itanium.

Would you be willing to agree to:

{armv7,i686,x86_64}-<vendor>-windows-{ia,gnu,ms}pe

I think 'msvc' is the only acceptable format. ;]

I don't really like 'ia' or 'ia64'. Those are CPU architectures, and very
specific ones. http://mentorembedded.github.io/cxx-abi/abi.html says
"Itanium C++ ABI". I think the name should reflect what that document says.

I'd actually rather prefer "<abi>-<fileformat>" as otherwise this is
completely illegible. But that's not deal breaker for me.

Would you be willing to agree to:

{armv7,i686,x86_64}-<vendor>-windows-{ia,gnu,ms}pe

You're opening big can of worms here...

Note, that stuff like "i386-mingw32" and similar target triples should
be supported regardless of this "canonical" scheme.

Also:
- Debian uses "i586-mingw32msvc" triple
- There is mingw-w64 which uses "x86_64-w64-mingw32" and "i686-w64-mingw32"

FWIW, I interpret the original email as explicitly saying that existing
(widely used) triples need to keep working. We already have lots of aliases
so this doesn't seem like an undue burden.

Saleem,

Thanks to open the Pandora's box!

I am certain "Win32" should be common word to represent Win32 API (ABI
in some context).
Then, I preferer -win32- rather than -windows-.
If we could use *-win32, I hope it might be neutral as possible.
That said, I don't have concrete plan what *-win32 should be.

In other words, I think it'd be worse that "*-pc-win32" represents
whole msvc things.

I could make the matrix later. This is a random note.

* i686-pc-cygwin (gcc-4.x)
  - PE/COFF
  - Win32 compatible. Win32 API(s) could be available with <windows.h>.
  - Doesn't use thiscall.
  - Doesn't use msvcrt. Using newlib delivered.
  - Uses GNU libstdc++ and libsupc++.
  - Uses dw2 eh.

* i686-pc-mingw32 (<4.6)
  - Uses msvcrt.dll. (malloc is not 16-byte aligned). Other versions
of msvcrt are optional.
  - Uses some supplemental libs that incapable in msvcrt.dll.
  - Uses libgcc
  - Uses GNU libstdc++ and libsupc++ provided by g++ (lib/gcc/i686-pc-mingw32)
  - Doesn't use thiscall.
  - dw2 is available older version of mingw32 was available only sjlj.

* *-w64-mingw32 (>=4.6)
  - Uses msvcrt.dll even on x86_64 (!!!)
  - EH is optional, x64-comptatible eh (aka seh) may be available.
  - multilib is available in development environment.
  - Uses thiscall (for i686)
  - Uses GNU libstdc++.

* x86_64-pc-cygwin
  - LP64
  - Investigating :stuck_out_tongue:

I wonder if we could provide neutral *-win32 for our project, or naked
*-win32 might be used as non-C++ environments...
(Consider with compiler-rt, libcxxabi and libcxx)

...Takumi

Win32 is not an ABI. If one were to compile an NT driver, they wouldn’t be targeting win32. They would be targeting windows.

Saleem,

Thanks to open the Pandora's box!

Agreed that this is probably pandora’s box, but, I think that addressing this now will help with the addition of Windows on ARM.

I am certain "Win32" should be common word to represent Win32 API (ABI
in some context).
Then, I preferer -win32- rather than -windows-.
If we could use *-win32, I hope it might be neutral as possible.
That said, I don't have concrete plan what *-win32 should be.

I agree that Windows is less precise, but that ambiguity is slightly on purpose. Win32 is not the OS, its more the set of APIs. Using windows permits us the ability to handle various different scenarios related to Windows (consider the case of Windows drivers where the Windows Kernel APIs are targeted rather than the WIN32 APIs).

In other words, I think it'd be worse that "*-pc-win32" represents
whole msvc things.

I could make the matrix later. This is a random note.

* i686-pc-cygwin (gcc-4.x)
- PE/COFF
- Win32 compatible. Win32 API(s) could be available with <windows.h>.
- Doesn't use thiscall.
- Doesn't use msvcrt. Using newlib delivered.
- Uses GNU libstdc++ and libsupc++.
- Uses dw2 eh.

* i686-pc-mingw32 (<4.6)
- Uses msvcrt.dll. (malloc is not 16-byte aligned). Other versions
of msvcrt are optional.
- Uses some supplemental libs that incapable in msvcrt.dll.
- Uses libgcc
- Uses GNU libstdc++ and libsupc++ provided by g++ (lib/gcc/i686-pc-mingw32)
- Doesn't use thiscall.
- dw2 is available older version of mingw32 was available only sjlj.

* *-w64-mingw32 (>=4.6)
- Uses msvcrt.dll even on x86_64 (!!!)
- EH is optional, x64-comptatible eh (aka seh) may be available.
- multilib is available in development environment.
- Uses thiscall (for i686)
- Uses GNU libstdc++.

* x86_64-pc-cygwin
- LP64
- Investigating :stuck_out_tongue:

MinGW32-W64 is a rework of MinGW32. AFAIK, it has entirely superseded MinGW32, so the “gnu” environment would represent both of these.

MinGW32-W64 is a fork of cygwin. The “gnu” environment would cover cygwin as well. If they have diverged significantly, cygnus vs gnu could be used to differentiate them.

I wonder if we could provide neutral *-win32 for our project, or naked
*-win32 might be used as non-C++ environments...
(Consider with compiler-rt, libcxxabi and libcxx)

The windows-msvc would cover the pure C case. If you are using libc++/libc++abi then you need a C++ ABI. That would be covered by the windows-itanium target.

This mostly all makes sense to me.

If someone feels strongly about changing “win32” to “windows”, they can do that, but we have to keep accepting win32 as a synonym. I’d accept it even when used with new ISAs like armv7.

The way we have multiple Windows-ish OSs is probably silly, and should be unpacked to something like -win32-gnu, -win32-msvc, and -win32-itanium.

Internally we should map -mingw32 to -win32-gnu and -win32 to -win32-msvc. I may be biased in favor of the second mapping, but it’s what we’ve been doing for a few months now.

I’m not sure if we should attempt to map cygwin to -win32-cyg(win)?. It’s really a different beast.

For the PE portion, I agree we should split it with a dash if its going to be there. And if we do that, we can pull ELF and MachO out of the Environment enum and make a new one for object file format. The object file format should be populated implicitly with the canonical format for the OS, and can be overridden if present.