bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

localename: Fix link error with module duplocale on AIX 7.2


From: Bruno Haible
Subject: localename: Fix link error with module duplocale on AIX 7.2
Date: Thu, 07 Jan 2021 23:00:53 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; )

In a testdir that contains the modules 'duplocale' and 'localename',
I get a link error on AIX 7.2:

xlc -qthreaded -qtls  -g  -L/home/haible/prefix32/lib -o test-duplocale 
test-duplocale.o libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a 
libtests.a  -lpthread -lpthread -lm  -lm -lm -lm -lm -lm -lm -lm -lm -lm
ld: 0711-317 ERROR: Undefined symbol: .rpl_newlocale
ld: 0711-317 ERROR: Undefined symbol: .rpl_freelocale
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make: 1254-004 The error code from the last command is 8.

The cause is that the conditions in the shell code and the conditions in the
config.h and localename.c files have diverged over time, in particular with the
2019-12-18 patch.

This patch fixes it, by doing more of the condition logic in .m4 files and
less in localename.c.


2021-01-07  Bruno Haible  <bruno@clisp.org>

        localename: Fix link error with duplocale on AIX 7.2 (regr. 2019-12-18).
        * m4/locale_h.m4 (gl_LOCALE_H_DEFAULTS): Initialize
        LOCALENAME_ENHANCE_LOCALE_FUNCS.
        * m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE):
        Set gt_working_uselocale.
        (gt_INTL_THREAD_LOCALE_NAME): Set gt_fake_locales, gt_good_uselocale,
        gt_localename_enhances_locale_funcs, LOCALENAME_ENHANCE_LOCALE_FUNCS.
        Define HAVE_GOOD_USELOCALE, LOCALENAME_ENHANCE_LOCALE_FUNCS.
        * m4/localename.m4 (gl_LOCALENAME): Test
        gt_localename_enhances_locale_funcs instead of gt_nameless_locales.
        * modules/locale (Makefile.am): Substitute
        LOCALENAME_ENHANCE_LOCALE_FUNCS.
        * lib/locale.in.h (newlocale, duplocale, freelocale): Don't override if
        module 'localename' is in use but LOCALENAME_ENHANCE_LOCALE_FUNCS is 0.
        * lib/localename.c (HAVE_GOOD_USELOCALE): Don't define here.
        (get_locale_t_name, newlocale, duplocale, freelocale): Define if
        LOCALENAME_ENHANCE_LOCALE_FUNCS.

diff --git a/lib/locale.in.h b/lib/locale.in.h
index df84747..13d1cf2 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -211,7 +211,7 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on 
native Windows - "
 # include "setlocale_null.h"
 #endif
 
-#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@)
+#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && 
@LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@)
 # if @REPLACE_NEWLOCALE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef newlocale
@@ -244,7 +244,7 @@ _GL_WARN_ON_USE (newlocale, "newlocale is not portable");
 # endif
 #endif
 
-#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@)
+#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && 
@LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@)
 # if @REPLACE_DUPLOCALE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef duplocale
@@ -274,7 +274,7 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some 
glibc systems - "
 # endif
 #endif
 
-#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@)
+#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && 
@LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@)
 # if @REPLACE_FREELOCALE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef freelocale
diff --git a/lib/localename.c b/lib/localename.c
index 4c785f1..0e63da4 100644
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -38,12 +38,6 @@
 #include "setlocale_null.h"
 #include "thread-optim.h"
 
-/* We cannot support uselocale() on platforms where the locale_t type is fake.
-   See intl-thread-locale.m4 for details.  */
-#if HAVE_WORKING_USELOCALE && !HAVE_FAKE_LOCALES
-# define HAVE_GOOD_USELOCALE 1
-#endif
-
 #if HAVE_GOOD_USELOCALE
 /* Mac OS X 10.5 defines the locale_t type in <xlocale.h>.  */
 # if defined __APPLE__ && defined __MACH__
@@ -2726,7 +2720,7 @@ struniq (const char *string)
 #endif
 
 
