Skip to content

redpanda-cpp/mingw-infinity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

MinGW ∞

UTF-8 oriented MinGW-w64 GCC toolchain.

Use

The toolchain is a UCRT-based toolchain plus extensions for UTF-8 programming. That is to say, without special arguments, it works as a common UCRT-based toolchain.

The toolchain is static by default. To opt-in shared runtime libraries, copy $prefix/lib/shared-unstable/* to $prefix/.

UTF-8 C and C++ Standard Library (U8CRT) Mode

-mcrtdll=utf8-ucrt and -stdlib=libutf8-stdc++ (compile time and link time) enable UTF-8 C and C++ standard library (U8CRT) mode. In this mode, the compiler and linker automatically link UTF-8 variant of ucrt and libstdc++.

This is good for beginners or simple programs. No changes are required to the source code if it only calls C and C++ standard library functions.

Boost.Nowide’s nowide::narrow and nowide::widen is recommended for Win32 API calls. The standalone version of Boost.Nowide is included in the toolchain.

NEVER MIX UTF-8 and non-UTF-8 C and C++ standard libraries. i.e. use BOTH flags or NEITHER for C++.

UTF-8 Manifest Mode

-mutf8 (link time) enables UTF-8 manifest mode. In this mode, the compiler automatically embeds UTF-8 manifest into the executable.

This is good for GUI programs that target Windows 10 1903 or later, and console programs that target Windows 10 22H2 or later (which defaults to Windows Terminal that supports UTF-8 input). No changes are required to the source code as long as the program does not call GDI functions.

Build

The build scripts and patches are located at MinGW Lite repository. See build instructions there (64-u8crt, 32-u8crt).

MinGW ∞ adds additional arguments --abi-name=∞{64,32}-{next,current}, --pkg-prefix=infinity{64,32}.

Technical Details

MinGW-w64 ABI

  • Default CRT: ucrt.
  • Exception model: seh (64-bit), dwarf (32-bit).
  • Thread model: posix.
  • Thread local storage: native (16.x), emulated (15.x).
  • Minimum OS version: Windows Server 2003 SP2 (x64), Windows XP SP3 (x86).

Extensions

  • The tools are internally UTF-8 and use UTF-8 in pipes.
  • Compiler warning of invalid UTF-8 sequence is enabled by default unless -finput-charset or -Wno-invalid-utf8 is specified.
  • Compile and link flag -mcrtdll=utf8-ucrt.
    • Compile time: define _UCRT, UNICODE, _UNICODE.
      • UNICODE and _UNICODE are defined to avoid passing narrow UTF-8 strings to ANSI WinAPI getting silently compiled.
    • Link time: link UTF-8 variant of ucrt, -lutf8-ucrt -lutf8-musl -lmingwex -lutf8-ucrt.
      • libutf8-ucrt is ucrt import library with UTF-8 thunks that convert narrow strings to wide strings and call their wide versions.
      • libutf8-musl implements UTF-8 stdio by porting musl functions.
  • Compile and link flag -stdlib=libutf8-stdc++.
    • Compile time: set proper C++ standard library header search path.
    • Link time: link UTF-8 variant of libstdc++, -lutf8-stdc++.
      • libutf8-stdc++ static library is identical to libstdc++.
      • libutf8-stdc++ shared library is almost same to libstdc++, except that it links to UTF-8 variant of ucrt.
  • Link flag -mutf8.
    • Embed UTF-8 manifest.
    • When building a console application (without -mwindows), also enable UTF-8 code page.
      • On starting, set console code page to active code page (SetConsoleCP(GetACP()); SetConsoleOutputCP(GetACP());).
      • On exiting, restore console code page.

About

MinGW ∞: UTF-8 oriented MinGW-w64 GCC toolchain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors