Trunk fails to build with -O<anything other than 0>
Our Ubuntu (12.04/12.10) build environment defaults configuring with CFLAGS containing -O2. Trunk currently does not build successfully with this on either my ARM platform or my x86_64 desktop.
This isn't causing any serious problems, but I thought I would report what I've found.
Commit #4635 included source code changes that ended up causing build
failures in several of the libcrypt cipher files with
---
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
---
when building the utils.
This occurs with any -O level other than -O0.
I traced the culprit down to the (system) libintl.h, which has a cute
little section which checks if __OPTIMIZE__ is set, and if so redefines gettext() as a macro for dcgettext (domainname, msgid, LC_MESSAGES).
Since this is all preprocessor driven in the C library headers, -fno-builtin has no effect.
Also, when building on my x86_64 workstation only, I get a failure when
compiling grub-core/lib/crypto.c - due to (system) fgets() ending up with a warn-unused-result prototype when building with optimizations.
And, also on my workstation only, util/ieee1275/ofpath.c (system) read() fails due to warn-unused-results, just like fgets() above.
All but one of these issues "go away" with -U__OPTIMIZE__ :grub-core/lib/libgcrypt-grub/cipher/rijndael.c gives a few screenfuls
of warnings anyway, and only builds successfully when -O2 is removed from the build command line (or -O0 is appended).
Regards,
Leif
В Wed, 30 Jan 2013 18:32:39 +0000
Leif Lindholm <[email protected]> пишет:
Quoted 39 lines
Our Ubuntu (12.04/12.10) build environment defaults configuring with CFLAGS containing -O2. Trunk currently does not build successfully with this on either my ARM platform or my
x86_64desktop.This isn't causing any serious problems, but I thought I would report what I've found.
Commit #4635 included source code changes that ended up causing build failures in several of the libcrypt cipher files with
---
libgrubgcry_a-arcfour.otest -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, fromgrub-core/lib/libgcrypt-grub/cipher/types.h:2, fromgrub-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
---
when building the utils.This occurs with any -O level other than -O0.
I traced the culprit down to the (system)
libintl.h, which has a cute little section which checks if__OPTIMIZE__is set, and if so redefinesgettext()as a macro for dcgettext (domainname, msgid,LC_MESSAGES). Since this is all preprocessor driven in the C library headers, -fno-builtin has no effect.Also, when building on my
x86_64workstation only, I get a failure when compilinggrub-core/lib/crypto.c- due to (system)fgets()ending up with a warn-unused-result prototype when building with optimizations.
Quoted 8 lines
And, also on my workstation only,
util/ieee1275/ofpath.c(system)read()fails due to warn-unused-results, just likefgets()above.All but one of these issues "go away" with -U__OPTIMIZE__ :
grub-core/lib/libgcrypt-grub/cipher/rijndael.cgives a few screenfuls of warnings anyway, and only builds successfully when -O2 is removed from the build command line (or -O0 is appended).
I wonder why it did not happen before. Apparently, empty locale.h is present since 2010-04-10 (rev 2311). Removing it fixes the problem, but I presume it should not be empty in the first place.
From: Andrey Borzenkov <[email protected]>
Subject: [PATCH] remove stray locale.h
Empty locale.h caused compilation errors.
--- po/POTFILES.in | 1 - 1 file changed, 1 deletion(-)
grub-core/lib/posix_wrap/locale.h deleted +0 -0
po/POTFILES.in +0 -1
@@ -443,7 +443,6 @@ ./grub-core/lib/posix_wrap/langinfo.h ./grub-core/lib/posix_wrap/limits.h ./grub-core/lib/posix_wrap/localcharset.h -./grub-core/lib/posix_wrap/locale.h ./grub-core/lib/posix_wrap/stdint.h ./grub-core/lib/posix_wrap/stdio.h ./grub-core/lib/posix_wrap/stdlib.h
Signature · 1 line
tg: (4b9ea2e..) u/locale.h (depends on: master)
Quoted 10 lines · Andrey Borzenkov
В Wed, 30 Jan 2013 18:32:39 +0000
Leif Lindholm <[email protected]> пишет:Quoted 3 lines
Our Ubuntu (12.04/12.10) build environment defaults configuring with CFLAGS containing -O2. Trunk currently does not build successfully with this on either my ARM platform or my
x86_64desktop.I wonder why it did not happen before. Apparently, empty
locale.his present since 2010-04-10 (rev 2311). Removing it fixes the problem, but I presume it should not be empty in the first place.
Thank you - I can confirm that this resolves the "gettext" portion of my issue.
Combined with the below (not suggested as a patch, simply to display the issue clearly), trunk now builds with -O2 again.
Regards,
Leif
=== modified file 'grub-core/lib/crypto.c'
lib/crypto.c 2013-01-31 13:41:36 +0000 renamed from lib/crypto.c 2013-01-11 20:32:42 +0000 +2 -1
@@ -461,7 +461,8 @@ } else tty_changed = 0; - fgets (buf, buf_size, stdin); + if (fgets (buf, buf_size, stdin) == NULL) + return 0; ptr = buf + strlen (buf) - 1; while (buf <= ptr && (*ptr == '\n' || *ptr == '\r')) *ptr-- = 0;
=== modified file 'util/ieee1275/ofpath.c'
ieee1275/ofpath.c 2013-01-31 13:49:44 +0000 renamed from ieee1275/ofpath.c 2013-01-13 21:45:16 +0000 +4 -2
@@ -143,7 +143,8 @@ size = st.st_size; of_path = xmalloc (size + MAX_DISK_CAT + 1); memset(of_path, 0, size + MAX_DISK_CAT + 1); - read(fd, of_path, size); + if (read(fd, of_path, size) < 1) + return NULL; close(fd); trim_newline(of_path);
@@ -354,7 +355,8 @@ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); memset (phy, 0, sizeof (phy)); - read (fd, phy, sizeof (phy)); + if (read (fd, phy, sizeof (phy)) < 1) + grub_util_warn (_("cannot read `%s': %s"), path, strerror (errno)); sscanf (phy, "%d", tgt);
/
Leif