SOLARIS: Fix libafs $(KOBJ) parallel make race 44/13344/2
authorAndrew Deason <adeason@sinenomine.net>
Sat, 22 Sep 2018 06:58:17 +0000 (01:58 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 28 Sep 2018 12:32:59 +0000 (08:32 -0400)
Currently, our COMPDIRS make rule for SOLARIS libafs builds looks like
this:

    ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
        for t in $(KOBJ) ; do
            # set some variables ; \
            cd $$t ; \
            $(MAKE) $@_libafs || exit $$? ; \
            cd ../ ;\
        done

And Makefile.common has this:

    all: setup $(COMPDIRS)

Where the 'setup' rule creates the $(KOBJ) dirs and sets up some
symlinks.

For parallel builds, this means that our commands in the ${COMPDIRS}
target can be running in parallel with the 'setup' target, and so our
$(KOBJ) dirs may not exist by the time we try to 'cd $$t'.

For single-KOBJ platforms this actually largely works, since the 'cd'
will fail, but then the subsequent 'make' will run (just in the wrong
dir), but this can cause us to wastefully re-compile the same source
files (and cause some possibly confusing error messages). For
platforms with multiple KOBJs, this causes obvious problems, since we
don't cd into each KOBJ dir.

To solve this, just have the ${COMPDIRS}/etc rule depend on setup, so
we know that 'setup' has finished running. Also change our way of
'cd'ing into each KOBJ dir to actually cause the rule to fail, to make
any errors here more obvious and consistent.

Change-Id: Id2e662f36ef47a6182716728167b2da4713893c6
Reviewed-on: https://gerrit.openafs.org/13344
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/libafs/MakefileProto.SOLARIS.in

index 31d8b3e..a3d102d 100644 (file)
@@ -102,7 +102,7 @@ setup:
 ## This is the target for a Solaris 7. Here we build both the 32 bit and
 ## the 64 bit libafs in MODLOAD32 and MODLOAD64 directories respectively
 
-${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
+${COMPDIRS} ${INSTDIRS} ${DESTDIRS}: setup
        for t in ${KOBJ} ; do \
                echo Building directory: $$t ; \
                case $$t in \
@@ -115,9 +115,7 @@ ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
                esac ; \
                export ARCH_DEFS ; \
                export BITS ; \
-               cd $$t  ; \
-               $(MAKE) $@_libafs || exit $$? ; \
-               cd ../ ;\
+               ( cd $$t && $(MAKE) $@_libafs ) || exit $$? ; \
        done
 
 solaris_compdirs_libafs: depsrcs libafs