unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72335: An attempt to fix UCRT64 build failure
@ 2024-07-28 13:55 YI Yue via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-07-28 14:22 ` Pip Cet via Bug reports for GNU Emacs, the Swiss army knife of text editors
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: YI Yue via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-28 13:55 UTC (permalink / raw)
  To: 72335

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]

Hello, everyone

I occasionally try to compile Emacs to get the latest commits. But on Windows, I
only use Mingw64 because it's the only one officially supported by Emacs.[1]
When I try to build Emacs in MSYS2/UCRT64, I'll get these outputs:

./temacs --batch  -l loadup --temacs=pbootstrap \
        --bin-dest '/d/user/yy/emacs-build/bin/' --eln-dest '/d/user/yy/emacs-build/lib/emacs/31.0.50/'
D:\user\yy\emacs-master\src\temacs.exe: Write error to standard output: No such file or directory

MSYS2 do provides a patch[2] that do something about function
`close_output_streams' in src/sysdep.c. By applying it, I can get these results:

***
*** "make all" succeeded, but Emacs is not functional.
***

Sometimes I'll check emacs-devel to see if there are any progress in solving
this problem, such as this[3]. Two days ago I saw Pip Cet's "MPS: Win64
testers?"[4] and it inspired me that the problem may come from `init_ntproc' in
src/w32.c. After seeing UCRT's documentation[5], I think maybe we can use
`_fcloseall' instead of `fclose'? By using this, I get no error above when building 
in MSYS2/UCRT64.

I have little knowledge of MSVCRT and UCRT, it just works :)

Here is my patch, regards.

[1]: https://lists.gnu.org/archive/html/help-gnu-emacs/2022-01/msg00441.html
[2]: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-emacs/001-ucrt.patch
[3]: https://lists.gnu.org/archive/html/emacs-devel/2024-02/msg00744.html
[4]: https://lists.gnu.org/archive/html/emacs-devel/2024-07/msg01055.html
[5]: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fclose-fcloseall

[-- Attachment #2: ucrt.patch --]
[-- Type: application/octet-stream, Size: 418 bytes --]

diff --git a/src/w32.c b/src/w32.c
index 31ffa301c2..a7fc0efde4 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -10513,9 +10513,13 @@ init_ntproc (int dumping)
 		     FALSE,
 		     DUPLICATE_SAME_ACCESS);

+#ifndef _UCRT
     fclose (stdin);
     fclose (stdout);
     fclose (stderr);
+#else
+    _fcloseall();
+#endif

     if (stdin_save != INVALID_HANDLE_VALUE)
       _open_osfhandle ((intptr_t) stdin_save, O_TEXT);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-08-11 18:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-28 13:55 bug#72335: An attempt to fix UCRT64 build failure YI Yue via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-28 14:22 ` Pip Cet via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-28 14:49   ` bug#72335: ��� " o0o0o���� via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-28 14:29 ` Eli Zaretskii
2024-07-28 14:47   ` bug#72335: ��� " o0o0o���� via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-03 15:39 ` Angelo Graziosi
2024-08-11 16:50   ` Yi Yue via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-11 18:35     ` Angelo Graziosi

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).