ftbfs with -O2 using gcc's builtin gettext

Bug #1110476 reported by Fathi Boudra
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linaro GRUB
Confirmed
Undecided
Leif Lindholm

Bug Description

building with -O2 enables the use of gcc's builtin gettext

gcc -DHAVE_CONFIG_H -I. -Wall -W -I./include -DGRUB_UTIL=1 -DGRUB_LIBDIR=\"/usr/lib/grub\" -DLOCALEDIR=\"/usr/share/locale\" -DGRUB_FILE=\"grub-core/lib/libgcrypt-grub/cipher/arcfour.c\" -I. -I. -I. -I. -I./include -I./include -I./grub-core/lib/libgcrypt-grub/include -I./grub-core/lib/libgcrypt-grub/src/ -I./grub-core/lib/libgcrypt_wrap -I./grub-core/lib/posix_wrap -D_GCRYPT_IN_LIBGCRYPT=1 -I./include/grub/gcrypt -g -Wall -O2 -Wno-error=unused-result -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -Werror -Wno-error -Wno-missing-field-initializers -fno-builtin -c -o grub-core/lib/libgcrypt-grub/cipher/libgrubgcry_a-arcfour.o `test -f 'grub-core/lib/libgcrypt-grub/cipher/arcfour.c' || echo './'`grub-core/lib/libgcrypt-grub/cipher/arcfour.c
In file included from ./include/grub/misc.h:27:0,
                 from ./grub-core/lib/libgcrypt_wrap/cipher_wrap.h:24,
                 from grub-core/lib/libgcrypt-grub/cipher/types.h:2,
                 from grub-core/lib/libgcrypt-grub/cipher/arcfour.c:30:
./include/grub/i18n.h: In function '_':
./include/grub/i18n.h:56:10: error: 'LC_MESSAGES' undeclared (first use in this function)
./include/grub/i18n.h:56:10: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [grub-core/lib/libgcrypt-grub/cipher/libgrubgcry_a-arcfour.o] Error 1
make[3]: Leaving directory `/build/buildd/linaro-grub-2.00+bzr4617+20130130'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/build/buildd/linaro-grub-2.00+bzr4617+20130130'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/build/buildd/linaro-grub-2.00+bzr4617+20130130'

Fathi Boudra (fboudra)
Changed in linaro-grub:
status: New → Confirmed
assignee: nobody → Leif Lindholm (leif-lindholm)
milestone: none → 13.02
Revision history for this message
Leif Lindholm (leif-lindholm) wrote :

Upstream commit #4635 (2013-01-11) included a source code change that, through a chain of events, triggers GCC-4.6.3-1ubuntu5 to override a locally provided "gettext()" function with a builtin alternative with a different prototype (including a requirement for an LC_MESSAGES define). This behaviour is triggered only when an optimization level is explicitly specified in the CFLAGS - and appears unaffected by -fno-builtins.

Workaround is to remove -O2 from build environment CFLAGS.
Solution is being investigated.

Also reproduced on amd64 with the same GCC version - where the build triggers additional errors not seen on ARM.

Revision history for this message
Leif Lindholm (leif-lindholm) wrote :

The culprit is (system-wide) libintl.h which contains macros replacing gettext when optimizing:

/* Optimized version of the function above. */
#if defined __OPTIMIZE__ && !defined __cplusplus

/* We need NULL for `gettext'. */
# define __need_NULL
# include <stddef.h>

/* We need LC_MESSAGES for `dgettext'. */
# include <locale.h>

/* These must be macros. Inlined functions are useless because the
   `__builtin_constant_p' predicate in dcgettext would always return
   false. */

# define gettext(msgid) dgettext (NULL, msgid)

# define dgettext(domainname, msgid) \
  dcgettext (domainname, msgid, LC_MESSAGES)

# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n)

# define dngettext(domainname, msgid1, msgid2, n) \
  dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES)

#endif /* Optimizing. */

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.