diff mbox series

x86: fix build race when generating temporary object files

Message ID 5CACB2D10200007800225EDC@prv1-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show
Series x86: fix build race when generating temporary object files | expand

Commit Message

Jan Beulich April 9, 2019, 2:57 p.m. UTC
The rules to generate xen-syms and xen.efi may run in parallel, but both
recursively invoke $(MAKE) to build symbol/relocation table temporary
object files. These recursive builds would both re-generate the .*.d2
files (where needed). Both would in turn invoke the same rule, thus
allowing for a race on the .*.d2.tmp intermediate files.

The dependency files of the temporary .xen*.o files live in xen/ rather
than xen/arch/x86/ anyway, so won't be included no matter what. Take the
opportunity and delete them, as the just re-generated .xen*.S files will
trigger a proper re-build of the .xen*.o ones anyway.

Empty the DEPS variable in case the set of goals consists of just those
temporary object files, thus eliminating the race.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper April 10, 2019, 12:56 p.m. UTC | #1
On 09/04/2019 15:57, Jan Beulich wrote:
> The rules to generate xen-syms and xen.efi may run in parallel, but both
> recursively invoke $(MAKE) to build symbol/relocation table temporary
> object files. These recursive builds would both re-generate the .*.d2
> files (where needed). Both would in turn invoke the same rule, thus
> allowing for a race on the .*.d2.tmp intermediate files.
>
> The dependency files of the temporary .xen*.o files live in xen/ rather
> than xen/arch/x86/ anyway, so won't be included no matter what. Take the
> opportunity and delete them, as the just re-generated .xen*.S files will
> trigger a proper re-build of the .xen*.o ones anyway.
>
> Empty the DEPS variable in case the set of goals consists of just those
> temporary object files, thus eliminating the race.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -145,7 +145,7 @@  $(TARGET)-syms: prelink.o xen.lds
 	$(NM) -pa --format=sysv $(@D)/$(@F) \
 		| $(BASEDIR)/tools/symbols --xensyms --sysv --sort \
 		>$(@D)/$(@F).map
-	rm -f $(@D)/.$(@F).[0-9]*
+	rm -f $(@D)/.$(@F).[0-9]* $(@D)/..$(@F).[0-9]*
 
 note.o: $(TARGET)-syms
 	$(OBJCOPY) -O binary --only-section=.note.gnu.build-id  $(BASEDIR)/xen-syms $@.bin
@@ -208,7 +208,7 @@  $(TARGET).efi: prelink-efi.o $(note_file
 	if $(guard) false; then rm -f $@; echo 'EFI support disabled'; \
 	else $(NM) -pa --format=sysv $(@D)/$(@F) \
 		| $(BASEDIR)/tools/symbols --xensyms --sysv --sort >$(@D)/$(@F).map; fi
-	rm -f $(@D)/.$(@F).[0-9]*
+	rm -f $(@D)/.$(@F).[0-9]* $(@D)/..$(@F).[0-9]*
 
 efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o: $(BASEDIR)/arch/x86/efi/built_in.o
 efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o: ;
@@ -253,3 +253,9 @@  clean::
 	rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/mkreloc
 	rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin
 	rm -f note.o
+
+# Suppress loading of DEPS files for internal, temporary target files.  This
+# then also suppresses re-generation of the respective .*.d2 files.
+ifeq ($(filter-out .xen%.o,$(notdir $(MAKECMDGOALS))),)
+DEPS:=
+endif