|
| 1 | +From f10087671538e8e052f035f011fc826f36f2af3b Mon Sep 17 00:00:00 2001 |
| 2 | +From: Jeremi Piotrowski < [email protected]> |
| 3 | +Date: Thu, 29 Feb 2024 10:00:22 +0100 |
| 4 | +Subject: [PATCH] Fix parallel build of gnu-efi |
| 5 | + |
| 6 | +When building with make 4.4.1, gnu-efi may be built twice and in parallel: |
| 7 | + |
| 8 | + $ make -n -j ARCH=x86_64 2>&1 | tee build.log |
| 9 | + $ grep -e 'make -C gnu-efi' build.log |
| 10 | + make -C gnu-efi \ |
| 11 | + make -C gnu-efi \ |
| 12 | + |
| 13 | +This has been seen to cause linking failures when building libgnuefi.a because |
| 14 | +some object files may end up truncated. |
| 15 | + |
| 16 | +The reason for this is that make interprets multiple targets in the same rule |
| 17 | +as independent and can run the rule multiple times. The solution is to define a |
| 18 | +grouped target with &:, which causes make to behave the way one expects: runs |
| 19 | +the rule once and expects it to create all targets. |
| 20 | + |
| 21 | +Grouped target support was added in make 4.3 released 4 years ago. |
| 22 | + |
| 23 | +Signed-off-by: Jeremi Piotrowski < [email protected]> |
| 24 | +--- |
| 25 | + Makefile | 2 +- |
| 26 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 27 | + |
| 28 | +diff --git a/Makefile b/Makefile |
| 29 | +index 8283d56..bbf707b 100644 |
| 30 | +--- a/Makefile |
| 31 | ++++ b/Makefile |
| 32 | +@@ -154,7 +154,7 @@ $(MMSONAME): $(MOK_OBJS) $(LIBS) |
| 33 | + $(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS) lib/lib.a |
| 34 | + |
| 35 | + gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a: CFLAGS+=-DGNU_EFI_USE_EXTERNAL_STDARG |
| 36 | +-gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a: |
| 37 | ++gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a &: |
| 38 | + mkdir -p gnu-efi/lib gnu-efi/gnuefi |
| 39 | + $(MAKE) -C gnu-efi \ |
| 40 | + COMPILER="$(COMPILER)" \ |
| 41 | +-- |
| 42 | +2.39.2 |
| 43 | + |
0 commit comments