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


Boie, Andrew P
 

Ø  Should I submit this to Zephyr (as a PR)?

 

Assuming this works in your testing, we would appreciate a patch. :)

 

Andrew

 

From: devel@... [mailto:devel@...] On Behalf Of Geoffroy Van Cutsem
Sent: Monday, March 11, 2019 10:31 AM
To: VanCutsem, Geoffroy <geoffroy.vancutsem@...>; devel@...
Subject: Re: [Zephyr-devel] Error when using './boards/x86/common/scripts/build_grub.sh x86_64' on Clear Linux

 

Quick update following some more testing I did. I hit the same "packed-not-aligned" issue on Fedora 29. I applied the same fix and subsequently hit another issue (see error below), which got resolved by cherry-picking another commit from Grub2 that's in their master but not in 2.02. Here is the diff that allowed be to build the GRUB2 boot loader image (not tested yet on real hardware):

 

[gvancuts@geoffroy-nuc-fedora zephyr]$ git diff

diff --git a/boards/x86/common/scripts/build_grub.sh b/boards/x86/common/scripts/build_grub.sh

index 8b628ab809..7247a904c2 100755

--- a/boards/x86/common/scripts/build_grub.sh

+++ b/boards/x86/common/scripts/build_grub.sh

@@ -23,6 +23,8 @@ prepare() {

   pushd src

   git checkout grub-2.02

   git cherry-pick c36c2a86404f373100775305f532c09d46f3c6ce

+  git cherry-pick 563b1da6e6ae7af46cc8354cadb5dab416989f0a

+  git cherry-pick 842c390469e2c2e10b5aa36700324cd3bde25875

   git clean -fdx

   popd

}

 

Should I submit this to Zephyr (as a PR)?

 

Thanks,

Geoffroy

 

* Second error after cherry-picking the fix for "packed-not-aligned":

<snip>

make[2]: Entering directory '/home/gvancuts/work/zephyrproject/zephyr/boards/x86/common/scripts/grub/src/util/bash-completion.d'

../../config.status --file=grub:grub-completion.bash.in

config.status: creating grub

make[2]: Leaving directory '/home/gvancuts/work/zephyrproject/zephyr/boards/x86/common/scripts/grub/src/util/bash-completion.d'

make[1]: Leaving directory '/home/gvancuts/work/zephyrproject/zephyr/boards/x86/common/scripts/grub/src'

./grub-mkimage: error: relocation 0x4 is not implemented yet.

 

From: devel@... [mailto:devel@...] On Behalf Of Geoffroy Van Cutsem
Sent: Monday, March 11, 2019 4:42 PM
To: devel@...
Subject: [Zephyr-devel] Error when using './boards/x86/common/scripts/build_grub.sh x86_64' on Clear Linux

 

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.