Menu

#446 build dir isn't properly specified as a dependency

open
nobody
None
5
2024-06-10
2024-06-10
NRK
No

When using parallel the mkdir needs to be complete before object files are attempted to be created. But the makefile doesn't specify the build dir to be a dependency of the objects so make may attempt to create object files before the build dir was created.

Short reproducer on linux using GNU Make:

$ cd CPP/7zip/Bundles/Alone2
$ make -f ../../cmpl_gcc.mak -j10 --shuffle=reverse

Proposed fix, add $(O) as a order-only dependency for all the $(OBJS) files:

--- CPP/7zip/7zip_gcc.mak
+++ CPP/7zip/7zip_gcc.mak

 all: $(O) $(PROGPATH) $(STATIC_TARGET)

+$(OBJS): | $(O)
+
 $(O):
        $(MY_MKDIR) $(O)

Bug report about this on gentoo: https://bugs.gentoo.org/933619

Discussion

  • NRK

    NRK - 2024-06-10

    Sorry, I meant to open this as a bug not patch.

     
  • Igor Pavlov

    Igor Pavlov - 2024-06-10

    Is it new switch: --shuffle=reverse ?
    It doesn't work in my make.

     
  • NRK

    NRK - 2024-06-10

    Is it new switch

    The --shuffle switch was added in GNU Make v4.4 in order to detect missing dependencies that causes parallel build failures: https://trofi.github.io/posts/238-new-make-shuffle-mode.html

    GNU Make v4.4 was released in 31 Oct 2022, so it's not too new. I suppose your make version is older than that.

     
  • Robert Simpson

    Robert Simpson - 2024-06-10

    I've also seen sporadic build errors with -j due to the target directory sometimes not getting created before the first ASMC output completes and tries and fails to write to the output location.

    Since I was batching my builds together into a shell script I just pre-created the directories beforehand in my script before calling make.

     

Log in to post a comment.