Skip to content

Commit 165335d

Browse files
keesgregkh
authored andcommitted
x86/boot: Fix if_changed build flip/flop bug
[ Upstream commit 92a4728 ] Dirk Gouders reported that two consecutive "make" invocations on an already compiled tree will show alternating behaviors: $ make CALL scripts/checksyscalls.sh DESCEND objtool CHK include/generated/compile.h DATAREL arch/x86/boot/compressed/vmlinux Kernel: arch/x86/boot/bzImage is ready (raspberrypi#48) Building modules, stage 2. MODPOST 165 modules $ make CALL scripts/checksyscalls.sh DESCEND objtool CHK include/generated/compile.h LD arch/x86/boot/compressed/vmlinux ZOFFSET arch/x86/boot/zoffset.h AS arch/x86/boot/header.o LD arch/x86/boot/setup.elf OBJCOPY arch/x86/boot/setup.bin OBJCOPY arch/x86/boot/vmlinux.bin BUILD arch/x86/boot/bzImage Setup is 15644 bytes (padded to 15872 bytes). System is 6663 kB CRC 3eb90f40 Kernel: arch/x86/boot/bzImage is ready (raspberrypi#48) Building modules, stage 2. MODPOST 165 modules He bisected it back to: commit 98f7852 ("x86/boot: Refuse to build with data relocations") The root cause was the use of the "if_changed" kbuild function multiple times for the same target. It was designed to only be used once per target, otherwise it will effectively always trigger, flipping back and forth between the two commands getting recorded by "if_changed". Instead, this patch merges the two commands into a single function to get stable build artifacts (i.e. .vmlinux.cmd), and a single build behavior. Bisected-and-Reported-by: Dirk Gouders <[email protected]> Fix-Suggested-by: Masahiro Yamada <[email protected]> Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Masahiro Yamada <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/20180724230827.GA37823@beast Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d35aab9 commit 165335d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/boot/compressed/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ define cmd_check_data_rel
104104
done
105105
endef
106106

107+
# We need to run two commands under "if_changed", so merge them into a
108+
# single invocation.
109+
quiet_cmd_check-and-link-vmlinux = LD $@
110+
cmd_check-and-link-vmlinux = $(cmd_check_data_rel); $(cmd_ld)
111+
107112
$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
108-
$(call if_changed,check_data_rel)
109-
$(call if_changed,ld)
113+
$(call if_changed,check-and-link-vmlinux)
110114

111115
OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
112116
$(obj)/vmlinux.bin: vmlinux FORCE

0 commit comments

Comments
 (0)