compile error in master, restrict is missing
I understand that grub.git#master does (most likely) compile for everyone else:
[ 135s] + env CFLAGS=-Wall CXXFLAGS=-Wall FFLAGS=-Wall ../grub2-src/configure --target=i386-suse-linux --with-platform=pc --prefix=/usr/lib64/grub2-chainloader --disable-boot-time --disable-cache-stats --disable-device-mapper --disable-efiemu --disable-grub-emu-pci --disable-grub-emu-sdl --disable-grub-mkfont --disable-grub-mount --disable-grub-themes --disable-liblzma --disable-libzfs --enable-mm-debug --disable-nls --disable-werror --enable-rpath --with-bootdir=/chainloader/grub2-chainloader --enable-grub-mkfont --enable-grub-themes --with-grubdir=grub2
...
[ 207s] In file included from ../grub2-src/util/grub-mkfont.c:21:0: [ 207s] ../grub2-src/include/grub/misc.h:264:64: error: expected ';', ',' or ')' before 'str' [ 207s] unsigned long EXPORT_FUNC(grub_strtoul) (const char * restrict str, const char ** const restrict end, int base); [ 207s] ^
Where is 'restrict' supposed to come from?
Olaf
Hi Olaf,
CC-ing Peter...
Quoted 8 lines · Olaf Hering
I understand that grub.git#master does (most likely) compile for everyone else:
[ 135s] + env CFLAGS=-Wall CXXFLAGS=-Wall FFLAGS=-Wall ../grub2-src/configure --target=i386-suse-linux --with-platform=pc --prefix=/usr/lib64/grub2-chainloader --disable-boot-time --disable-cache-stats --disable-device-mapper --disable-efiemu --disable-grub-emu-pci --disable-grub-emu-sdl --disable-grub-mkfont --disable-grub-mount --disable-grub-themes --disable-liblzma --disable-libzfs --enable-mm-debug --disable-nls --disable-werror --enable-rpath --with-bootdir=/chainloader/grub2-chainloader --enable-grub-mkfont --enable-grub-themes --with-grubdir=grub2
...[ 207s] In file included from ../grub2-src/util/grub-mkfont.c:21:0: [ 207s] ../grub2-src/include/grub/misc.h:264:64: error: expected ';', ',' or ')' before 'str' [ 207s] unsigned long EXPORT_FUNC(grub_strtoul) (const char * restrict str, const char ** const restrict end, int base); [ 207s] ^
Yeah, I added tons of patches yesterday evening and build tested. Nothing suspicious pooped out. I expect that the issues you are hitting are related to set of configure flags which you are using. Anyway, it has to be fixed...
Quoted 1 line
Where is 'restrict' supposed to come from?
Peter, could you take a look at this?
Daniel
Quoted 1 line · Daniel Kiper
Quoted 1 line
[ 135s] + env CFLAGS=-Wall CXXFLAGS=-Wall FFLAGS=-Wall ../grub2-src/configure --target=i386-suse-linux
Which version of SUSE Linux is that, in case I want to reproduce that?
FWIW, I work at SUSE, so I have access to all versions :).
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer - [email protected] `. `' Freie Universitaet Berlin - [email protected] `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Am Wed, 11 Mar 2020 11:39:08 +0100
schrieb Daniel Kiper <[email protected]>:
Quoted 2 lines
Nothing suspicious pooped out. I expect that the issues you are hitting are related to set of configure flags which you are using.
It turned out --disable-mm-debug does for some reason fix the build with gcc7. But building with gcc48 does still trigger the failure.
Olaf
Am Wed, 11 Mar 2020 11:56:27 +0100
schrieb John Paul Adrian Glaubitz <[email protected]>:
Quoted 1 line
Which version of SUSE Linux is that, in case I want to reproduce that?
SLE_12 and Leap 42.3, everything with gcc-4.8. I may be able to work around it by using a newer compiler.
Olaf
Quoted 6 lines · Olaf Hering
Am Wed, 11 Mar 2020 11:56:27 +0100
schrieb John Paul Adrian Glaubitz <[email protected]>:Quoted 1 line
Which version of SUSE Linux is that, in case I want to reproduce that?
SLE_12and Leap 42.3, everything with gcc-4.8. I may be able to work around it by using a newer compiler.
Ok, thanks. FWIW, Leap 42.3 is no longer supported by us.
I happen to have a SLE-12 cloud instance running anyway now so I can help debug if necessary.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer - [email protected] `. `' Freie Universitaet Berlin - [email protected] `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Hello Olaf,
Quoted 8 lines · Olaf Hering
Am Wed, 11 Mar 2020 11:39:08 +0100
schrieb Daniel Kiper <[email protected]>:Quoted 2 lines
Nothing suspicious pooped out. I expect that the issues you are hitting are related to set of configure flags which you are using.
It turned out --disable-mm-debug does for some reason fix the build with gcc7. But building with gcc48 does still trigger the failure.
That's expected because unless specified, the default for GCC 4.8 is -std=gnu90 (C90 with GNU extensions) but the restrict type qualifier was introduced in C99.
Does the following patch solve the issue?
From 2e9879df9ddd4744f7b6c55bac9cf335e5832243 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <[email protected]>
Date: Wed, 11 Mar 2020 12:03:54 +0100
Subject: [PATCH] misc: Disable the restrict keyword when not building with C99
The restrict type qualifier was introduced in the C99 standard, so it will lead to a compile error if GRUB is not built with -std=c99 or newer.
This check comes from grub-core/lib/zstd/xxhash.h file that does the same.
--- include/grub/misc.h | 4 ++++ 1 file changed, 4 insertions(+)
include/grub/misc.h +4 -0
@@ -27,6 +27,10 @@#include <grub/i18n.h> #include <grub/compiler.h> +#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >=199901L ))/* ! C99 */ +# define restrict/* disable restrict */ +#endif +#define ALIGN_UP (addr, align) \ ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))#define ALIGN_UP_OVERHEAD (addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1))
Signature · 1 line
2.24.1
Am Wed, 11 Mar 2020 12:30:01 +0100
schrieb Javier Martinez Canillas <[email protected]>:
Quoted 1 line
+#if !(defined(__STDC_VERSION__) && (
__STDC_VERSION__>= 199901L))
This does not help. I have seen similar code in one of the zstd headers.
Whatever the outcome will be, it should get a 'Fixes commit d5a32255d' tag.
Olaf
Quoted 7 lines · Olaf Hering
Am Wed, 11 Mar 2020 12:30:01 +0100
schrieb Javier Martinez Canillas <[email protected]>:Quoted 1 line
+#if !(defined(__STDC_VERSION__) && (
__STDC_VERSION__>= 199901L))This does not help. I have seen similar code in one of the zstd headers.
Yes, I mentioned in the commit message that it was taken from there...
I would had expected that change to avoid the build failure. I wonder why it didn't help.
Quoted 2 lines
Whatever the outcome will be, it should get a 'Fixes commit
d5a32255d' tag.
Agreed.
Daniel said that instead he will add a -std=gnu99 option so the compiler uses C99 even if is not its default.
Quoted 2 lines
Olaf
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
Quoted 13 lines · Javier Martinez Canillas
Quoted 6 lines · Olaf Hering
Am Wed, 11 Mar 2020 12:30:01 +0100
schrieb Javier Martinez Canillas <[email protected]>:Quoted 1 line
+#if !(defined(__STDC_VERSION__) && (
__STDC_VERSION__>= 199901L))This does not help. I have seen similar code in one of the zstd headers.
Yes, I mentioned in the commit message that it was taken from there...
I would had expected that change to avoid the build failure. I wonder why it didn't help.
Quoted 6 lines
Quoted 1 line
Whatever the outcome will be, it should get a 'Fixes commit
d5a32255d' tag.Agreed.
Daniel said that instead he will add a -std=gnu99 option so the compiler uses C99 even if is not its default.
Olaf, could you try the patch in the attachment? Please rerun ./autogen.sh and ./configure after applying it.
Daniel
configure.ac +7 -1
@@ -36,7 +36,7 @@ AC_INIT([GRUB],[2.05],[[email protected]]) AC_CONFIG_AUX_DIR([build-aux]) # We don't want -g -O2 by default in CFLAGS -: ${CFLAGS=""} +: ${CFLAGS='-std=gnu99'} # Checks for build, host and target systems. AC_CANONICAL_BUILD
@@ -80,6 +80,12 @@ if test "x$TARGET_CFLAGS" = x; then TARGET_CFLAGS="$TARGET_CFLAGS -Os" fi +TARGET_CFLAGS="$TARGET_CFLAGS -std=gnu99" + +BUILD_CFLAGS="$BUILD_CFLAGS -std=gnu99" + +HOST_CFLAGS="$HOST_CFLAGS -std=gnu99" + # Default HOST_CPPFLAGS HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
Am Thu, 12 Mar 2020 19:01:26 +0100
schrieb Daniel Kiper <[email protected]>:
Quoted 1 line
Olaf, could you try the patch in the attachment?
Yes, this fixes the compile errors. Thanks.
Olaf
Quoted 6 lines · Olaf Hering
Am Thu, 12 Mar 2020 19:01:26 +0100
schrieb Daniel Kiper <[email protected]>:Quoted 1 line
Olaf, could you try the patch in the attachment?
Yes, this fixes the compile errors. Thanks.
Great! So, I will post proper patch probably at the beginning of next week. This one requires some polishing.
Olaf, in the mean time please fix your issue if possible.
Daniel