unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Arthur Miller <arthur.miller@live.com>
Cc: emacs-devel@gnu.org
Subject: Re: Compiling in mingw-ucrt runtime
Date: Sun, 25 Feb 2024 08:33:16 +0200	[thread overview]
Message-ID: <86edd1xdcj.fsf@gnu.org> (raw)
In-Reply-To: <DU2PR02MB101090193B1D88B7999BA636096542@DU2PR02MB10109.eurprd02.prod.outlook.com> (message from Arthur Miller on Sun, 25 Feb 2024 00:11:10 +0100)

> From: Arthur Miller <arthur.miller@live.com>
> Cc: emacs-devel@gnu.org
> Date: Sun, 25 Feb 2024 00:11:10 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > 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

What is the value of errno before and after fclose, in particular when
ferror does NOT fail (i.e. prev_fail is false)?

> > 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.

The __imp_snprintf means it expects the function to be pulled from a
DLL.  Which is wrong, AFAIU; see below.

> $ 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

OK, this means _snprintf in the UCRT case is defined by some header.
And indeed I see its definition in stdio.h, for UCRT only.  So I think
your original change was OK after all, and I have now installed it
with a comment explaining why.

> 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.

You should be able to use "nm -g SOME.DLL" to show the symbols
exported by that DLL; those marked "T" are functions.

But I don't think you need that: the above clearly tells us _snprintf
does NOT come from a DLL, its code is included in the executable
(that's what "t" means in the nm output), which can only mean it is
either defined inline in some header or in the program sources
themselves.

> 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?

But the fclose problem does not happen in cmdproxy.exe, it is in
emacs.exe, right?  So this is not relevant to the fact that cmdproxy
doesn't include stdio.h.

> 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?

Yes: we want to compile each Lisp file in a clean environment,
unchanged by loading any other Lisp files.

> Just so we can call make with -jN flag?

You can use -jN, and that speeds up the compilation quite a lot.  On
my system I use -j16, and I can bootstrap Emacs in under 4 min.



  parent reply	other threads:[~2024-02-25  6:33 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
2024-02-25  5:56                 ` Po Lu
2024-02-25  6:33                 ` Eli Zaretskii [this message]
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=86edd1xdcj.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=arthur.miller@live.com \
    --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).