It annoys me that lang/clisp fails to build with parallel make
(MAKE_JOBS).  I would like to fix that so MAKE_JOBS builds of ports
and their dependencies don't error out when they recurse into clisp.

Clisp hasn't had a release since 2010, but there has been upstream
development up to 2018 in a Mercurial repository at Sourceforge.

There are two unreleased changes we can take from upstream that fix
the Makefile rules generated by the makemake script so that various
helper programs use different file names and don't step on each
other when built in parallel.

There is another problem replicated three times across the modules
subdirectories.  Upstream has completely reworked that area, so
we need to devise our own fix.  The problem centers on this kind of
(GNU)Makefile rule:

gllib libgnu_sc.a : force
        rm -f libgnu_sc.a
        mkdir -p gllib
        test -f gllib/Makefile || sh config.status gllib/Makefile depfiles
        cd gllib; \
          $(MAKE) [...] ; \
          $(LN) libgnu.a ../libgnu_sc.a

It defines two targets that are prerequisites for other targets.
gmake executes the recipe separately for each target.  In parallel
mode, the commands end up being run more than once in parallel and
step on each other.

My proposed fix is to replace all mentions of one of the two targets
with the other one, so that there will be only a single target, e.g.
s/gllib/libgnu_sc.a/g.  Is there a more idiomatic fix?

With the diff below, clisp builds reliably for me with MAKE_JOBS=4.

OK?


Index: patches/patch-modules_regexp_Makefile_in
===================================================================
RCS file: patches/patch-modules_regexp_Makefile_in
diff -N patches/patch-modules_regexp_Makefile_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-modules_regexp_Makefile_in    13 Sep 2021 14:02:57 -0000
@@ -0,0 +1,26 @@
+$OpenBSD$
+
+Fix parallel make: reach target by a single name so the build recipe
+is not run multiple times in parallel.
+
+Index: modules/regexp/Makefile.in
+--- modules/regexp/Makefile.in.orig
++++ modules/regexp/Makefile.in
+@@ -31,7 +31,7 @@ clisp-module : $(GENERATED)
+ regexp.fas: $(srcdir)/regexp.lisp
+       $(CLISP) -c $(srcdir)/regexp.lisp -o ./
+ 
+-regexi.o : regexi.m.c config.h gllib
++regexi.o : regexi.m.c config.h libgnu_rx.a
+       $(CC) $(CPPFLAGS) $(CFLAGS) -I$(CLISP_LINKKIT) \
+               -Igllib -I$(srcdir)/gllib -c regexi.m.c -o regexi.o
+ 
+@@ -44,7 +44,7 @@ preload.lisp : $(srcdir)/preload.lisp
+ am--refresh :
+ 
+ # regexp relies on src/gllib, so we must also include files in the build dir
+-gllib libgnu_rx.a : force
++libgnu_rx.a : force
+       rm -f libgnu_rx.a
+       mkdir -p gllib
+       test -f gllib/Makefile || sh config.status gllib/Makefile depfiles
Index: patches/patch-modules_syscalls_Makefile_in
===================================================================
RCS file: patches/patch-modules_syscalls_Makefile_in
diff -N patches/patch-modules_syscalls_Makefile_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-modules_syscalls_Makefile_in  13 Sep 2021 14:02:57 -0000
@@ -0,0 +1,26 @@
+$OpenBSD$
+
+Fix parallel make: reach target by a single name so the build recipe
+is not run multiple times in parallel.
+
+Index: modules/syscalls/Makefile.in
+--- modules/syscalls/Makefile.in.orig
++++ modules/syscalls/Makefile.in
+@@ -37,7 +37,7 @@ posix.fas: $(srcdir)/posix.lisp
+ calls.m.c: $(srcdir)/calls.c
+       $(CLISP) -C $(CLISP_LINKKIT)/modprep $(srcdir)/calls.c ./
+ 
+-calls.o : calls.m.c config.h gllib
++calls.o : calls.m.c config.h libgnu_sc.a
+       $(CC) $(CPPFLAGS) $(CFLAGS) -I$(CLISP_LINKKIT) \
+               -Igllib -I$(srcdir)/gllib -c calls.m.c -o calls.o
+ 
+@@ -47,7 +47,7 @@ preload.lisp : $(srcdir)/preload.lisp
+ am--refresh :
+ 
+ # syscalls relies on src/gllib, so we must also include files in the build dir
+-gllib libgnu_sc.a : force
++libgnu_sc.a : force
+       rm -f libgnu_sc.a
+       mkdir -p gllib
+       test -f gllib/Makefile || sh config.status gllib/Makefile depfiles
Index: patches/patch-modules_wildcard_Makefile_in
===================================================================
RCS file: patches/patch-modules_wildcard_Makefile_in
diff -N patches/patch-modules_wildcard_Makefile_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-modules_wildcard_Makefile_in  13 Sep 2021 14:02:57 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+Fix parallel make: reach target by a single name so the build recipe
+is not run multiple times in parallel.
+
+Index: modules/wildcard/Makefile.in
+--- modules/wildcard/Makefile.in.orig
++++ modules/wildcard/Makefile.in
+@@ -27,14 +27,14 @@ clisp-module : $(GENERATED)
+ wildcard.c wildcard.fas : $(srcdir)/wildcard.lisp
+       $(CLISP) -c $(srcdir)/wildcard.lisp -o ./
+ 
+-wildcard.o : wildcard.c config.h gllib
++wildcard.o : wildcard.c config.h libgnu_wc.a
+       $(CC) $(CPPFLAGS) $(CFLAGS) -I$(CLISP_LINKKIT) \
+               -Igllib -I$(srcdir)/gllib -c wildcard.c
+ 
+ am--refresh :
+ 
+ # wildcard relies on src/gllib, so we must also include files in the build dir
+-gllib libgnu_wc.a : force
++libgnu_wc.a : force
+       rm -f libgnu_wc.a
+       mkdir -p gllib
+       test -f gllib/Makefile || sh config.status gllib/Makefile depfiles
Index: patches/patch-src_makemake_in
===================================================================
RCS file: /cvs/ports/lang/clisp/patches/patch-src_makemake_in,v
retrieving revision 1.12
diff -u -p -r1.12 patch-src_makemake_in
--- patches/patch-src_makemake_in       6 Oct 2015 11:37:06 -0000       1.12
+++ patches/patch-src_makemake_in       13 Sep 2021 14:02:57 -0000
@@ -5,8 +5,15 @@ Override broken compiler test, attemptin
 
 Use the correct recipe to build shared modules on OpenBSD.
 
