* [PATCH] wchar: avoid a linker error during configure on AIX
@ 2020-10-13 14:59 CHIGOT, CLEMENT
2020-10-18 21:06 ` Bruno Haible
0 siblings, 1 reply; 3+ messages in thread
From: CHIGOT, CLEMENT @ 2020-10-13 14:59 UTC (permalink / raw)
To: bug-gnulib@gnu.org
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Configure programs aiming to check if wchar.h uses 'inline' correctly
raises a linker error on AIX because there are redefining wcstod to an
undeclaration function. However, in the latest AIX version (at least
7.1.5 and after 7.2.3), wcstod() is used to declare a static function
directly in wchar.h. Thus, renamed_wcstod() must be defined.
* m4/wchar_t.m4 (gl_WCHAR_H_INLINE_OK): Add fake definiton of
renamed_wcstod for AIX.
Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France
[-- Attachment #2: 0001-wchar-avoid-a-linker-error-during-configure-on-AIX.patch --]
[-- Type: application/octet-stream, Size: 1302 bytes --]
From 14c8dc29e623649a5fa59cff7328136a72fe628f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 13 Oct 2020 16:39:43 +0200
Subject: [PATCH] wchar: avoid a linker error during configure on AIX
Configure programs aiming to check if wchar.h uses 'inline' correctly
raises a linker error on AIX because there are redefining wcstod to an
undeclaration function. However, in the latest AIX version (at least
7.1.5 and after 7.2.3), wcstod() is used to declare a static function
directly in wchar.h. Thus, renamed_wcstod() must be defined.
* m4/wchar_t.m4 (gl_WCHAR_H_INLINE_OK): Add fake definiton of
renamed_wcstod for AIX.
---
m4/wchar_h.m4 | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4
index 6c4e8a6c4..95478ce18 100644
--- a/m4/wchar_h.m4
+++ b/m4/wchar_h.m4
@@ -83,6 +83,12 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK],
#include <stdio.h>
#include <time.h>
#include <wchar.h>
+#ifdef _AIX
+/* On some AIX versions, wcstod() is used in <wchar.h> to define a static
+ function. Thus, redefining it to an unknown function raises a linker
+ error. */
+double renamed_wcstod (const wchar_t *nptr, wchar_t **endptr) { return 0; }
+#endif
extern int zero (void);
int main () { return zero(); }
]])])
--
2.25.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wchar: avoid a linker error during configure on AIX
2020-10-13 14:59 [PATCH] wchar: avoid a linker error during configure on AIX CHIGOT, CLEMENT
@ 2020-10-18 21:06 ` Bruno Haible
2020-10-19 6:53 ` CHIGOT, CLEMENT
0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2020-10-18 21:06 UTC (permalink / raw)
To: bug-gnulib; +Cc: CHIGOT, CLEMENT
Hi,
CHIGOT, CLEMENT wrote:
> Configure programs aiming to check if wchar.h uses 'inline' correctly
> raises a linker error on AIX because there are redefining wcstod to an
> undeclaration function. However, in the latest AIX version (at least
> 7.1.5 and after 7.2.3), wcstod() is used to declare a static function
> directly in wchar.h. Thus, renamed_wcstod() must be defined.
>
> * m4/wchar_t.m4 (gl_WCHAR_H_INLINE_OK): Add fake definiton of
> renamed_wcstod for AIX.
Thanks for the report.
I can't reproduce the problem on the AIX 7.1 and 7.2 systems I have
access to. Anyway...
Your patch is a workaround to a workaround. Worse, I can't verify that
your patch does not break the original workaround (on glibc systems of
around 2009). Therefore I find it better to just not execute the test
on AIX systems - and just reduce the amount of workarounds, not increase
them.
2020-10-18 Bruno Haible <bruno@clisp.org>
wchar: Fix configure test result on some versions of AIX.
Reported by Clément Chigot <clement.chigot@atos.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-10/msg00115.html>.
* m4/wchar_h.m4 (gl_WCHAR_H_INLINE_OK): Execute the test only on glibc
systems.
(diff -w)
diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4
index 6c4e8a6..08b7c86 100644
--- a/m4/wchar_h.m4
+++ b/m4/wchar_h.m4
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
dnl Written by Eric Blake.
-# wchar_h.m4 serial 46
+# wchar_h.m4 serial 47
AC_DEFUN([gl_WCHAR_H],
[
@@ -70,9 +70,12 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK],
dnl and <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
[gl_cv_header_wchar_h_correct_inline],
[gl_cv_header_wchar_h_correct_inline=yes
+ case "$host_os" in
+ *-gnu* | gnu*)
AC_LANG_CONFTEST([
AC_LANG_SOURCE([[#define wcstod renamed_wcstod
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
@@ -93,8 +96,8 @@ int main () { return zero(); }
dnl that the object file has the latter name from the start.
save_ac_compile="$ac_compile"
ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/`
- if echo '#include "conftest.c"' >conftest1.c &&
- AC_TRY_EVAL([ac_compile]); then
+ if echo '#include "conftest.c"' >conftest1.c \
+ && AC_TRY_EVAL([ac_compile]); then
AC_LANG_CONFTEST([
AC_LANG_SOURCE([[#define wcstod renamed_wcstod
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
@@ -109,8 +112,8 @@ int zero (void) { return 0; }
]])])
dnl See note above about renaming object files.
ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/`
- if echo '#include "conftest.c"' >conftest2.c &&
- AC_TRY_EVAL([ac_compile]); then
+ if echo '#include "conftest.c"' >conftest2.c \
+ && AC_TRY_EVAL([ac_compile]); then
if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
:
else
@@ -120,6 +123,8 @@ int zero (void) { return 0; }
fi
ac_compile="$save_ac_compile"
rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext
+ ;;
+ esac
])
if test $gl_cv_header_wchar_h_correct_inline = no; then
AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wchar: avoid a linker error during configure on AIX
2020-10-18 21:06 ` Bruno Haible
@ 2020-10-19 6:53 ` CHIGOT, CLEMENT
0 siblings, 0 replies; 3+ messages in thread
From: CHIGOT, CLEMENT @ 2020-10-19 6:53 UTC (permalink / raw)
To: Bruno Haible, bug-gnulib@gnu.org
Hi
> I can't reproduce the problem on the AIX 7.1 and 7.2 systems I have
> access to. Anyway...
> Your patch is a workaround to a workaround. Worse, I can't verify that
> your patch does not break the original workaround (on glibc systems of
> around 2009). Therefore I find it better to just not execute the test
> on AIX systems - and just reduce the amount of workarounds, not increase
> them.
I know that it doesn't appear with -O2, so maybe if you're using XLC
instead of GCC (which I used to discover this bug), it might not reproduce.
Anyway, I agree with you.
Thanks for the patch
Clément
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-19 6:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 14:59 [PATCH] wchar: avoid a linker error during configure on AIX CHIGOT, CLEMENT
2020-10-18 21:06 ` Bruno Haible
2020-10-19 6:53 ` CHIGOT, CLEMENT
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).