Add app-profile static lib for Windows

Adds a small dependency to be added to executables(). The app-profile dependency carries:

A small static library with a CRT constructor

  • ✔️ Sets stderr to unbuffered mode. stderr can be fully-buffered depending on the output type, for example named pipes. That's not good because we can loose important messages before a crash. POSIX states that stderr must not be fully-buffered. Note that we can't set line-buffering mode because the Windows CRT implements line-buffering the same as full-buffering. From setvbuf:

    _IOLBF For some systems, this mode provides line buffering. However, for Win32, the behavior is the same as _IOFBF - Full Buffering.

  • ✔️ Flushes all open FILE streams on clean exit, which is either a return from main or a call to exit. This ensures that FILE streams are flushed when the application is in a consistent state. The Windows CRT will flush the streams as well, but will do so later during process teardown. At that stage stdio internal locks may be abandoned, and attempting to acquire such locks leads to instant termination (so not all streams are flushed).
  • ✔️ Opts-in to security settings. We can enable data execution prevention also on x86 builds, etc.

A resource including a fusion manifest XML:

  • ✔️ Enables the UTF-8 codepage. This way the arguments we get from main are UTF-8 encoded rather than ACP-encoded, thereby addressing !3445 (comment 1753812).
  • ✔️ Declares compatibility up to Windows 11. This way tools and tests opt-in to newer features. We also get a faster memcpy on ARM64 (see crt/vcruntime/initialization.cpp)
  • ✔️ Declares required UAC settings. This way the OS does not apply heuristics to determine if the tool needs elevation (like !3490 (merged), but for all executables)
  • We can add more in the future: long paths support, segmented heap, etc.

Fixes #3733 (closed)

Edited by Luca Bacci

Merge request reports

Loading