Error when using './boards/x86/common/scripts/build_grub.sh x86_64' on Clear Linux


Geoffroy Van Cutsem
 

Hi folks,

I am trying to build a GRUB2 bootloader image following these steps on a Clear Linux system (version 28230). I ran into the problem below (see output at [1]). That is a problem with gcc 8.x that has since been resolved upstream (but not in the 2.02 version used by Zephyr), I cherry-picked that change and applied it (see [2]), but now I'm running into a new, different issue:
<snip>
    -e "/OUTPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $b/;p;}" $pp; \
done) | sort -u > terminal.lst
In file included from ../include/grub/dl.h:29,
                 from loader/i386/bsd.c:26:
loader/i386/bsd.c: In function ‘grub_cmd_openbsd’:
../include/grub/misc.h:71:10: error: ‘ptr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   return grub_memmove (dest, src, n);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
loader/i386/bsd.c:264:9: note: ‘ptr’ was declared here
   void *ptr;
         ^~~
In file included from ../include/grub/dl.h:29,
<snip>

Has anyone seen this?

Thanks,
Geoffroy

[1] Error when running the upstream build_grub.sh script on Clear Linux:
In file included from grub-core/partmap/gpt.c:26:
./include/grub/gpt_partition.h:79:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned]
 } GRUB_PACKED;
 ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:6490: grub-core/partmap/libgrubkern_a-gpt.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f grub-core/lib/.deps-util/grub_mkrescue-reed_solomon.Tpo grub-core/lib/.deps-util/grub_mkrescue-reed_solomon.Po
mv -f grub-core/osdep/.deps-util/grub_mkrescue-random.Tpo grub-core/osdep/.deps-util/grub_mkrescue-random.Po
mv -f grub-core/osdep/.deps-util/grub_mkrescue-ofpath.Tpo grub-core/osdep/.deps-util/grub_mkrescue-ofpath.Po
In file included from grub-core/disk/ldm.c:26:
./include/grub/gpt_partition.h:79:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned]
 } GRUB_PACKED;
 ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:6462: grub-core/disk/libgrubkern_a-ldm.o] Error 1
make[2]: Leaving directory '/home/gvancuts/work/zephyr/boards/x86/common/scripts/grub/src'
make[1]: *** [Makefile:11295: all-recursive] Error 1
make[1]: Leaving directory '/home/gvancuts/work/zephyr/boards/x86/common/scripts/grub/src'
make: *** [Makefile:3515: all] Error 2
./boards/x86/common/scripts/build_grub.sh: line 39: ./grub-mkimage: No such file or directory
~/work/zephyr/boards/x86/common/scripts/grub ~/work/zephyr
cp: cannot stat 'src/grub_x86_64.efi': No such file or directory

[2] Fix for "packed-not-aligned" error
$ git diff
diff --git a/boards/x86/common/scripts/build_grub.sh b/boards/x86/common/scripts/build_grub.sh
index 8b628ab809..a38cd93faa 100755
--- a/boards/x86/common/scripts/build_grub.sh
+++ b/boards/x86/common/scripts/build_grub.sh
@@ -23,6 +23,7 @@ prepare() {
   pushd src
   git checkout grub-2.02
   git cherry-pick c36c2a86404f373100775305f532c09d46f3c6ce
+  git cherry-pick 563b1da6e6ae7af46cc8354cadb5dab416989f0a
   git clean -fdx
   popd
 }

Join devel@lists.zephyrproject.org to automatically receive all group messages.