diff mbox series

[v2] boot/grub2: fix build race condition

Message ID c225549c7b76f63429e7fddcb13e38de3c8d30c9.1659683491.git.stefan@agner.ch
State Accepted
Headers show
Series [v2] boot/grub2: fix build race condition | expand

Commit Message

Stefan Agner Aug. 5, 2022, 7:12 a.m. UTC
Sometimes buildroot fails with:
../grub-core/kern/emu/hostfs.c:20:10: fatal error: config-util.h: No such file or directory
   20 | #include <config-util.h>
      |          ^~~~~~~~~~~~~~~

Add a patch which fixes the Makefile to correctly generate config-util.h
first.

Note: This readds a work around to avoid re-running autoconf. This has
previously been used to avoid having to run the rather complex build
file generation machinery of GRUB2. See 7e64a050fb ("boot/grub2: Fix
GRUB i386-pc build with Ubuntu gcc").

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 ...ub_fstest.pp-depend-on-config-util.h.patch | 45 +++++++++++++++++++
 boot/grub2/grub2.mk                           |  6 +++
 2 files changed, 51 insertions(+)
 create mode 100644 boot/grub2/0001-Makefile-Make-grub_fstest.pp-depend-on-config-util.h.patch

Comments

Yann E. MORIN Aug. 6, 2022, 9:08 a.m. UTC | #1
Stefan, All,

On 2022-08-05 09:12 +0200, Stefan Agner spake thusly:
> Sometimes buildroot fails with:
> ../grub-core/kern/emu/hostfs.c:20:10: fatal error: config-util.h: No such file or directory
>    20 | #include <config-util.h>
>       |          ^~~~~~~~~~~~~~~
> 
> Add a patch which fixes the Makefile to correctly generate config-util.h
> first.
> 
> Note: This readds a work around to avoid re-running autoconf. This has
> previously been used to avoid having to run the rather complex build
> file generation machinery of GRUB2. See 7e64a050fb ("boot/grub2: Fix
> GRUB i386-pc build with Ubuntu gcc").

7e64a050fb also touched Makefile.util.am, so I had to check that this
was no onger needed, so I extended the commit log that touching
Makefile.in is indeed sufficient.

> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
[--SNIP--]
> diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk
> index 57593330dd..6c9c80dc15 100644
> --- a/boot/grub2/grub2.mk
> +++ b/boot/grub2/grub2.mk
> @@ -13,6 +13,12 @@ GRUB2_DEPENDENCIES = host-bison host-flex host-grub2
>  HOST_GRUB2_DEPENDENCIES = host-bison host-flex
>  GRUB2_INSTALL_IMAGES = YES
>  
> +define GRUB2_AVOID_AUTORECONF

We usually add a comment to refer to the patch that requires such a
hook, so I added one.

> +       $(Q)touch $(@D)/Makefile.in

    $ make check-package
    boot/grub2/grub2.mk:18: expected indent with tabs

I fixed that too, and applied to master, thanks.

Regards,
Yann E. MORIN.

> +endef
> +GRUB2_POST_PATCH_HOOKS += GRUB2_AVOID_AUTORECONF
> +HOST_GRUB2_POST_PATCH_HOOKS += GRUB2_AVOID_AUTORECONF
> +
>  # CVE-2019-14865 is about a flaw in the grub2-set-bootflag tool, which
>  # doesn't exist upstream, but is added by the Redhat/Fedora
>  # packaging. Not applicable to Buildroot.
> -- 
> 2.37.1
>
diff mbox series

Patch

diff --git a/boot/grub2/0001-Makefile-Make-grub_fstest.pp-depend-on-config-util.h.patch b/boot/grub2/0001-Makefile-Make-grub_fstest.pp-depend-on-config-util.h.patch
new file mode 100644
index 0000000000..ea8787de7a
--- /dev/null
+++ b/boot/grub2/0001-Makefile-Make-grub_fstest.pp-depend-on-config-util.h.patch
@@ -0,0 +1,45 @@ 
+From bb08b723fa7bc56439c7bc166cff361628e73453 Mon Sep 17 00:00:00 2001
+Message-Id: <bb08b723fa7bc56439c7bc166cff361628e73453.1659683176.git.stefan@agner.ch>
+From: Stefan Agner <stefan@agner.ch>
+Date: Fri, 5 Aug 2022 08:59:52 +0200
+Subject: [PATCH] Makefile: Make grub_fstest.pp depend on config-util.h
+
+Warning: This commit does not apply to the GRUB git repository. This
+patch applies against the release tarballs.
+
+Upstream status: https://lists.gnu.org/archive/html/grub-devel/2022-08/msg00045.html
+Signed-off-by: Stefan Agner <stefan@agner.ch>
+---
+ Makefile.am | 2 +-
+ Makefile.in | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index bf9c1ba..f08cfc0 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -51,7 +51,7 @@ libgrub_a_init.c: libgrub_a_init.lst $(top_srcdir)/geninit.sh
+ CLEANFILES += libgrub_a_init.c
+ 
+ # For grub-fstest
+-grub_fstest.pp: $(grub_fstest_SOURCES)
++grub_fstest.pp: config-util.h $(grub_fstest_SOURCES)
+ 	$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_fstest_CPPFLAGS) $(CPPFLAGS) \
+ 	  -D'GRUB_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
+ CLEANFILES += grub_fstest.pp
+diff --git a/Makefile.in b/Makefile.in
+index 13f2eef..2c1d20b 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -13312,7 +13312,7 @@ libgrub_a_init.c: libgrub_a_init.lst $(top_srcdir)/geninit.sh
+ 	sh $(top_srcdir)/geninit.sh `cat $<` > $@ || (rm -f $@; exit 1)
+ 
+ # For grub-fstest
+-grub_fstest.pp: $(grub_fstest_SOURCES)
++grub_fstest.pp: config-util.h $(grub_fstest_SOURCES)
+ 	$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_fstest_CPPFLAGS) $(CPPFLAGS) \
+ 	  -D'GRUB_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
+ 
+-- 
+2.37.1
+
diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk
index 57593330dd..6c9c80dc15 100644
--- a/boot/grub2/grub2.mk
+++ b/boot/grub2/grub2.mk
@@ -13,6 +13,12 @@  GRUB2_DEPENDENCIES = host-bison host-flex host-grub2
 HOST_GRUB2_DEPENDENCIES = host-bison host-flex
 GRUB2_INSTALL_IMAGES = YES
 
+define GRUB2_AVOID_AUTORECONF
+       $(Q)touch $(@D)/Makefile.in
+endef
+GRUB2_POST_PATCH_HOOKS += GRUB2_AVOID_AUTORECONF
+HOST_GRUB2_POST_PATCH_HOOKS += GRUB2_AVOID_AUTORECONF
+
 # CVE-2019-14865 is about a flaw in the grub2-set-bootflag tool, which
 # doesn't exist upstream, but is added by the Redhat/Fedora
 # packaging. Not applicable to Buildroot.