unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Gnulib's boot-time.c breaks the build with mingw.org's MinGW
@ 2024-06-04 16:27 Eli Zaretskii
  2024-06-04 18:39 ` Collin Funk
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-06-04 16:27 UTC (permalink / raw)
  To: Paul Eggert, Bruno Haible; +Cc: Collin Funk, emacs-devel, bug-gnulib

Paul imported today the latest changes from Gnulib, and that broke the
Emacs MinGW build on the master branch when mingw.org's MinGW is used:

  boot-time.c:49:11: fatal error: sysinfoapi.h: No such file or directory
     49 | # include <sysinfoapi.h>
	|           ^~~~~~~~~~~~~~
  compilation terminated.

mingw.org's MinGW doesn't have the sysinfoapi.h header (unlike
MinGW64).  However, that header is not really needed here because the
signature of the GetTickCount64 function, which boot-time-aux.h now
calls, is completely defined in boot-time-aux.h:

  typedef ULONGLONG (WINAPI * GetTickCount64FuncType) (void);

Moreover, the Microsoft documentation, here:

  https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64

clearly says that the header file to be included when using
GetTickCount64 is windows.h, not sysinfoapi.h directly.

So I think the Gnulib code should be amended not to include
sysinfoapi.h.  For the time being I made a local change in Emacs, to
be able to build the master branch with MinGW, but I don't think it's
an Emacs-specific issue.

P.S. Paul, please from now on, and until the emacs-30 release branch
is cut, please coordinate with me any updates from Gnulib.  I don't
want us to destabilize the master branch inadvertently so close to the
beginning of the release cycle.  TIA.



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

* Re: Gnulib's boot-time.c breaks the build with mingw.org's MinGW
  2024-06-04 16:27 Gnulib's boot-time.c breaks the build with mingw.org's MinGW Eli Zaretskii
@ 2024-06-04 18:39 ` Collin Funk
  2024-06-04 18:46   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Collin Funk @ 2024-06-04 18:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Paul Eggert, Bruno Haible, emacs-devel, bug-gnulib

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

Hi Eli,

Eli Zaretskii <eliz@gnu.org> writes:

> However, that header is not really needed here because the
> signature of the GetTickCount64 function, which boot-time-aux.h now
> calls, is completely defined in boot-time-aux.h:
>
>   typedef ULONGLONG (WINAPI * GetTickCount64FuncType) (void);
[...]
> So I think the Gnulib code should be amended not to include
> sysinfoapi.h.  For the time being I made a local change in Emacs, to
> be able to build the master branch with MinGW, but I don't think it's
> an Emacs-specific issue.

Thanks for the report.

This code was a backup method for getting the boot time on Windows that
I added recently. On my system #include <windows.h> includes <winbase.h>
which then includes <sysinfoapi.h> unconditionally. Therefore you are
correct that there is no need to include it. I've applied the attached
patch in Gnulib fixing this.

Were you using an older Windows version perhaps? For older systems where
the function isn't declared in headers (_WIN32_WINNT < _WIN32_WINNT_VISTA)
the dll is loaded and it tries to get the function address from there.
Note that the line of code you sent is a typedef not a declaration. :)

Collin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-boot-time-readutmp-Fix-missing-MinGW-include-regr.-2.patch --]
[-- Type: text/x-patch, Size: 1998 bytes --]

From c41b3f92e3b0e9bd42d0ac05d80f3d23b00b28d2 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Tue, 4 Jun 2024 11:21:04 -0700
Subject: [PATCH] boot-time, readutmp: Fix missing MinGW include (regr.
 2024-05-24).

Reported by Eli Zaretskii in:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-06/msg00044.html>.

* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Remove unnecessary
<sysinfoapi.h> include. Some systems do not have this header and
<windows.h> should have the correct declarations.
* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Likewise.
---
 ChangeLog       | 10 ++++++++++
 lib/boot-time.c |  1 -
 lib/readutmp.c  |  1 -
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 787edff23d..1200ec0ec8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-06-04  Collin Funk  <collin.funk1@gmail.com>
+
+	boot-time, readutmp: Fix missing MinGW include (regr. 2024-05-24).
+	Reported by Eli Zaretskii in:
+	<https://lists.gnu.org/archive/html/bug-gnulib/2024-06/msg00044.html>.
+	* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Remove unnecessary
+	<sysinfoapi.h> include. Some systems do not have this header and
+	<windows.h> should have the correct declarations.
+	* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Likewise.
+
 2024-06-03  Paul Eggert  <eggert@cs.ucla.edu>
 
 	nstrftime: remove dependency on hard-locale
diff --git a/lib/boot-time.c b/lib/boot-time.c
index 71562dcf75..515fc48069 100644
--- a/lib/boot-time.c
+++ b/lib/boot-time.c
@@ -46,7 +46,6 @@
 #if defined _WIN32 && ! defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
-# include <sysinfoapi.h>
 # include <sys/time.h>
 #endif
 
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 82b9d4ca33..10d79d1d81 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -54,7 +54,6 @@
 #if defined _WIN32 && ! defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
-# include <sysinfoapi.h>
 # include <sys/time.h>
 #endif
 
-- 
2.45.1


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

* Re: Gnulib's boot-time.c breaks the build with mingw.org's MinGW
  2024-06-04 18:39 ` Collin Funk
@ 2024-06-04 18:46   ` Eli Zaretskii
  2024-06-04 19:10     ` Paul Eggert
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-06-04 18:46 UTC (permalink / raw)
  To: Collin Funk; +Cc: eggert, bruno, emacs-devel, bug-gnulib

> From: Collin Funk <collin.funk1@gmail.com>
> Cc: Paul Eggert <eggert@cs.ucla.edu>,  Bruno Haible <bruno@clisp.org>,
>   emacs-devel@gnu.org,  bug-gnulib@gnu.org
> Date: Tue, 04 Jun 2024 11:39:12 -0700
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > However, that header is not really needed here because the
> > signature of the GetTickCount64 function, which boot-time-aux.h now
> > calls, is completely defined in boot-time-aux.h:
> >
> >   typedef ULONGLONG (WINAPI * GetTickCount64FuncType) (void);
> [...]
> > So I think the Gnulib code should be amended not to include
> > sysinfoapi.h.  For the time being I made a local change in Emacs, to
> > be able to build the master branch with MinGW, but I don't think it's
> > an Emacs-specific issue.
> 
> Thanks for the report.
> 
> This code was a backup method for getting the boot time on Windows that
> I added recently. On my system #include <windows.h> includes <winbase.h>
> which then includes <sysinfoapi.h> unconditionally. Therefore you are
> correct that there is no need to include it. I've applied the attached
> patch in Gnulib fixing this.

Thanks.  Paul, please import this into our repository when you have
time, reverting my change when you do.

> Were you using an older Windows version perhaps? For older systems where
> the function isn't declared in headers (_WIN32_WINNT < _WIN32_WINNT_VISTA)
> the dll is loaded and it tries to get the function address from there.

I'm on Windows 11, but that's not important.  One can set _WIN32_WINNT
to any value during compilation, regardless of the underlying system.
_WIN32_WINNT is about which versions your application targets when it
runs, as I'm sure you know very well.

In any case, in the case in point we don't need the prototype of
GetTickCount64 because the code calls the function via a function
pointer, and loads it dynamically at run time.

> Note that the line of code you sent is a typedef not a declaration. :)

I know.  But since the function is not called directly, the typedef
declares its signature, and nothing else is required for the code to
compile.  (We could need the header if the code used some macros or
data structures defined on that header, but this is not the case
here.)



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

* Re: Gnulib's boot-time.c breaks the build with mingw.org's MinGW
  2024-06-04 18:46   ` Eli Zaretskii
