From: Arthur Miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Compiling in mingw-ucrt runtime
Date: Sun, 25 Feb 2024 00:11:10 +0100 [thread overview]
Message-ID: <DU2PR02MB101090193B1D88B7999BA636096542@DU2PR02MB10109.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <86bk86yxbs.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 24 Feb 2024 05:24:13 -0500")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Cc: emacs-devel@gnu.org
>> Date: Sat, 24 Feb 2024 10:13:45 +0100
>>
>> Ok; I have looked at close_stream :). Why is it clearing errno on prev_fail?
>>
>> if (! fclose_fail)
>> errno = 0;
>>
>> I don't think it is meaningful to signal to client code that operation failed,
>> but clear the errno so the application can't figure out why and recover.
>
> There are comments there which explain the rationale. If you are
> saying that in the UCRT build something goes wrong that violates the
> assumptions of this code, please tell the details. Specifically,
> which of these three operations indicates a failure:
>
> const bool some_pending = (__fpending (stream) != 0);
> const bool prev_fail = (ferror (stream) != 0);
> const bool fclose_fail = (fclose (stream) != 0);
prev_fail sometimes fail with Operation not permitted.
fclose fails always with -1
> You can answer that question by printing the 3 values, or by stepping
> through the code with GDB.
Yeah, I know Eli; thanks. :)
>> But perhaps I just don't understand the details. Anyway, I don't
>> think that is the problem here.
>>
>> I think the problem is that different libraries are mixed. I am not 100%,
>> because I am not familiar with the build process, but what I see is that ldflags and
>> cflags seems quite different for temacs vs cmdproxy:
>
> Of course, they are! temacs is a large application with GUI
> capabilities, and calls a lot of Windows APIs, whereas cmdproxy is a
> relatively simple console application that just calls the shell. The
I didn't expect them to be identical in the sense they will link against all the
same libraries and have all the same command line switches.
I don't see -DUSE_CRT_DLL=1 in temacs object; so I am just suspecting there
are some different dlls from different places with same symbols in game, but I
don't know how the build works. Perhaps they are both linked to the same ucrt
runtime anyway.
> question is: which of the libraries linked into temacs seem to define
> _snprintf, or if none do, how does the linker resolve the calls to
> _snprintf in w32.c, w32fns.c and sound.c. If you cannot figure that
$ nm -a nt/cmdproxy.exe | fgrep _snprintf
0000000140004060 D __imp_snprintf
0000000000000318 ? ucrt_snprintf.
$ nm -a src/sound.o | fgrep snprintf
0000000000000000 t _snprintf.constprop.0
U _vsnprintf
$ nm -a src/w32.o | fgrep snprintf
0000000000000bd0 t _snprintf
U _vsnprintf
$ nm -a src/w32fns.o | fgrep snprintf
U __mingw_vsnprintf
00000000000017d0 t _snprintf.constprop.0
U _vsnprintf
0000000000001800 t snprintf.constprop.0
How can I see which dll are they actually from? I tried with objdump but I
didn't got anything. Scanelf does not understand coff.
>> I have also tested to include <stdio.h> in cmdproxy.c; then I get conflicting
>> redefinition and conflicting declaration for printf and basically everything in
>> stdio:
>
> That's not surprising, since the comments in cmdproxy.c say:
>
> /* We don't want to include stdio.h because we are already duplicating
> lots of it here */
> extern int _snprintf (char *buffer, size_t count, const char *format, ...);
>
> So don't do that.
Yes, I have seen that, and expected those to conflict; but there is much more
conflicting than just those defined in cmdproxy.c. Basically every symbol from
stdio is conflicting, not just those defined in cmdproxy itself. I think it is
fishy,but perhaps I am misunderstanding that.
Can it be that fclose is trying to close a wrong pointer or something like that,
because pointer from one library is (wrongly) passed to a wrong library?
>> I have also a qeustion; I would like to understand better how Emacs get built,
>> so I wonder why does it include half of the gnulibc and core-utils in lib
>> directory?
>
> It isn't gnulibc or core-utils, it's Gnulib, the library that provides
> implementations of functions missing from C libraries that are not
> glibc. Emacs uses Gnulib to avoid too many #ifdef's in its sources,
> where some function needs to be used that is not guaranteed to exist
> on all platforms -- in such cases we use the Gnulib replacement.
Ok. Thanks.
Another question: the build process compiles one lisp file at a time It takes
quite long time to recompile. Is there some special reason a separate Emacs
process is created per each Lisp file, instead of single Emacs process compiling
all lisp files in batch? Just so we can call make with -jN flag?
next prev parent reply other threads:[~2024-02-24 23:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 0:01 Compiling in mingw-ucrt runtime Arthur Miller
2024-02-22 6:24 ` Po Lu via Emacs development discussions.
2024-02-22 7:14 ` Eli Zaretskii
2024-02-23 7:58 ` Arthur Miller
2024-02-23 8:24 ` Eli Zaretskii
2024-02-23 11:32 ` Arthur Miller
2024-02-23 12:02 ` Eli Zaretskii
2024-02-24 9:13 ` Arthur Miller
2024-02-24 10:24 ` Eli Zaretskii
2024-02-24 23:11 ` Arthur Miller [this message]
2024-02-25 5:56 ` Po Lu
2024-02-25 6:33 ` Eli Zaretskii
2024-02-25 10:19 ` Arthur Miller
2024-02-25 10:48 ` Eli Zaretskii
2024-02-25 11:40 ` Arthur Miller
2024-02-25 12:15 ` Eli Zaretskii
2024-02-25 14:11 ` Bruno Haible
2024-02-25 14:29 ` Eli Zaretskii
2024-02-25 15:05 ` Bruno Haible
2024-02-25 15:14 ` Eli Zaretskii
2024-02-25 15:32 ` Bruno Haible
2024-02-25 16:02 ` Eli Zaretskii
2024-04-02 15:30 ` Arthur Miller
2024-04-02 16:28 ` Eli Zaretskii
2024-04-03 13:09 ` Arthur Miller
2024-02-23 14:47 ` Benjamin Riefenstahl
2024-02-23 15:03 ` Benjamin Riefenstahl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DU2PR02MB101090193B1D88B7999BA636096542@DU2PR02MB10109.eurprd02.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).