---- src/makemake.in.orig       Wed Jul  7 17:15:35 2010
-+++ src/makemake.in    Tue Sep 29 00:28:57 2015
+Fix intparam.h/floatparam.h Makefile rule for parallel make.
+https://sourceforge.net/p/clisp/clisp/ci/72d3cffbc699cc0d46c81b6180109f4f6205657b/
+
+Fix text file processing Makefile rules for parallel make.
+https://sourceforge.net/p/clisp/clisp/ci/ff4fe3d1b89cc23826f98233858308f6da610de4/
+
+Index: src/makemake.in
+--- src/makemake.in.orig
++++ src/makemake.in
 @@ -1150,6 +1150,7 @@ esac
  # esac
  
@@ -37,7 +44,22 @@ Use the correct recipe to build shared m
  echol
  echol '# Directories used by "make install":'
  echol "prefix = ${PREFIX}"
-@@ -2931,7 +2932,7 @@ fi
+@@ -2404,11 +2405,10 @@ for parf in ${PARAMS}; do
+     echotab '$(TOUCH) '"${parf}.h"
+   else
+     echol "${parf}.h : ${SRCDIR}${parf}.c config.h"
+-    echotab "echo '#include \"config.h\"' > tmp.c"
+-    echotab "cat '${SRCDIR}${parf}.c' >> tmp.c"
+-    echotab_to_HEXE "\$(CC)" "tmp.c" "${parf}"
++    echotab "{ echo '#include \"config.h\"' && cat '${SRCDIR}${parf}.c'; } > 
gen-${parf}.c"
++    echotab_to_HEXE "\$(CC)" "gen-${parf}.c" "${parf}"
+     echotab "${HERE}${parf}${HEXE} ${parf}.h"
+-    echotab "\$(RM) ${parf}${HEXE} tmp.c"
++    echotab "\$(RM) ${parf}${HEXE} gen-${parf}.c"
+   fi
+   echol
+ done
+@@ -2931,7 +2931,7 @@ fi
  CLISP_="${HERE_}lisp${LEXE} -M ${HERE_}lispinit.mem 
${localeflags}${someflags}"
  
  if [ $CROSS = false ] ; then
@@ -46,3 +68,31 @@ Use the correct recipe to build shared m
  
    echol "# check the sources:"
    echol "# 1. subr.d, fsubr.d, subrkw.d and all the LISPFUNs must add up"
+@@ -3458,9 +3458,9 @@ for f in $TXT_FILES ; do
+     *) sourcedir=${SRCDIR} ;;
+   esac
+   echol "${f} : ${sourcedir}_${f}${TXT_INCLUDES}${depends} txt2c${HEXE}"
+-  echotab "\$(TXT2C) < ${sourcedir}_${f} > txt.c"
+-  echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS)${flags} 
\$(CLFLAGS)${XCC_NOOPTFLAGS}" "txt.c" "txt"
+-  line="${HERE}txt"
++  echotab "\$(TXT2C) < ${sourcedir}_${f} > gen-${f}.c"
++  echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS)${flags} 
\$(CLFLAGS)${XCC_NOOPTFLAGS}" "gen-${f}.c" "gen-${f}"
++  line="${HERE}gen-${f}"
+   test $f = clisp.1 -o $f = clisp-link.1 && \
+     line=$line" | \$(GREP) -v ${ARGQ1}^ *\$\$${ARGQ1}"
+   # *-1.html is for chunked impnotes and does not depend on user hyperspec
+@@ -3470,11 +3470,11 @@ for f in $TXT_FILES ; do
+   test $f = distmakefile && line=$line" | sed -e \"s,@@LEXE@@,${LEXE},g\" -e 
\"s:@@EXPORT_DYNAMIC_FLAG_SPEC@@:${EXPORT_DYNAMIC_FLAG_SPEC}:g\""
+   line=$line$platform_line
+   echotabpipe "${line} > ${f}"
+-  echotab "\$(RM) txt.c"
+-  echotab "\$(RM) txt${HEXE}"
++  echotab "\$(RM) gen-${f}.c"
++  echotab "\$(RM) gen-${f}${HEXE}"
+   echol
++  OBSOLETE=$OBSOLETE" gen-${f}.c gen-${f}${HEXE}"
+ done
+-OBSOLETE=$OBSOLETE" txt.c txt${HEXE}"
+ 
+ for f in ${MANPAGES}; do
+   if test -n "$GROFF"; then
-- 
Christian "naddy" Weisgerber                          [email protected]

Reply via email to