Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 871adefc authored by Brad King's avatar Brad King

cmake: Fix default file translate mode when using libuv

On Windows, libuv's one-time initialization changes the C runtime
library's  `_fmode` setting to `_O_BINARY`, thus causing files to open
as binary after that instead of the default `_O_TEXT` mode.  See
upstream libuv issue 840.  Work around the problem by performing libuv
initialization early and then restoring `_fmode`.

In particular, this currently affects server mode.  Without this fix,
the `_fmode` setting changes when the server mode initializes libuv.

Fixes: #16962
parent d025faf4
......@@ -27,6 +27,10 @@
#include <vector>
#ifdef _WIN32
#include <fcntl.h> /* _O_TEXT */
#include <stdlib.h> /* _set_fmode, _fmode */
#include "cm_uv.h"
......@@ -168,6 +172,18 @@ int main(int ac, char const* const* av)
ac = args.argc();
av = args.argv();
#if defined(CMAKE_USE_LIBUV) && defined(_WIN32)
// Perform libuv one-time initialization now, and then un-do its
// global _fmode setting so that using libuv does not change the
// default file text/binary mode. See libuv issue 840.
#ifdef _MSC_VER
_fmode = _O_TEXT;
if (ac > 1) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment