Fix build action order

Add $(INCTARGETS) to build dependencies of %.o and $(DEVICELIB).
As there were no dep files during the first build, Make may kick off source
compilation before nccl.h got generated, which leads to occasional build
failures on systems with high core count. The build failure could be
reproduced reliably with a `sleep 5` in $(INCDIR)/nccl.h rule.
This commit is contained in:
Riatre Foo 2020-07-03 00:07:43 +08:00 committed by Sylvain Jeaugey
parent 1952325569
commit 2d8601701d

View File

@ -46,7 +46,7 @@ lib : $(INCTARGETS) $(LIBDIR)/$(LIBTARGET) $(PKGDIR)/$(PKGTARGET)
staticlib : $(LIBDIR)/$(STATICLIBTARGET) staticlib : $(LIBDIR)/$(STATICLIBTARGET)
$(DEVICELIB): ALWAYS_REBUILD $(DEVICELIB): ALWAYS_REBUILD $(INCTARGETS)
$(MAKE) -C collectives/device $(MAKE) -C collectives/device
# Empty target to force rebuild # Empty target to force rebuild
@ -107,7 +107,7 @@ $(PKGDIR)/%.pc : %.pc
mkdir -p $(PKGDIR) mkdir -p $(PKGDIR)
install -m 644 $< $@ install -m 644 $< $@
$(OBJDIR)/%.o : %.cc $(OBJDIR)/%.o : %.cc $(INCTARGETS)
@printf "Compiling %-35s > %s\n" $< $@ @printf "Compiling %-35s > %s\n" $< $@
mkdir -p `dirname $@` mkdir -p `dirname $@`
$(CXX) -I. -I$(INCDIR) $(CXXFLAGS) -Iinclude -c $< -o $@ $(CXX) -I. -I$(INCDIR) $(CXXFLAGS) -Iinclude -c $< -o $@