-#if HAVE_GOOD_USELOCALE && HAVE_NAMELESS_LOCALES
+#if LOCALENAME_ENHANCE_LOCALE_FUNCS
 
 /* The 'locale_t' object does not contain the names of the locale categories.
    We have to associate them with the object through a hash table.
diff --git a/m4/intl-thread-locale.m4 b/m4/intl-thread-locale.m4
index 65ac371..890fec0 100644
--- a/m4/intl-thread-locale.m4
+++ b/m4/intl-thread-locale.m4
@@ -1,4 +1,4 @@
-# intl-thread-locale.m4 serial 8
+# intl-thread-locale.m4 serial 9
 dnl Copyright (C) 2015-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -72,9 +72,13 @@ int main ()
   esac
   case "$gt_cv_locale_fake" in
     *yes)
+      gt_fake_locales=yes
       AC_DEFINE([HAVE_FAKE_LOCALES], [1],
         [Define if the locale_t type contains insufficient information, as on 
OpenBSD.])
       ;;
+    *)
+      gt_fake_locales=no
+      ;;
   esac
 
   case "$gt_cv_func_uselocale_works" in
@@ -133,10 +137,33 @@ int main ()
         [Define if the locale_t type does not contain the name of each locale 
category.])
       ;;
   esac
+
+  dnl We cannot support uselocale() on platforms where the locale_t type is
+  dnl fake.  So, set
+  dnl   gt_good_uselocale = gt_working_uselocale && !gt_fake_locales.
+  if test $gt_working_uselocale = yes && test $gt_fake_locales = no; then
+    gt_good_uselocale=yes
+    AC_DEFINE([HAVE_GOOD_USELOCALE], [1],
+      [Define if the uselocale exists, may be safely called, and returns 
sufficient information.])
+  else
+    gt_good_uselocale=no
+  fi
+
+  dnl Set gt_localename_enhances_locale_funcs to indicate whether localename.c
+  dnl overrides newlocale(), duplocale(), freelocale() to keep track of locale
+  dnl names.
+  if test $gt_good_uselocale = yes && test $gt_nameless_locales = yes; then
+    gt_localename_enhances_locale_funcs=yes
+    LOCALENAME_ENHANCE_LOCALE_FUNCS=1
+    AC_DEFINE([LOCALENAME_ENHANCE_LOCALE_FUNCS], [1],
+      [Define if localename.c overrides newlocale(), duplocale(), 
freelocale().])
+  else
+    gt_localename_enhances_locale_funcs=no
+  fi
 ])
 
 dnl Tests whether uselocale() exists and is usable.
-dnl Sets gt_cv_func_uselocale_works. Defines HAVE_WORKING_USELOCALE.
+dnl Sets gt_working_uselocale and defines HAVE_WORKING_USELOCALE.
 AC_DEFUN([gt_FUNC_USELOCALE],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -181,8 +208,12 @@ int main ()
   fi
   case "$gt_cv_func_uselocale_works" in
     *yes)
+      gt_working_uselocale=yes
       AC_DEFINE([HAVE_WORKING_USELOCALE], [1],
-        [Define if the uselocale function exists any may safely be called.])
+        [Define if the uselocale function exists and may safely be called.])
+      ;;
+    *)
+      gt_working_uselocale=no
       ;;
   esac
 ])
diff --git a/m4/locale_h.m4 b/m4/locale_h.m4
index a95379a..7b50aa7 100644
--- a/m4/locale_h.m4
+++ b/m4/locale_h.m4
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 24
+# locale_h.m4 serial 25
 dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -155,4 +155,5 @@ AC_DEFUN([gl_LOCALE_H_DEFAULTS],
   REPLACE_DUPLOCALE=0;    AC_SUBST([REPLACE_DUPLOCALE])
   REPLACE_FREELOCALE=0;   AC_SUBST([REPLACE_FREELOCALE])
   REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
+  LOCALENAME_ENHANCE_LOCALE_FUNCS=0; 
AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
 ])
diff --git a/m4/localename.m4 b/m4/localename.m4
index 5c1ea0e..2bff33d 100644
--- a/m4/localename.m4
+++ b/m4/localename.m4
@@ -1,4 +1,4 @@
-# localename.m4 serial 7
+# localename.m4 serial 8
 dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,7 +33,7 @@ AC_DEFUN([gl_LOCALENAME],
   if test $gl_func_freelocale != yes; then
     HAVE_FREELOCALE=0
   fi
-  if test $gt_nameless_locales = yes; then
+  if test $gt_localename_enhances_locale_funcs = yes; then
     REPLACE_NEWLOCALE=1
     REPLACE_DUPLOCALE=1
     REPLACE_FREELOCALE=1
diff --git a/modules/locale b/modules/locale
index aac463c..cd045c3 100644
--- a/modules/locale
+++ b/modules/locale
@@ -44,6 +44,7 @@ locale.h: locale.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
              -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
              -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
+             -e 
's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]