Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Allow parallel make
- X-seq: zsh-workers 55141
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Allow parallel make
- Date: Tue, 8 Sep 2026 16:21:23 +0200
- Archived-at: <https://zsh.org/workers/55141>
- List-id: <zsh-workers.zsh.org>
---
Back in workers/23102 Vincent reported that make -j2 didn't work, and we
added .NOTPARALLEL etc to the build rules. I finally got a bit bored
with seeing my cpu sit at 50% when building zsh (yes, I only have a dual
core cpu), so here's my stab at fixing it.
The rule depending on headers in src/Makefile.in is the main thing that
avoids the error Vincent saw, but there's also some follow-on errors
that needed fixing up.
I won't commit this unless a lot of people says it works on various make
implementations (I only have GNU Make), and please try it at different
job counts. The newuser.c failure only happened to me with make -j3, not
make -j10 for example. The others didn't happen and are purely by
inspection.
Tighten up the atomicity of the header generation rules in zsh.mdd now
that they could in theory be invoked concurrently.
The phony rules in curses.mdd and terminfo.mdd are because I have some
vague memory that Make may be unhappy with defining multiple identical
rules in the same Makefile, and the mdd files' rules all end up combined
somewhere (I assume), so I used two phony rules instead. I didn't bother
doing that for newuser.mdd since it's the only one defining a rule for
../zshpaths.h
Config/defs.mk.in | 6 ----
Src/Makefile.in | 2 ++
Src/Modules/curses.mdd | 7 +++-
Src/Modules/newuser.mdd | 5 ++-
Src/Modules/terminfo.mdd | 10 ++++++
Src/zsh.mdd | 75 +++++++++++++++++++++-------------------
6 files changed, 61 insertions(+), 44 deletions(-)
diff --git a/Config/defs.mk.in b/Config/defs.mk.in
index 116875fb9c..00119eac97 100644
--- a/Config/defs.mk.in
+++ b/Config/defs.mk.in
@@ -105,9 +105,3 @@ FUNCTIONS_INSTALL='$(FUNCTIONS_INSTALL)' tzsh='$(tzsh)'
# override built-in suffix list
.SUFFIXES:
-
-# parallel build is not supported (pmake, gmake)
-.NOTPARALLEL:
-
-# parallel build is not supported (dmake)
-.NO_PARALLEL:
diff --git a/Src/Makefile.in b/Src/Makefile.in
index 0fdbb73d2d..06fc2f8529 100644
--- a/Src/Makefile.in
+++ b/Src/Makefile.in
@@ -218,6 +218,8 @@ mostlyclean-modules clean-modules distclean-modules realclean-modules:
# ========== RECURSIVE MAKES ==========
+install.modules uninstall.modules \
+modobjs modules proto $(MAIN_OBJS) zsh.export: headers
install.modules uninstall.modules \
modobjs modules headers proto $(MAIN_OBJS) zsh.export: Makemod
@$(MAKE) -f Makemod $(MAKEDEFS) $@
diff --git a/Src/Modules/curses.mdd b/Src/Modules/curses.mdd
index 75da29a6d2..1a630b6b53 100644
--- a/Src/Modules/curses.mdd
+++ b/Src/Modules/curses.mdd
@@ -7,11 +7,16 @@ autofeatures="b:zcurses"
objects="curses.o"
:<<\Make
-curses.o curses..o: curses_keys.h
+curses.o curses..o: curses_keys.h ../zshcurses.h CURSES_HEADER_RULE
curses_keys.h: curses_keys.awk @CURSES_KEYS_H@
$(AWK) -f $(sdir)/curses_keys.awk @CURSES_KEYS_H@ /dev/null >curses_keys.h
+CURSES_HEADER_RULE: FORCE
+ @cd .. && $(MAKE) $(MAKEDEFS) -f Makemod zshcurses.h
+
+.PHONY: CURSES_HEADER_RULE
+
clean-here: clean.curses
clean.curses:
rm -f curses_keys.h
diff --git a/Src/Modules/newuser.mdd b/Src/Modules/newuser.mdd
index 82a08a52e3..923602041c 100644
--- a/Src/Modules/newuser.mdd
+++ b/Src/Modules/newuser.mdd
@@ -8,6 +8,9 @@ functions='Scripts/newuser Functions/Newuser/*'
objects="newuser.o"
:<<\Make
-newuser.o: ../zshpaths.h
+newuser.o newuser..o: ../zshpaths.h
+
+../zshpaths.h: FORCE
+ @cd .. && $(MAKE) $(MAKEDEFS) -f Makemod zshpaths.h
Make
diff --git a/Src/Modules/terminfo.mdd b/Src/Modules/terminfo.mdd
index a9a3f1b49b..e42d4c0408 100644
--- a/Src/Modules/terminfo.mdd
+++ b/Src/Modules/terminfo.mdd
@@ -15,3 +15,13 @@ load=yes
autofeatures="b:echoti p:terminfo"
objects="terminfo.o"
+
+:<<\Make
+terminfo.o terminfo..o: ../zshcurses.h ../zshterm.h TERMCAP_HEADER_RULE
+
+TERMCAP_HEADER_RULE: FORCE
+ @cd .. && $(MAKE) $(MAKEDEFS) -f Makemod zshcurses.h zshterm.h
+
+.PHONY: TERMCAP_HEADER_RULE
+
+Make
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 9a5e9daab1..8480538501 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -61,56 +61,59 @@ FORCE:
zshcurses.h: ../config.h
@if test x$(ZSH_CURSES_H) != x; then \
- echo "#include <$(ZSH_CURSES_H)>" >zshcurses.h; \
+ echo "#include <$(ZSH_CURSES_H)>" >zshcurses.h.tmp.$$$$; \
+ mv zshcurses.h.tmp.$$$$ zshcurses.h; \
else \
echo >zshcurses.h; \
fi
zshterm.h: ../config.h
@if test x$(ZSH_TERM_H) != x; then \
- echo "#include <$(ZSH_TERM_H)>" >zshterm.h; \
+ echo "#include <$(ZSH_TERM_H)>" >zshterm.h.tmp.$$$$; \
+ mv zshterm.h.tmp.$$$$ zshterm.h; \
else \
echo >zshterm.h; \
fi
zshpaths.h: Makemod $(CONFIG_INCS)
- @echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp
- @if test x$(sitescriptdir) != xno; then \
- echo '#define SITESCRIPT_DIR "'$(sitescriptdir)'"' >> zshpaths.h.tmp; \
- fi
- @if test x$(scriptdir) != xno; then \
- echo '#define SCRIPT_DIR "'$(scriptdir)'"' >> zshpaths.h.tmp; \
- fi
- @if test x$(sitefndir) != xno; then \
- echo '#define SITEFPATH_DIR "'$(sitefndir)'"' >> zshpaths.h.tmp; \
- fi
- @if test x$(fixed_sitefndir) != x; then \
- echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp; \
- fi
- @if test x$(fndir) != xno; then \
- echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \
- if test x$(FUNCTIONS_SUBDIRS) != x && \
- test x$(FUNCTIONS_SUBDIRS) != xno; then \
- fpath_tmp="`grep ' functions=.' \
- $(dir_top)/config.modules | sed -e '/^#/d' -e '/ link=no/d' \
- -e 's/^.* functions=//'`"; \
- fpath_tmp=`for f in $$fpath_tmp; do \
- echo $$f | sed -e 's%^Functions/%%' -e 's%/[^/]*$$%%' -e 's%/\*%%'; \
- done | grep -v Scripts | sort | uniq`; \
- fpath_tmp=`echo $$fpath_tmp | sed 's/ /\", \"/g'`; \
- echo "#define FPATH_SUBDIRS { \"$$fpath_tmp\" }" \
- >>zshpaths.h.tmp; \
+ @{ \
+ echo '#define MODULE_DIR "'$(MODDIR)'"'; \
+ if test x$(sitescriptdir) != xno; then \
+ echo '#define SITESCRIPT_DIR "'$(sitescriptdir)'"'; \
fi; \
- fi
- @if test x$(additionalfpath) != x; then \
- fpath_tmp="`echo $(additionalfpath) | sed -e 's:,:\", \":g'`"; \
- echo "#define ADDITIONAL_FPATH { \"$$fpath_tmp\" }" >> zshpaths.h.tmp; \
- fi
- @if cmp -s zshpaths.h zshpaths.h.tmp; then \
- rm -f zshpaths.h.tmp; \
+ if test x$(scriptdir) != xno; then \
+ echo '#define SCRIPT_DIR "'$(scriptdir)'"'; \
+ fi; \
+ if test x$(sitefndir) != xno; then \
+ echo '#define SITEFPATH_DIR "'$(sitefndir)'"'; \
+ fi; \
+ if test x$(fixed_sitefndir) != x; then \
+ echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"'; \
+ fi; \
+ if test x$(fndir) != xno; then \
+ echo '#define FPATH_DIR "'$(fndir)'"'; \
+ if test x$(FUNCTIONS_SUBDIRS) != x && \
+ test x$(FUNCTIONS_SUBDIRS) != xno; then \
+ fpath_tmp="`grep ' functions=.' \
+ $(dir_top)/config.modules | sed -e '/^#/d' -e '/ link=no/d' \
+ -e 's/^.* functions=//'`"; \
+ fpath_tmp=`for f in $$fpath_tmp; do \
+ echo $$f | sed -e 's%^Functions/%%' -e 's%/[^/]*$$%%' -e 's%/\*%%'; \
+ done | grep -v Scripts | sort | uniq`; \
+ fpath_tmp=`echo $$fpath_tmp | sed 's/ /\", \"/g'`; \
+ echo "#define FPATH_SUBDIRS { \"$$fpath_tmp\" }"; \
+ fi; \
+ fi; \
+ if test x$(additionalfpath) != x; then \
+ fpath_tmp="`echo $(additionalfpath) | sed -e 's:,:\", \":g'`"; \
+ echo "#define ADDITIONAL_FPATH { \"$$fpath_tmp\" }"; \
+ fi; \
+ } > zshpaths.h.tmp.$$$$; \
+ if cmp -s zshpaths.h zshpaths.h.tmp.$$$$; then \
+ rm -f zshpaths.h.tmp.$$$$; \
echo "\`zshpaths.h' is up to date." ; \
else \
- mv -f zshpaths.h.tmp zshpaths.h; \
+ mv -f zshpaths.h.tmp.$$$$ zshpaths.h; \
echo "Updated \`zshpaths.h'." ; \
fi
--
2.38.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author