* [patch] Failed to build mips64-elf with NLS on OSX
@ 2006-06-15 8:12 Masaki Muranaka
2006-06-15 8:22 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Masaki Muranaka @ 2006-06-15 8:12 UTC (permalink / raw)
To: gdb-patches
Hello,
On mainline, it's failed to compile with a lot of
warnings like
: format not a string literal, argument types not checked
: format not a string literal and no format arguments
In case building with NLS, _("string") was expanded to
gettext("string"), not literal.
The patch is to suppress -Wformat-nonliteral
when you build with NLS.
My environment is OSX (gcc version 4.0.1), configuration
is --target=mips64-elf. I've not tested yet but I guess
it occurs on the another host and target.
- - - - - - - - - - -
2006-06-15 Masaki Muranaka <monaka@monami-software.com>
* configure.ac: Remove -Wformat-nonliteral
if USE_NLS = yes
* configure: regenerate.
- - - - - - - - - - -
Index: configure
===================================================================
RCS file: /cvs/src/src/gdb/configure,v
retrieving revision 1.212
diff -u -p -r1.212 configure
--- configure 31 May 2006 15:14:36 -0000 1.212
+++ configure 15 Jun 2006 08:05:55 -0000
@@ -20277,8 +20277,11 @@ fi
# NOTE: If you add to this list, remember to update
# gdb/doc/gdbint.texinfo.
build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
--Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral \
+-Wformat -Wparentheses -Wpointer-arith \
-Wunused-label -Wunused-function -Wno-pointer-sign"
+if test x"$USE_NLS" != xyes; then
+ build_warnings="$build_warnings -Wformat-nonliteral"
+fi
# GCC supports -Wuninitialized only with -O or -On, n != 0.
if test x${CFLAGS+set} = xset; then
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.33
diff -u -p -r1.33 configure.ac
--- configure.ac 31 May 2006 15:14:37 -0000 1.33
+++ configure.ac 15 Jun 2006 08:05:56 -0000
@@ -1104,8 +1104,11 @@ fi
# NOTE: If you add to this list, remember to update
# gdb/doc/gdbint.texinfo.
build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
--Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral \
+-Wformat -Wparentheses -Wpointer-arith \
-Wunused-label -Wunused-function -Wno-pointer-sign"
+if test x"$USE_NLS" != xyes; then
+ build_warnings="$build_warnings -Wformat-nonliteral"
+fi
# GCC supports -Wuninitialized only with -O or -On, n != 0.
if test x${CFLAGS+set} = xset; then
--
Masaki Muranaka
Monami software
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 8:12 [patch] Failed to build mips64-elf with NLS on OSX Masaki Muranaka
@ 2006-06-15 8:22 ` Andreas Schwab
2006-06-15 9:12 ` Masaki Muranaka
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2006-06-15 8:22 UTC (permalink / raw)
To: Masaki Muranaka; +Cc: gdb-patches
Masaki Muranaka <monaka@monami-software.com> writes:
> Hello,
>
> On mainline, it's failed to compile with a lot of
> warnings like
> : format not a string literal, argument types not checked
> : format not a string literal and no format arguments
>
>
> In case building with NLS, _("string") was expanded to
> gettext("string"), not literal.
GCC should recognize gettext specially in the context of format string
tests.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 8:22 ` Andreas Schwab
@ 2006-06-15 9:12 ` Masaki Muranaka
2006-06-15 9:24 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Masaki Muranaka @ 2006-06-15 9:12 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches
On 2006/06/15, at 17:22, Andreas Schwab wrote:
> GCC should recognize gettext specially in the context of format string
> tests.
Regardless GCC should work so, the build was failed.
This is a sample script that reproduce the error.
I tested on gcc-4.0.1/OSX and gcc-3.2.2/Linux.
Results are same.
-8<----8<----8<----8<----8<----8<---
cat <<__EOF > test.c
#include <stdio.h>
# define _(String) gettext (String)
int
main(int argc, char **argv)
{
printf(_("aaa"));
}
__EOF
gcc -Werror -Wformat -Wformat-nonliteral -c test.c
-8<----8<----8<----8<----8<----8<---
--
Masaki Muranaka
Monami software
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 9:12 ` Masaki Muranaka
@ 2006-06-15 9:24 ` Andreas Schwab
2006-06-15 10:04 ` Masaki Muranaka
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2006-06-15 9:24 UTC (permalink / raw)
To: Masaki Muranaka; +Cc: gdb-patches
Masaki Muranaka <monaka@monami-software.com> writes:
> On 2006/06/15, at 17:22, Andreas Schwab wrote:
>> GCC should recognize gettext specially in the context of format string
>> tests.
>
> Regardless GCC should work so, the build was failed.
GCC _does_ work so.
> This is a sample script that reproduce the error.
> I tested on gcc-4.0.1/OSX and gcc-3.2.2/Linux.
> Results are same.
>
> -8<----8<----8<----8<----8<----8<---
> cat <<__EOF > test.c
> #include <stdio.h>
>
> # define _(String) gettext (String)
>
> int
> main(int argc, char **argv)
> {
> printf(_("aaa"));
> }
> __EOF
> gcc -Werror -Wformat -Wformat-nonliteral -c test.c
> -8<----8<----8<----8<----8<----8<---
This is not a valid testcase since gettext is not declared.
I cannot reproduce the problem with any gcc version, once the missing
declaration is added.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 9:24 ` Andreas Schwab
@ 2006-06-15 10:04 ` Masaki Muranaka
2006-06-15 11:34 ` Masaki Muranaka
0 siblings, 1 reply; 8+ messages in thread
From: Masaki Muranaka @ 2006-06-15 10:04 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches
On 2006/06/15, at 18:24, Andreas Schwab wrote:
> GCC _does_ work so.
After sent the previous mail, I've built GDB on my Linux box.
The build was succeeded without my patch.
So I believe you are right.
Then, I confused why the build was failed on OSX.
The use of intl/ is a one of the configuration diffence
between my Linux host and my OSX one.
In my Linux box, Gettext has installed. so intl/libintl.h
is not generated.
How do you think possibilities about bugs in intl/ causes
the build failed?
The cpp'ed code under OSX is like this:
internal_error ("../../src/gdb/mips-tdep.c", 273, libintl_gettext
("bad switch"));
And the definition of internal_error is like this:
extern void internal_error ( char *file, int line,
char *, ...) __attribute__
((noreturn)) __attribute__ ((format(printf, 3, 4)));
--
Masaki Muranaka
Monami software
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 10:04 ` Masaki Muranaka
@ 2006-06-15 11:34 ` Masaki Muranaka
2006-06-15 13:51 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Masaki Muranaka @ 2006-06-15 11:34 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches
Still I was confused, but I see somehow.
On 2006/06/15, at 19:04, Masaki Muranaka wrote:
> internal_error ("../../src/gdb/mips-tdep.c", 273, libintl_gettext
> ("bad switch"));
As Schwab says, dgettext/gettext was regarded as constant by gcc.
The information was put on gcc/builtin.def.
So there is no troubles on some targets which expands _() to dgettext().
I checked the code generated on Linux. _() was expanded to
dgettext().
But the another target which expands _() to libintl_gettext(),
the build will be failed. Because there is no information
about libintl_gettext() in builtin.def.
The code which is generated on MacOSX was so.
If my understanding is reasonable, -Wformat-nonliteral
should be off in case GDB is built with intl/, right?
(Fixing GCC or intl is also not impossible, but I don't want to)
--
Masaki Muranaka
Monami software
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 11:34 ` Masaki Muranaka
@ 2006-06-15 13:51 ` Daniel Jacobowitz
2006-06-16 0:42 ` Masaki Muranaka
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2006-06-15 13:51 UTC (permalink / raw)
To: Masaki Muranaka; +Cc: Andreas Schwab, gdb-patches
On Thu, Jun 15, 2006 at 08:34:06PM +0900, Masaki Muranaka wrote:
>
> Still I was confused, but I see somehow.
>
> On 2006/06/15, at 19:04, Masaki Muranaka wrote:
> >internal_error ("../../src/gdb/mips-tdep.c", 273, libintl_gettext
> >("bad switch"));
>
> As Schwab says, dgettext/gettext was regarded as constant by gcc.
> The information was put on gcc/builtin.def.
> So there is no troubles on some targets which expands _() to dgettext().
> I checked the code generated on Linux. _() was expanded to
> dgettext().
>
> But the another target which expands _() to libintl_gettext(),
> the build will be failed. Because there is no information
> about libintl_gettext() in builtin.def.
> The code which is generated on MacOSX was so.
>
> If my understanding is reasonable, -Wformat-nonliteral
> should be off in case GDB is built with intl/, right?
> (Fixing GCC or intl is also not impossible, but I don't want to)
But it's right :-)
char *libintl_gettext (const char *) __attribute__((format_arg(1)));
That's enough to fix it. The example in the manual is even a dgettext
wrapper. It looks like it's been there since ~ 2001. There's already
a GNUC version check in libgnuintl.h; adding another one with the
appropriate version ought to fix this.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] Failed to build mips64-elf with NLS on OSX
2006-06-15 13:51 ` Daniel Jacobowitz
@ 2006-06-16 0:42 ` Masaki Muranaka
0 siblings, 0 replies; 8+ messages in thread
From: Masaki Muranaka @ 2006-06-16 0:42 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Andreas Schwab, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 513 bytes --]
On 2006/06/15, at 22:51, Daniel Jacobowitz wrote:
> But it's right :-)
>
> char *libintl_gettext (const char *) __attribute__((format_arg(1)));
>
> That's enough to fix it.
Thanks for your comment.
It's shut up the warinings to add the attribute.
An attached file is the patch I was applied.
For MacOSX, it's enough to modify at libgnuintl.h:line 128.
And I guess it should be applied line 119, too.
Then, what should I do to request for apply?
Need to post to gcc-bugs?
--
Masaki Muranaka
Monami software
[-- Attachment #2: libgnuintl.h.diff --]
[-- Type: application/octet-stream, Size: 1003 bytes --]
Index: libgnuintl.h
===================================================================
RCS file: /cvs/src/src/intl/libgnuintl.h,v
retrieving revision 1.1
diff -u -p -r1.1 libgnuintl.h
--- libgnuintl.h 22 May 2006 15:30:13 -0000 1.1
+++ libgnuintl.h 16 Jun 2006 00:40:02 -0000
@@ -116,7 +116,7 @@ extern "C" {
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_gettext (const char *__msgid);
+extern char *libintl_gettext (const char *__msgid) __attribute__((format_arg(1)));
static inline char *gettext (const char *__msgid)
{
return libintl_gettext (__msgid);
@@ -126,7 +126,7 @@ static inline char *gettext (const char
# define gettext libintl_gettext
#endif
extern char *gettext _INTL_PARAMS ((const char *__msgid))
- _INTL_ASM (libintl_gettext);
+ _INTL_ASM (libintl_gettext) __attribute__((format_arg(1)));
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-06-16 0:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-15 8:12 [patch] Failed to build mips64-elf with NLS on OSX Masaki Muranaka
2006-06-15 8:22 ` Andreas Schwab
2006-06-15 9:12 ` Masaki Muranaka
2006-06-15 9:24 ` Andreas Schwab
2006-06-15 10:04 ` Masaki Muranaka
2006-06-15 11:34 ` Masaki Muranaka
2006-06-15 13:51 ` Daniel Jacobowitz
2006-06-16 0:42 ` Masaki Muranaka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox