From 0b501335f55d96ab78251b75310f3417f8659c6d Mon Sep 17 00:00:00 2001 From: joshua stein Date: Fri, 27 Dec 2019 23:50:39 -0600 Subject: [PATCH] Build: wrap make invocations with flock(1) Lock each directory before entering it so when using -j, the same dependency isn't built more than once at a time. This doesn't get full -j parallelism though, since one make child will be sitting idle waiting for flock to receive its lock and continue making (which should then do nothing since it will have been built already). Unfortunately there's not much that can be done to fix that since it can't proceed until its dependency is built by another make process. --- AK/Tests/Makefile | 1 - Applications/Browser/Makefile | 4 ++-- Libraries/LibAudio/Makefile | 2 +- Libraries/LibC/Makefile | 7 +++---- Libraries/LibGUI/Makefile | 2 +- Libraries/LibHTML/Makefile | 8 ++++---- Libraries/LibProtocol/Makefile | 2 +- Makefile | 2 +- Makefile.common | 8 +++++--- Makefile.subdir | 6 +++--- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/AK/Tests/Makefile b/AK/Tests/Makefile index bd8ec67b83a..1d517b8cd4c 100644 --- a/AK/Tests/Makefile +++ b/AK/Tests/Makefile @@ -35,7 +35,6 @@ SHARED_TEST_OBJS = \ define execute-command $(1) - endef all: $(PROGRAMS) diff --git a/Applications/Browser/Makefile b/Applications/Browser/Makefile index a67bc091c90..e4843ac8cb0 100755 --- a/Applications/Browser/Makefile +++ b/Applications/Browser/Makefile @@ -7,10 +7,10 @@ LIB_DEPS = GUI HTML Draw IPC Protocol Core main.cpp: ../../Libraries/LibHTML/CSS/PropertyID.h ../../Libraries/LibHTML/CSS/PropertyID.h: - @$(MAKE) -C ../../Libraries/LibHTML + @flock ../../Libraries/LibHTML $(MAKE) -C ../../Libraries/LibHTML main.cpp: ../../Servers/ProtocolServer/ProtocolClientEndpoint.h ../../Servers/ProtocolServer/ProtocolClientEndpoint.h: - @$(MAKE) -C $(dir $(@)) + @flock ../../Servers/ProtocolServer $(MAKE) -C $(dir $(@)) include ../../Makefile.common diff --git a/Libraries/LibAudio/Makefile b/Libraries/LibAudio/Makefile index a7bda37485e..ae2ec668ad6 100644 --- a/Libraries/LibAudio/Makefile +++ b/Libraries/LibAudio/Makefile @@ -6,7 +6,7 @@ LIBRARY = libaudio.a AClientConnection.cpp: ../../Servers/AudioServer/AudioClientEndpoint.h ../../Servers/AudioServer/AudioClientEndpoint.h: - @$(MAKE) -C $(dir $(@)) + @flock $(dir $(@)) $(MAKE) -C $(dir $(@)) install: mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/LibAudio/ diff --git a/Libraries/LibC/Makefile b/Libraries/LibC/Makefile index 76b38328386..ee3996b7bae 100644 --- a/Libraries/LibC/Makefile +++ b/Libraries/LibC/Makefile @@ -1,5 +1,3 @@ -.NOTPARALLEL: - AK_OBJS = \ ../../AK/StringImpl.o \ ../../AK/String.o \ @@ -62,7 +60,6 @@ OBJS = $(AK_OBJS) $(LIBC_OBJS) EXTRA_OBJS = setjmp.ao crti.ao crtn.ao crt0.o: crt0.cpp - $(QUIET) $(CXX) $(CXXFLAGS) -o crt0.o -c crt0.cpp crtio.o: crti.ao $(QUIET) cp crti.ao crti.o @@ -76,7 +73,9 @@ DEFINES = -DSERENITY_LIBC_BUILD LIBRARY = libc.a -all: crt0.o $(EXTRA_OBJS) $(LIBRARY) install +POST_LIBRARY_BUILD = $(QUIET) $(MAKE) install + +all: crt0.o $(EXTRA_OBJS) $(LIBRARY) install: mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/sys/ diff --git a/Libraries/LibGUI/Makefile b/Libraries/LibGUI/Makefile index 25f23cec2e4..7d71bf950aa 100644 --- a/Libraries/LibGUI/Makefile +++ b/Libraries/LibGUI/Makefile @@ -66,7 +66,7 @@ LIBRARY = libgui.a GWindowServerConnection.cpp: ../../Servers/WindowServer/WindowServerEndpoint.h ../../Servers/WindowServer/WindowServerEndpoint.h: - @$(MAKE) -C $(dir $(@)) + @flock $(dir $(@)) $(MAKE) -C $(dir $(@)) install: mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/LibGUI/ diff --git a/Libraries/LibHTML/Makefile b/Libraries/LibHTML/Makefile index 1ff6b91919f..6ce339aedb0 100644 --- a/Libraries/LibHTML/Makefile +++ b/Libraries/LibHTML/Makefile @@ -71,10 +71,10 @@ GENERATE_CSS_PROPERTYID_CPP = CodeGenerators/Generate_CSS_PropertyID_cpp/Generat GENERATE_CSS_PROPERTYID_H = CodeGenerators/Generate_CSS_PropertyID_h/Generate_CSS_PropertyID_h $(GENERATE_CSS_PROPERTYID_H): - @$(MAKE) -C $(dir $(GENERATE_CSS_PROPERTYID_H)) + @flock $(dir $(GENERATE_CSS_PROPERTYID_H)) $(MAKE) -C $(dir $(GENERATE_CSS_PROPERTYID_H)) $(GENERATE_CSS_PROPERTYID_CPP): - @$(MAKE) -C $(dir $(GENERATE_CSS_PROPERTYID_CPP)) + @flock $(dir $(GENERATE_CSS_PROPERTYID_CPP)) $(MAKE) -C $(dir $(GENERATE_CSS_PROPERTYID_CPP)) CSS/DefaultStyleSheetSource.cpp: CSS/Default.css Scripts/GenerateStyleSheetSource.sh @echo "GENERATE $@" @@ -82,11 +82,11 @@ CSS/DefaultStyleSheetSource.cpp: CSS/Default.css Scripts/GenerateStyleSheetSourc CSS/PropertyID.h: CSS/Properties.json $(GENERATE_CSS_PROPERTYID_H) @echo "GENERATE $@" - $(QUIET) $(GENERATE_CSS_PROPERTYID_H) $< > $@ + $(QUIET) flock CSS $(GENERATE_CSS_PROPERTYID_H) $< > $@ CSS/PropertyID.cpp: CSS/Properties.json $(GENERATE_CSS_PROPERTYID_CPP) @echo "GENERATE $@" - $(QUIET) $(GENERATE_CSS_PROPERTYID_CPP) $< > $@ + $(QUIET) flock CSS $(GENERATE_CSS_PROPERTYID_CPP) $< > $@ EXTRA_CLEAN = CSS/DefaultStyleSheetSource.cpp CSS/PropertyID.h CSS/PropertyID.cpp diff --git a/Libraries/LibProtocol/Makefile b/Libraries/LibProtocol/Makefile index fb5732a68df..3521c20a001 100644 --- a/Libraries/LibProtocol/Makefile +++ b/Libraries/LibProtocol/Makefile @@ -6,6 +6,6 @@ LIBRARY = libprotocol.a Download.cpp: ../../Servers/ProtocolServer/ProtocolClientEndpoint.h ../../Servers/ProtocolServer/ProtocolClientEndpoint.h: - @$(MAKE) -C $(dir $(@)) + @flock $(dir $(@)) $(MAKE) -C $(dir $(@)) include ../../Makefile.common diff --git a/Makefile b/Makefile index 8ab4e9408b1..31e79296d0d 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,6 @@ ifeq ($(UNAME_S),Darwin) test: else test: - $(QUIET) $(MAKE) -C AK/Tests clean all clean + $(QUIET) flock AK/Tests $(MAKE) -C AK/Tests clean all clean endif diff --git a/Makefile.common b/Makefile.common index 45ff9671170..203bd090fbd 100644 --- a/Makefile.common +++ b/Makefile.common @@ -103,19 +103,21 @@ $(PROGRAM): $(STATIC_LIB_DEPS) $(SUFFIXED_OBJS) $(EXTRA_OBJS) $(LIBRARY): $(SUFFIXED_OBJS) $(EXTRA_OBJS) @echo "LIB $@" $(QUIET) $(AR) rcs $@ $(OBJS) $(EXTRA_OBJS) $(LIBS) + $(POST_LIBRARY_BUILD) +#.PHONY: $(STATIC_LIB_DEPS) $(STATIC_LIB_DEPS): - @$(MAKE) -C $(dir $(@)) + @flock $(dir $(@)) $(MAKE) -C $(dir $(@)) IPCCOMPILER = $(SERENITY_BASE_DIR)/DevTools/IPCCompiler/IPCCompiler IPCCOMPILER: $(IPCCOMPILER) $(IPCCOMPILER): - @$(MAKE) -C $(dir $(@)) + @flock $(dir $(@)) $(MAKE) -C $(dir $(@)) FORMCOMPILER = $(SERENITY_BASE_DIR)/DevTools/FormCompiler/FormCompiler FORMCOMPILER: $(FORMCOMPILER) $(FORMCOMPILER): - @$(MAKE) -C $(dir $(@)) + @flock $(dir $(@)) $(MAKE) -C $(dir $(@)) .DEFAULT_GOAL := all diff --git a/Makefile.subdir b/Makefile.subdir index b4e86913f8c..f7f0e0cd076 100644 --- a/Makefile.subdir +++ b/Makefile.subdir @@ -1,17 +1,17 @@ subdirs: $(SUBDIRS) $(SUBDIRS): - @$(MAKE) -C $@ + @flock $@ $(MAKE) -C $@ all: $(subdirs) SUBDIRS_CLEAN = $(addsuffix .clean,$(SUBDIRS)) clean: $(SUBDIRS_CLEAN) $(SUBDIRS_CLEAN): %.clean: - @$(MAKE) -C $* clean + @flock $* $(MAKE) -C $* clean SUBDIRS_INSTALL = $(addsuffix .install,$(SUBDIRS)) install: $(SUBDIRS_INSTALL) $(SUBDIRS_INSTALL): %.install: - @$(MAKE) -C $* install + @flock $* $(MAKE) -C $* install .PHONY: all clean install $(SUBDIRS)