Skip to contentSkip to conversation

grub: Fix build with gcc7

PATCH In review Khem Raj 3 participants 6 messages Apr 21, 2017 – Apr 26, 2017

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 grub: Fix build with gcc7

backport patches from upsteam and adapt them to 2.0 codebase

---
 ...-avoid-used-uninitialized-error-with-GCC7.patch |  36 +++
 ...-ppc-fix-switch-fallthrough-cases-with-GC.patch | 248 +++++++++++++++++++++
 ...0003-Add-gnulib-fix-gcc7-fallthrough.diff.patch |  38 ++++
 ...aining-cases-of-gcc-7-fallthrough-warning.patch | 175 +++++++++++++++
 meta/recipes-bsp/grub/grub2.inc                    |   4 +
 5 files changed, 501 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/files/0001-btrfs-avoid-used-uninitialized-error-with-GCC7.patch
 create mode 100644 meta/recipes-bsp/grub/files/0002-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch
 create mode 100644 meta/recipes-bsp/grub/files/0003-Add-gnulib-fix-gcc7-fallthrough.diff.patch
 create mode 100644 meta/recipes-bsp/grub/files/0004-Fix-remaining-cases-of-gcc-7-fallthrough-warning.patch
meta/recipes-bsp/grub/files/0001-btrfs-avoid-used-uninitialized-error-with-GCC7.patch new file +36 -0
new file mode 100644
index 00000000000..217a775609e
@@ -0,0 +1,36 @@
+From 6cef7f6079550af3bf91dbff824398eaef08c3c5 Mon Sep 17 00:00:00 2001
+From: Andrei Borzenkov <[email protected]>
+Date: Tue, 4 Apr 2017 19:22:32 +0300
+Subject: [PATCH 1/4] btrfs: avoid "used uninitialized" error with GCC7
+
+sblock was local and so considered new variable on every loop
+iteration.
+
+Closes: 50597
+---
+Upstream-Status: Backport
+Signed-off-by: Khem Raj <[email protected]>
+
+ grub-core/fs/btrfs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
+index 9cffa91..4849c1c 100644
+--- a/grub-core/fs/btrfs.c
++++ b/grub-core/fs/btrfs.c
+@@ -227,11 +227,11 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data,
+ static grub_err_t
+ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb)
+ {
++  struct grub_btrfs_superblock sblock;
+   unsigned i;
+   grub_err_t err = GRUB_ERR_NONE;
+   for (i = 0; i < ARRAY_SIZE (superblock_sectors); i++)
+     {
+-      struct grub_btrfs_superblock sblock;
+       /* Don't try additional superblocks beyond device size.  */
+       if (i && (grub_le_to_cpu64 (sblock.this_device.size)
+ 		>> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i])
+-- 
+1.9.1
+
meta/recipes-bsp/grub/files/0002-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch new file +248 -0

248 lines not on this page · raw message

meta/recipes-bsp/grub/files/0003-Add-gnulib-fix-gcc7-fallthrough.diff.patch new file +38 -0
new file mode 100644
index 00000000000..fcfbf5cdf6c
@@ -0,0 +1,38 @@
+From 007f0b407f72314ec832d77e15b83ea40b160037 Mon Sep 17 00:00:00 2001
+From: Andrei Borzenkov <[email protected]>
+Date: Tue, 4 Apr 2017 19:37:47 +0300
+Subject: [PATCH 3/4] Add gnulib-fix-gcc7-fallthrough.diff
+
+As long as the code is not upstream, add it as explicit patch for the
+case of gnulib refresh.
+---
+Upstream-Status: Backport
+Signed-off-by: Khem Raj <[email protected]>
+
+ grub-core/gnulib-fix-gcc7-fallthrough.diff | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+ create mode 100644 grub-core/gnulib-fix-gcc7-fallthrough.diff
+
+diff --git a/grub-core/gnulib-fix-gcc7-fallthrough.diff b/grub-core/gnulib-fix-gcc7-fallthrough.diff
+new file mode 100644
+index 0000000..9802e2d
+--- /dev/null
++++ b/grub-core/gnulib-fix-gcc7-fallthrough.diff
+@@ -0,0 +1,14 @@
++diff --git grub-core/gnulib/regexec.c grub-core/gnulib/regexec.c
++index f632cd4..a7776f0 100644
++--- grub-core/gnulib/regexec.c
+++++ grub-core/gnulib/regexec.c
++@@ -4099,6 +4099,9 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
++     case OP_UTF8_PERIOD:
++       if (ch >= ASCII_CHARS)
++         return false;
+++#if defined __GNUC__ && __GNUC__ >= 7
+++      __attribute__ ((fallthrough));
+++#endif
++       /* FALLTHROUGH */
++ #endif
++     case OP_PERIOD:
+-- 
+1.9.1
+
meta/recipes-bsp/grub/files/0004-Fix-remaining-cases-of-gcc-7-fallthrough-warning.patch new file +175 -0

175 lines not on this page · raw message

meta/recipes-bsp/grub/grub2.inc +4 -0
index ef893b327f2..a93c99e6c9d 100644
@@ -36,6 +36,10 @@ SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
            file://0001-grub-core-kern-efi-mm.c-grub_efi_finish_boot_service.patch \
            file://0002-grub-core-kern-efi-mm.c-grub_efi_get_memory_map-Neve.patch \
            file://0001-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch \
+           file://0001-btrfs-avoid-used-uninitialized-error-with-GCC7.patch \
+           file://0002-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch \
+           file://0003-Add-gnulib-fix-gcc7-fallthrough.diff.patch \
+           file://0004-Fix-remaining-cases-of-gcc-7-fallthrough-warning.patch \
             "
 
 DEPENDS = "flex-native bison-native autogen-native"
Signature · 1 line
2.12.2
author
#1 lore raw

PATCH 2/2 ovmf: Fix build with gcc7

backport a patch which fixing warnings with gcc7

---
 ...g-UefiHiiLib-Fix-incorrect-comparison-exp.patch | 45 ++++++++++++++++++++++
 meta/recipes-core/ovmf/ovmf_git.bb                 |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-MdeModulePkg-UefiHiiLib-Fix-incorrect-comparison-exp.patch
meta/recipes-core/ovmf/ovmf/0001-MdeModulePkg-UefiHiiLib-Fix-incorrect-comparison-exp.patch new file +45 -0
new file mode 100644
index 00000000000..0529a27b168
@@ -0,0 +1,45 @@
+From 73692710d50da1f421b0e6ddff784ca3135389b3 Mon Sep 17 00:00:00 2001
+From: Dandan Bi <[email protected]>
+Date: Sat, 1 Apr 2017 10:31:14 +0800
+Subject: [PATCH] MdeModulePkg/UefiHiiLib:Fix incorrect comparison expression
+
+Fix the incorrect comparison between pointer and constant zero character.
+
+https://bugzilla.tianocore.org/show_bug.cgi?id=416
+
+V2: The pointer StringPtr points to a string returned
+by ExtractConfig/ExportConfig, if it is NULL, function
+InternalHiiIfrValueAction will return FALSE. So in
+current usage model, the StringPtr can not be NULL before
+using it, so we can add ASSERT here.
+
+Cc: Eric Dong <[email protected]>
+Cc: Liming Gao <[email protected]>
+Contributed-under: TianoCore Contribution Agreement 1.0
+Signed-off-by: Dandan Bi <[email protected]>
+Reviewed-by: Eric Dong <[email protected]>
+---
+Upstream-Status: Backport
+
+ MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+index 8579501..46ca7bc 100644
+--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
++++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+@@ -2180,8 +2180,9 @@ InternalHiiIfrValueAction (
+   }
+   
+   StringPtr = ConfigAltResp;
+-  
+-  while (StringPtr != L'\0') {
++  ASSERT (StringPtr != NULL);
++
++  while (*StringPtr != L'\0') {
+     //
+     // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
+     //
+-- 
+1.9.1
+
meta/recipes-core/ovmf/ovmf_git.bb +1 -0
index 73fdfc6239e..9d988e9d414 100644
@@ -14,6 +14,7 @@ SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \
 	file://0002-ovmf-update-path-to-native-BaseTools.patch \
 	file://0003-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
 	file://VfrCompile-increase-path-length-limit.patch \
+        file://0001-MdeModulePkg-UefiHiiLib-Fix-incorrect-comparison-exp.patch \
         "
 
 SRC_URI_append_class-target = " \
Signature · 1 line
2.12.2
#2 lore raw
In reply to Khem Raj
Quoted 2 lines · Khem Raj

backport patches from upsteam and adapt them to 2.0 codebase

This fails for me (and the autobuilders) in grub-core/video/i386/pc/vbe.c which was fixed upstream in 2015 and the file hasn't been touched since.

This makes me wonder why are we building code that was released before then, and is VBE still a thing? Last time I remember seeing those letters was around 2000 on my new Pentium...

Fix those and now it fails for me in:

../../grub-2.00/grub-core/loader/i386/pc/linux.c: In function
'grub_cmd_linux':
| ../../grub-2.00/grub-core/loader/i386/pc/linux.c:254:9: error: this statement may fall through [-Werror=implicit-fallthrough=]

|    shift += 10;
|    ~~~~~~^~~~~
| ../../grub-2.00/grub-core/loader/i386/pc/linux.c:255:8: note: here
|         case 'm':
|         ^~~~
| ../../grub-2.00/grub-core/loader/i386/pc/linux.c:256:9: error: this
statement may fall through [-Werror=implicit-fallthrough=]
|    shift += 10;
|    ~~~~~~^~~~~
| ../../grub-2.00/grub-core/loader/i386/pc/linux.c:257:8: note: here
|         case 'k':
|         ^~~~

Clearly there's some build difference between our configurations. Are you building grub-git instead of grub_2.00? Should we delete grub_2.00 if its that old? I'd say that it looks good for a new upstream 2.02 release as there is a 2.02-rc2 tagged just six weeks ago, but 2.02-beta1 was tagged three years ago...

Ross

author
#3 lore raw
Quoted 5 lines · Ross

Clearly there's some build difference between our configurations. Are you building grub-git instead of grub_2.00? Should we delete grub_2.00 if its that old? I'd say that it looks good for a new upstream 2.02 release as there is a 2.02-rc2 tagged just six weeks ago, but 2.02-beta1 was tagged three years ago...

yes saw that, fedora is already using 2.02-rc2, we will simplify things if we are ready to take the plunge and be ready to release with rc2 itself if final
release takes another 3 years.

#4 lore raw
Quoted 11 lines · Khem Raj
Quoted 5 lines · Ross

Clearly there's some build difference between our configurations. Are you building grub-git instead of grub_2.00? Should we delete grub_2.00 if its that old? I'd say that it looks good for a new upstream 2.02 release as there is a 2.02-rc2 tagged just six weeks ago, but 2.02-beta1 was tagged three years ago...

yes saw that, fedora is already using 2.02-rc2, we will simplify things if we are ready to take the plunge and be ready to release with rc2 itself if final
release takes another 3 years.

The 2.02 release seems to be almost ready:

http://git.savannah.gnu.org/cgit/grub.git/commit/?id=e54c99aaff5e5f6f5d3b06028506c57e66d8ef77

Quoted 5 lines

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core