On 2026-10-12 04:34, Eli Zaretskii wrote:
Date: Sun, 11 Oct 2026 11:13:40 -0700 From: Paul Eggert<[email protected]> This patch follows Bruno's suggestion of avoiding the Gnulib localtime module because Emacs doesn't need it. It goes further by also avoiding Gnulib's tzsanitize module, as I assume Emacs doesn't need that either. If my assumption is incorrect I can create another patch that avoids localtime but not tzsanitize.Yes, let's do the latter, please.
OK, thanks, I did that by installing the attached on the master branch.
From a6ebb896b5179910794d0f503e24b08a763a8a95 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Mon, 12 Oct 2026 13:52:43 -0700 Subject: [PATCH] =?UTF-8?q?Avoid=20Gnulib=E2=80=99s=20localtime=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by Bruno Haible in: https://lists.gnu.org/r/emacs-devel/2026-10/msg00191.html * admin/merge-gnulib (AVOIDED_MODULES): Avoid localtime. * lib-src/ntlib.c, nt/inc/ms-w32.h (localtime): No need to #undef now. * lib-src/ntlib.c (rpl_localtime): Remove. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/localtime.c: Remove. * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_localtime): Remove. * src/w32.c (rpl_localtime): Remove. --- admin/merge-gnulib | 2 +- lib-src/ntlib.c | 11 ----------- lib/gnulib.mk.in | 15 +-------------- lib/localtime.c | 34 ---------------------------------- m4/gnulib-comp.m4 | 20 -------------------- m4/localtime.m4 | 16 ---------------- nt/gnulib-cfg.mk | 1 - nt/inc/ms-w32.h | 4 ---- src/w32.c | 6 ------ 9 files changed, 2 insertions(+), 107 deletions(-) delete mode 100644 lib/localtime.c delete mode 100644 m4/localtime.m4 diff --git a/admin/merge-gnulib b/admin/merge-gnulib index eca94e12d9a..c71bc036783 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -63,7 +63,7 @@ AVOIDED_MODULES= c32isalnum c32rtomb c32tolower c32toupper chmod close dup fchdir fstat gnulib-i18n langinfo-h libgmp-mpq - localcharset localeinfo localename-unsafe-limited lock + localcharset localeinfo localename-unsafe-limited localtime lock mbrtoc32-regular mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo openat-die opendir pthread-h diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c index 89ce3b00fd0..4329dd16612 100644 --- a/lib-src/ntlib.c +++ b/lib-src/ntlib.c @@ -41,9 +41,6 @@ #define DEFER_MS_W32_H #include <nl_types.h> #include <langinfo.h> #include <tzsanitize.h> -#ifdef localtime -# undef localtime -#endif #include "ntlib.h" @@ -603,11 +600,3 @@ nl_langinfo (nl_item item) return (char *) ""; } } - -/* Gnulib forcibly redirects 'localtime' to this. */ -struct tm * -rpl_localtime (const time_t *tp) -{ - tzsanitize (); - return localtime (tp); -} diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 0f90b5628c1..077f5c1fb62 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -53,6 +53,7 @@ # --avoid=localcharset \ # --avoid=localeinfo \ # --avoid=localename-unsafe-limited \ +# --avoid=localtime \ # --avoid=lock \ # --avoid=mbrtoc32-regular \ # --avoid=mbsinit \ @@ -329,7 +330,6 @@ GL_COND_OBJ_GETRANDOM_CONDITION = @GL_COND_OBJ_GETRANDOM_CONDITION@ GL_COND_OBJ_GETTIMEOFDAY_CONDITION = @GL_COND_OBJ_GETTIMEOFDAY_CONDITION@ GL_COND_OBJ_GROUP_MEMBER_CONDITION = @GL_COND_OBJ_GROUP_MEMBER_CONDITION@ GL_COND_OBJ_LCHMOD_CONDITION = @GL_COND_OBJ_LCHMOD_CONDITION@ -GL_COND_OBJ_LOCALTIME_CONDITION = @GL_COND_OBJ_LOCALTIME_CONDITION@ GL_COND_OBJ_LSTAT_CONDITION = @GL_COND_OBJ_LSTAT_CONDITION@ GL_COND_OBJ_MEMPCPY_CONDITION = @GL_COND_OBJ_MEMPCPY_CONDITION@ GL_COND_OBJ_MEMRCHR_CONDITION = @GL_COND_OBJ_MEMRCHR_CONDITION@ @@ -1534,7 +1534,6 @@ gl_GNULIB_ENABLED_getgroups_CONDITION = @gl_GNULIB_ENABLED_getgroups_CONDITION@ gl_GNULIB_ENABLED_issymlink_CONDITION = @gl_GNULIB_ENABLED_issymlink_CONDITION@ gl_GNULIB_ENABLED_issymlinkat_CONDITION = @gl_GNULIB_ENABLED_issymlinkat_CONDITION@ gl_GNULIB_ENABLED_lchmod_CONDITION = @gl_GNULIB_ENABLED_lchmod_CONDITION@ -gl_GNULIB_ENABLED_localtime_CONDITION = @gl_GNULIB_ENABLED_localtime_CONDITION@ gl_GNULIB_ENABLED_open_CONDITION = @gl_GNULIB_ENABLED_open_CONDITION@ gl_GNULIB_ENABLED_rawmemchr_CONDITION = @gl_GNULIB_ENABLED_rawmemchr_CONDITION@ gl_GNULIB_ENABLED_stdc_memreverse8u_CONDITION = @gl_GNULIB_ENABLED_stdc_memreverse8u_CONDITION@ @@ -2783,18 +2782,6 @@ EXTRA_DIST += limits.in.h endif ## end gnulib module limits-h -## begin gnulib module localtime -ifeq (,$(OMIT_GNULIB_MODULE_localtime)) - -ifneq (,$(gl_GNULIB_ENABLED_localtime_CONDITION)) -ifneq (,$(GL_COND_OBJ_LOCALTIME_CONDITION)) -libgnu_a_SOURCES += localtime.c -endif - -endif -endif -## end gnulib module localtime - ## begin gnulib module lstat ifeq (,$(OMIT_GNULIB_MODULE_lstat)) diff --git a/lib/localtime.c b/lib/localtime.c deleted file mode 100644 index 1af75963bde..00000000000 --- a/lib/localtime.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Work around platform bugs in localtime. - Copyright (C) 2017-2026 Free Software Foundation, Inc. - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <time.h> - -#include "tzsanitize.h" - -#undef localtime - -struct tm * -rpl_localtime (const time_t *tp) -{ -#if defined _WIN32 && ! defined __CYGWIN__ - tzsanitize (); -#endif - - return localtime (tp); -} diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 9ddcae9b821..13efb82bdd2 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -142,7 +142,6 @@ AC_DEFUN # Code from module libgmp: # Code from module libgmp-mpz: # Code from module limits-h: - # Code from module localtime: # Code from module lstat: # Code from module malloc-gnu: # Code from module malloc-posix: @@ -728,7 +727,6 @@ AC_DEFUN gl_gnulib_enabled_issymlink=false gl_gnulib_enabled_issymlinkat=false gl_gnulib_enabled_lchmod=false - gl_gnulib_enabled_localtime=false gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_open=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false @@ -904,18 +902,6 @@ AC_DEFUN fi fi } - func_gl_gnulib_m4code_localtime () - { - if $gl_gnulib_enabled_localtime; then :; else - gl_FUNC_LOCALTIME - gl_CONDITIONAL([GL_COND_OBJ_LOCALTIME], [test $REPLACE_LOCALTIME = 1]) - gl_TIME_MODULE_INDICATOR([localtime]) - gl_gnulib_enabled_localtime=true - if test $REPLACE_LOCALTIME = 1; then - func_gl_gnulib_m4code_tzsanitize - fi - fi - } func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () { if $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then :; else @@ -1097,9 +1083,6 @@ AC_DEFUN if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then func_gl_gnulib_m4code_strtoll fi - if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then - func_gl_gnulib_m4code_localtime - fi if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 fi @@ -1129,7 +1112,6 @@ AC_DEFUN AM_CONDITIONAL([gl_GNULIB_ENABLED_issymlink], [$gl_gnulib_enabled_issymlink]) AM_CONDITIONAL([gl_GNULIB_ENABLED_issymlinkat], [$gl_gnulib_enabled_issymlinkat]) AM_CONDITIONAL([gl_GNULIB_ENABLED_lchmod], [$gl_gnulib_enabled_lchmod]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_localtime], [$gl_gnulib_enabled_localtime]) AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) @@ -1442,7 +1424,6 @@ AC_DEFUN lib/lchmod.c lib/libc-config.h lib/limits.in.h - lib/localtime.c lib/lstat.c lib/malloc.c lib/malloc/dynarray-skeleton.c @@ -1635,7 +1616,6 @@ AC_DEFUN m4/libgmp.m4 m4/limits-h.m4 m4/locale-en.m4 - m4/localtime.m4 m4/lstat.m4 m4/malloc.m4 m4/manywarnings-c++.m4 diff --git a/m4/localtime.m4 b/m4/localtime.m4 deleted file mode 100644 index 5b96cf960c3..00000000000 --- a/m4/localtime.m4 +++ /dev/null @@ -1,16 +0,0 @@ -# localtime.m4 -# serial 3 -dnl Copyright (C) 2017-2026 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl This file is offered as-is, without any warranty. - -AC_DEFUN([gl_FUNC_LOCALTIME], -[ - AC_REQUIRE([gl_TIME_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) - case "$host_os" in - mingw* | windows*) REPLACE_LOCALTIME=1 ;; - esac -]) diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk index fd551fb88c4..288c9b11209 100644 --- a/nt/gnulib-cfg.mk +++ b/nt/gnulib-cfg.mk @@ -60,7 +60,6 @@ OMIT_GNULIB_MODULE_futimens = OMIT_GNULIB_MODULE_issymlink = true OMIT_GNULIB_MODULE_issymlinkat = true OMIT_GNULIB_MODULE_lchmod = true -OMIT_GNULIB_MODULE_localtime = true OMIT_GNULIB_MODULE_malloc-gnu = true OMIT_GNULIB_MODULE_malloc-posix = true OMIT_GNULIB_MODULE_nanosleep = true diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h index f7e59c22abe..17df44aeda9 100644 --- a/nt/inc/ms-w32.h +++ b/nt/inc/ms-w32.h @@ -218,10 +218,6 @@ #define dup sys_dup #define dup2 sys_dup2 #define fopen sys_fopen #define link sys_link -/* Gnulib might redirect 'localtime' ahead of us. */ -#ifdef localtime -# undef localtime -#endif #define localtime sys_localtime /* We redirect 'read' below, after including io.h, see bug#73444. */ #define rename sys_rename diff --git a/src/w32.c b/src/w32.c index 905e3f8731d..2202f9728cd 100644 --- a/src/w32.c +++ b/src/w32.c @@ -10350,12 +10350,6 @@ sys_localtime (const time_t *t) return localtime (t); } -struct tm * -rpl_localtime (const time_t *t) -{ - return sys_localtime (t); -} - /* The Windows CRT implementation of 'clock' doesn't really return CPU time of the process (it returns the elapsed time since the process started), so we provide a better emulation here, if possible. */ -- 2.56.0
