Re: AC_SYS_LARGEFILE_REQUIRED vs. AC_SYS_YEAR2038_REQUIRED on MSVC

Bruno Haible <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.sysutils.autoconf.general
Message-ID <64681549.3F2A3RajZp@nimes>
Paul Eggert wrote:
> > +[AC_REQUIRE([AC_CANONICAL_HOST])
> Is there some way we can do this without requiring AC_CANONICAL_HOST? 
> We're close to a release for Autoconf, and requiring this at the last 
> minute for AC_SYS_LARGEFILE is a bit of a stretch.
> 
> That is, instead of AS_CASE([$host_os], ...) can  we use 
> AC_PREPROC_IFELSE with the appropriate C preprocessor tests? Or perhaps 
> do the AC_REQUIRE only if gl_LARGEFILE is defined?

Yes. Here are adjusted patches. I moved the AC_REQUIRE([AC_CANONICAL_HOST])
into the part that is only expanded if gl_LARGEFILE is defined.

Inside gnulib, so many macros require AC_CANONICAL_HOST that it's a no-brainer.

Find attached also the testdirs which I used to test the patches:
  - hello-3: no gnulib, just AC_SYS_LARGEFILE_REQUIRED
  - hello-4: no gnulib, just AC_SYS_YEAR2038_REQUIRED
  - testdir3: a gnulib testdir for the modules largefile-required stat
  - testdir4: a gnulib testdir for the modules year2038-required stat

In hello-3/configure and hello-4/configure the word 'host_os' does not occur;
this proves that the AC_REQUIRE([AC_CANONICAL_HOST]) has no effect if gnulib
is not used.

The configure results are exactly the expected outcome from my previous mail.
Summary table:

             mingw64  mingw32  msvc64  msvc32

hello-3        OK       OK     "support not detected" -> fail
hello-4        OK       OK     "support not detected" -> fail
testdir3       OK       OK       OK      OK
testdir4       OK       OK       OK      OK

Details from the configure output:

hello-3/build-mingw32  option to enable large file support... -D_FILE_OFFSET_BITS=64
hello-3/build-mingw64  option to enable large file support... -D_FILE_OFFSET_BITS=64
hello-3/build-msvc32   option to enable large file support... support not detected
hello-3/build-msvc64   option to enable large file support... support not detected
hello-4/build-mingw32  option to enable large file support... -D_FILE_OFFSET_BITS=64
hello-4/build-mingw64  option to enable large file support... -D_FILE_OFFSET_BITS=64
hello-4/build-msvc32   option to enable large file support... support not detected
hello-4/build-msvc64   option to enable large file support... support not detected
testdir3/build-mingw32 option to enable large file support... -D_FILE_OFFSET_BITS=64
testdir3/build-mingw64 option to enable large file support... -D_FILE_OFFSET_BITS=64
testdir3/build-msvc32  option to enable large file support... supported through gnulib
testdir3/build-msvc64  option to enable large file support... supported through gnulib
testdir4/build-mingw32 option to enable large file support... -D_FILE_OFFSET_BITS=64
testdir4/build-mingw64 option to enable large file support... -D_FILE_OFFSET_BITS=64
testdir4/build-msvc32  option to enable large file support... supported through gnulib
testdir4/build-msvc64  option to enable large file support... supported through gnulib

hello-4/build-mingw32  option to enable timestamps after Jan 2038... -D__MINGW_USE_VC2005_COMPAT
hello-4/build-mingw64  option to enable timestamps after Jan 2038... none needed
testdir4/build-mingw32 option to enable timestamps after Jan 2038... -D__MINGW_USE_VC2005_COMPAT
testdir4/build-mingw64 option to enable timestamps after Jan 2038... none needed
testdir4/build-msvc32  option to enable timestamps after Jan 2038... none needed
testdir4/build-msvc64  option to enable timestamps after Jan 2038... none needed

Bruno
0001-AC_SYS_YEAR2038_REQUIRED-Fix-configure-failure-with-.patch (text/x-patch, 1.5 KB)
From c0260017520a92e77579f4bee113901d7ae90db0 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 16 Apr 2023 01:24:34 +0200
Subject: [PATCH] AC_SYS_YEAR2038_REQUIRED: Fix configure failure with MSVC.

* lib/autoconf/specific.m4 (_AC_SYS_LARGEFILE_PROBE): Distinguish the results
"support not detected" and "supported through gnulib". If the result is
"supported through gnulib", don't fail.
---
 lib/autoconf/specific.m4 | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4
index 3bf1a0ed..f411695f 100644
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -323,11 +323,24 @@ AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
     test $ac_opt_found = no || break
   done
   CC="$ac_save_CC"
+  dnl Gnulib implements large file support for native Windows, based on the
+  dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE.
+  m4_ifdef([gl_LARGEFILE], [
+    AC_REQUIRE([AC_CANONICAL_HOST])
+    if test $ac_opt_found != yes; then
+      AS_CASE([$host_os],
+        [mingw*],
+          [ac_cv_sys_largefile_opts="supported through gnulib"
+           ac_opt_found=yes]
+      )
+    fi
+  ])
   test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
 
 ac_have_largefile=yes
 AS_CASE([$ac_cv_sys_largefile_opts],
   ["none needed"], [],
+  ["supported through gnulib"], [],
   ["support not detected"],
     [ac_have_largefile=no
      AS_IF([test $ac_largefile_required,$ac_year2038_required != no,no],
-- 
2.34.1
0001-year2038-required-Fix-configure-failure-with-MSVC.patch (text/x-patch, 2 KB)
From 89a0589a2965360400e11688cf50e1f90415c47b Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 16 Apr 2023 01:22:19 +0200
Subject: [PATCH] year2038-required: Fix configure failure with MSVC.

* m4/largefile.m4 (_AC_SYS_LARGEFILE_PROBE): Distinguish the results
"support not detected" and "supported through gnulib". If the result is
"supported through gnulib", don't fail.
---
 ChangeLog       |  7 +++++++
 m4/largefile.m4 | 13 +++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 581ca09a47..6dec50bd63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-04-16  Bruno Haible  <[email protected]>
+
+	year2038-required: Fix configure failure with MSVC.
+	* m4/largefile.m4 (_AC_SYS_LARGEFILE_PROBE): Distinguish the results
+	"support not detected" and "supported through gnulib". If the result is
+	"supported through gnulib", don't fail.
+
 2023-04-16  Bruno Haible  <[email protected]>
 
 	posix_spawn_file_actions_addclose tests: Avoid test failure on Cygwin.
diff --git a/m4/largefile.m4 b/m4/largefile.m4
index f741d0df6e..46b019a670 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -266,11 +266,24 @@ AC_DEFUN([_AC_SYS_LARGEFILE_PROBE]
     test $ac_opt_found = no || break
   done
   CC="$ac_save_CC"
+  dnl Gnulib implements large file support for native Windows, based on the
+  dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE.
+  m4_ifdef([gl_LARGEFILE], [
+    AC_REQUIRE([AC_CANONICAL_HOST])
+    if test $ac_opt_found != yes; then
+      AS_CASE([$host_os],
+        [mingw*],
+          [ac_cv_sys_largefile_opts="supported through gnulib"
+           ac_opt_found=yes]
+      )
+    fi
+  ])
   test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
 
 ac_have_largefile=yes
 AS_CASE([$ac_cv_sys_largefile_opts],
   ["none needed"], [],
+  ["supported through gnulib"], [],
   ["support not detected"],
     [ac_have_largefile=no
      AS_IF([test $ac_largefile_required,$ac_year2038_required != no,no],
-- 
2.34.1
testdirs.tar.xz (application/x-xz-compressed-tar, 437.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.