Yury V. Zaytsev wrote: > > The AC_MSG_ERROR is useful to alert us of platforms with missing support. > > At this point, no known platform triggers this AC_MSG_ERROR. > > As I said in my first post, I would expect `gl_MOUNTLIST` to define > `gl_cv_list_mounted_fs` and let *me* decide whether to fail or not. > ... > The reason I asked is that an early version of Termux had to patch > `AC_MSG_ERROR` out of our build system, which I found odd. > > Only then did I realize that they had no other choice until they implemented > enough support to make the module work, even though *I* consider it an > optional feature. So again, I went to ask why this module fails > unconditionally for unsupported platforms.
In Gnulib, we intend to make sure that the user of a module does not have to deal with portability problems at all. The vast majority of the modules is designed like this. Only a few (such as 'flock') are not supported on all platforms; consider this the exception, not the rule. If a module is not yet ported: The 'mountlist' module aborts the configuration. Which is not developer-friendly, because it requires the developer to fiddle with a .m4 file and regenerate 'configure. > The documentation seems to support this expectation: > > https://www.gnu.org/software/gnulib/MODULES.html#module=mountlist > > Otherwise, `gl_CONDITIONAL` doesn't seem to make sense. This gl_CONDITIONAL produces a link error when the module is not ported. Which is also not developer-friendly. Instead, it's better to have an error message by the C compiler. This is what the attached patch does. It produces: gcc -DHAVE_CONFIG_H -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -Wall -g -O2 -MT mountlist.o -MD -MP -MF .deps/mountlist.Tpo -c -o mountlist.o ../../gllib/mountlist.c ../../gllib/mountlist.c: In function ‘read_file_system_list’: ../../gllib/mountlist.c:1288:3: error: #error "Please port gnulib mountlist.c to your platform!" 1288 | # error "Please port gnulib mountlist.c to your platform!" | ^~~~~ make[3]: *** [Makefile:2272: mountlist.o] Error 1 2025-03-21 Bruno Haible <br...@clisp.org> mountlist: Replace a configure-time error with a compile-time error. Reported by Yury V. Zaytsev <y...@shurup.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2025-03/msg00080.html>. * m4/mountlist.m4 (gl_MOUNTLIST): Instead of aborting the configuration, define MOUNTED_NOT_PORTED. * lib/mountlist.c (read_file_system_list): Err out if MOUNTED_NOT_PORTED is defined. * modules/mountlist (configure.ac, Makefile.am): Compile mountlist.c on all platforms.
>From ea4258f5d942c5fdd4f805ba7875ad6dee2654b0 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Fri, 21 Mar 2025 11:46:43 +0100 Subject: [PATCH] mountlist: Replace a configure-time error with a compile-time error. Reported by Yury V. Zaytsev <y...@shurup.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2025-03/msg00080.html>. * m4/mountlist.m4 (gl_MOUNTLIST): Instead of aborting the configuration, define MOUNTED_NOT_PORTED. * lib/mountlist.c (read_file_system_list): Err out if MOUNTED_NOT_PORTED is defined. * modules/mountlist (configure.ac, Makefile.am): Compile mountlist.c on all platforms. --- ChangeLog | 12 ++++++++++++ lib/mountlist.c | 6 +++++- m4/mountlist.m4 | 9 ++++----- modules/mountlist | 7 +------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d681ea6e2..6cd99afd0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2025-03-21 Bruno Haible <br...@clisp.org> + + mountlist: Replace a configure-time error with a compile-time error. + Reported by Yury V. Zaytsev <y...@shurup.com> in + <https://lists.gnu.org/archive/html/bug-gnulib/2025-03/msg00080.html>. + * m4/mountlist.m4 (gl_MOUNTLIST): Instead of aborting the configuration, + define MOUNTED_NOT_PORTED. + * lib/mountlist.c (read_file_system_list): Err out if MOUNTED_NOT_PORTED + is defined. + * modules/mountlist (configure.ac, Makefile.am): Compile mountlist.c on + all platforms. + 2025-03-21 Bruno Haible <br...@clisp.org> setlocale-null: Fix autoconf warning. diff --git a/lib/mountlist.c b/lib/mountlist.c index 2ed4b138ba..d52d4ffca7 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -1096,7 +1096,7 @@ read_file_system_list (bool need_fs_type) } #endif /* MOUNTED_INTERIX_STATVFS */ -#if defined _WIN32 && !defined __CYGWIN__ +#if defined _WIN32 && !defined __CYGWIN__ /* native Windows */ /* Don't assume that UNICODE is not defined. */ # undef GetDriveType # define GetDriveType GetDriveTypeA @@ -1287,6 +1287,10 @@ read_file_system_list (bool need_fs_type) } #endif +#if MOUNTED_NOT_PORTED +# error "Please port gnulib mountlist.c to your platform!" +#endif + *mtail = NULL; return mount_list; diff --git a/m4/mountlist.m4 b/m4/mountlist.m4 index 0b8e3f1da2..e7eac2e9ed 100644 --- a/m4/mountlist.m4 +++ b/m4/mountlist.m4 @@ -1,5 +1,5 @@ # mountlist.m4 -# serial 17 +# serial 18 dnl Copyright (C) 2002-2006, 2009-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -325,12 +325,11 @@ AC_DEFUN([gl_MOUNTLIST] fi if test -z "$ac_list_mounted_fs"; then - AC_MSG_ERROR([could not determine how to read list of mounted file systems]) - # FIXME -- no need to abort building the whole package - # Can't build mountlist.c or anything that needs its functions + AC_DEFINE([MOUNTED_NOT_PORTED], [1], + [Define if we don't know how to determine the list of mounted file systems.]) fi - if test $ac_list_mounted_fs = found; then + if test "$ac_list_mounted_fs" = found; then gl_cv_list_mounted_fs=yes else gl_cv_list_mounted_fs=no diff --git a/modules/mountlist b/modules/mountlist index 016ff2dd6f..b4acef36e6 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -20,15 +20,10 @@ xalloc configure.ac: gl_MOUNTLIST -gl_CONDITIONAL([GL_COND_OBJ_MOUNTLIST], [test $gl_cv_list_mounted_fs = yes]) -AM_COND_IF([GL_COND_OBJ_MOUNTLIST], [ - gl_PREREQ_MOUNTLIST_EXTRA -]) +gl_PREREQ_MOUNTLIST_EXTRA Makefile.am: -if GL_COND_OBJ_MOUNTLIST lib_SOURCES += mountlist.c -endif Include: "mountlist.h" -- 2.43.0