Fix parallel creation of directories during make install
#1639
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A race condition occurs during
make installwhen any directory up tothe installation prefix doesn't exist (i.e.,
configure --prefix <prefix-dir>) and more than one make job is specified.For example, invoking
make -j 2 installwhen<prefix-dir>does notexist results in two jobs attempting to create
<prefix-dir>. One ofthe invocations of
src/mkinstalldirsfails because it callsmkdir(
mkdir, without-p, returns a non-zero exit status due todirectories already created). However, due to the dash,
-, for themake recipe, the failure is ignored. Thus, this issue manifests itself
as other installation operations failing.
To address this, use autoconf's
AC_PROG_MKDIR_Pmacro to setMKDIR_Pfor safely creating directories, and parent directories, in parallel.
Remove
mkinstalldirsin favor of automake'sinstall-shscript, whichis needed for
AC_PROG_MKDIR_Pas a fallback mechanism. Note thatinstall-shis safe to run in parallel.Signed-off-by: Eric N. Vander Weele [email protected]