@ 2024-06-04 19:10     ` Paul Eggert
  2024-06-05 11:09       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2024-06-04 19:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, Po Lu

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

On 2024-06-04 11:46, Eli Zaretskii wrote:
> Thanks.  Paul, please import this into our repository when you have
> time, reverting my change when you do.

Since the Gnulib change to lib/boot-time.c is identical to your change, 
there's no need to import it into Emacs now.

I plan to install the attached further patch, if it works for Po on 
Android. See this thread:

https://lists.gnu.org/r/bug-gnulib/2024-06/msg00040.html

[-- Attachment #2: 0001-More-permanent-fix-for-build-with-Android-NDK-r10b.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

From 604f7b45f97d4fe4146646cd296494716de767a6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 4 Jun 2024 11:54:24 -0700
Subject: [PATCH] More-permanent fix for build with Android NDK r10b

* configure.ac (gl_cv_header_working_endian_h):
Remove temporary workaround for Android.
* lib/endian.in.h: Copy latest version from Gnulib.
---
 configure.ac    |  6 ------
 lib/endian.in.h | 18 +++++++++++++++++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 369c9005c61..e3213f4ac79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,12 +49,6 @@
     CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=32"
     enable_largefile=no
     enable_year2038=no])
-  # Further, endian.h is not guaranteed to define every function that
-  # Gnulib seeks to replace, but Gnulib tests are not prepared for
-  # such versions of endian.h as only define a subset of the functions
-  # whose presence it tests.  Force such tests to succeed as a stopgap
-  # measure.
-  gl_cv_header_working_endian_h=yes
 fi
 
 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
diff --git a/lib/endian.in.h b/lib/endian.in.h
index bd65ae8aaba..156fe49fbda 100644
--- a/lib/endian.in.h
+++ b/lib/endian.in.h
@@ -69,8 +69,9 @@ #define PDP_ENDIAN 3412
 # define BYTE_ORDER LITTLE_ENDIAN
 #endif
 
-/* Make sure function-like macros get undefined.  */
 #if @HAVE_ENDIAN_H@
+
+/* Make sure we don't have any system definitions.  */
 # undef be16toh
 # undef be32toh
 # undef be64toh
@@ -83,6 +84,21 @@ #define PDP_ENDIAN 3412
 # undef htole16
 # undef htole32
 # undef htole64
+
+/* Define our own.  */
+# define be16toh rpl_endian_be16toh
+# define be32toh rpl_endian_be32toh
+# define be64toh rpl_endian_be64toh
+# define htobe16 rpl_endian_htobe16
+# define htobe32 rpl_endian_htobe32
+# define htobe64 rpl_endian_htobe64
+# define le16toh rpl_endian_le16toh
+# define le32toh rpl_endian_le32toh
+# define le64toh rpl_endian_le64toh
+# define htole16 rpl_endian_htole16
+# define htole32 rpl_endian_htole32
+# define htole64 rpl_endian_htole64
+
 #endif
 
 #ifdef __cplusplus
-- 
2.43.0


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

* Re: Gnulib's boot-time.c breaks the build with mingw.org's MinGW
  2024-06-04 19:10     ` Paul Eggert
@ 2024-06-05 11:09       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-06-05 11:09 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel, luangruo

> Date: Tue, 4 Jun 2024 12:10:42 -0700
> Cc: emacs-devel@gnu.org, Po Lu <luangruo@yahoo.com>
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> I plan to install the attached further patch, if it works for Po on 
> Android. See this thread:
> 
> https://lists.gnu.org/r/bug-gnulib/2024-06/msg00040.html

Fine with me, as long as Po Lu approves.



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

end of thread, other threads:[~2024-06-05 11:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04 16:27 Gnulib's boot-time.c breaks the build with mingw.org's MinGW Eli Zaretskii
2024-06-04 18:39 ` Collin Funk
2024-06-04 18:46   ` Eli Zaretskii
2024-06-04 19:10     ` Paul Eggert
2024-06-05 11:09       ` Eli Zaretskii

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