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
-
✔️ Setsstderrto unbuffered mode.stderrcan 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.POSIXstates thatstderrmust 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 openFILEstreams on clean exit, which is either a return frommainor a call toexit. This ensures thatFILEstreams 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 stagestdiointernal 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 theUTF-8codepage. This way the arguments we get frommainareUTF-8encoded rather thanACP-encoded, thereby addressing !3445 (comment 1753812). -
✔️ Declares compatibility up toWindows 11. This way tools and tests opt-in to newer features. We also get a faster memcpy on ARM64 (seecrt/vcruntime/initialization.cpp) -
✔️ Declares requiredUACsettings. 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