Skip to content

Commit 64db994

Browse files
authored
Merge 3fdcab0 into 90b0476
2 parents 90b0476 + 3fdcab0 commit 64db994

2 files changed

Lines changed: 69 additions & 22 deletions

File tree

Makefile.am

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -697,17 +697,22 @@ spellcheck spellcheck-interactive:
697697

698698
# Auto-parallel recipe (if current 'make' implementation supports the "-j N"
699699
# syntax; the optional MAXPARMAKES may be set in NUT CI farm style builds):
700-
spellcheck-quick:
701-
+@case " $(MAKEFLAGS) $(AM_MAKEFLAGS)" in \
702-
*"j"*) $(MAKE) $(AM_MAKEFLAGS) -k -s spellcheck && exit ;; \
700+
SET_PARMAKES_OPT = \
701+
+@PARMAKES_OPT=""; \
702+
case " $(MAKEFLAGS) $(AM_MAKEFLAGS)" in \
703+
*"j"*) ;; \
703704
*) \
704705
if ! [ "$${MAXPARMAKES-}" -gt 1 ] 2>/dev/null ; then \
705706
MAXPARMAKES=8 ; \
706707
fi ; \
707-
$(MAKE) $(AM_MAKEFLAGS) -k -s -j $${MAXPARMAKES} spellcheck \
708-
&& exit ;; \
708+
PARMAKES_OPT="-j $${MAXPARMAKES}" ; \
709+
;; \
709710
esac
710711

712+
spellcheck-quick:
713+
+@$(SET_PARMAKES_OPT); \
714+
$(MAKE) $(AM_MAKEFLAGS) -k -s ${PARMAKES_OPT} spellcheck
715+
711716
# Run auto-parallel recipe, and if something fails - re-run interactively:
712717
spellcheck-interactive-quick:
713718
+@$(MAKE) $(AM_MAKEFLAGS) -k -s spellcheck-quick && exit ; \
@@ -1444,6 +1449,10 @@ check-files-quick: $(CHECK_FILES_QUICK_TARGETS)
14441449
# Autotools hook: run the quick checks before recursing for defaults:
14451450
check-recursive: check-files-quick
14461451

1452+
# Caller can set this to "false" to not regenerate below
1453+
# (e.g. in CI vs. developer iterations):
1454+
CHECK_PARALLEL_BUILDS_REGEN = true
1455+
14471456
# Not pulled in directly so far, can be used by developers to verify that build
14481457
# rules (inlcuding dependencies pulled from other directories) make sense and
14491458
# do not cause conflict by writing into same file names. Something that builds
@@ -1454,25 +1463,16 @@ check-recursive: check-files-quick
14541463
# Auto-parallel recipe (if current 'make' implementation supports the "-j N"
14551464
# syntax; the optional MAXPARMAKES may be set in NUT CI farm style builds):
14561465
check-parallel-builds:
1457-
automake -f
1458-
./config.status
1459-
+@MAXPARMAKES_OPT=""; \
1460-
case " $(MAKEFLAGS) $(AM_MAKEFLAGS)" in \
1461-
*"j"*) ;; \
1462-
*) \
1463-
if ! [ "$${MAXPARMAKES-}" -gt 1 ] 2>/dev/null ; then \
1464-
MAXPARMAKES=8 ; \
1465-
fi ; \
1466-
MAXPARMAKES_OPT="-j $${MAXPARMAKES}" ; \
1467-
;; \
1468-
esac ; \
1466+
if [ x"$(CHECK_PARALLEL_BUILDS_REGEN)" = xtrue ] ; then automake -f ; fi
1467+
if [ x"$(CHECK_PARALLEL_BUILDS_REGEN)" = xtrue ] ; then ./config.status ; fi
1468+
+@$(SET_PARMAKES_OPT); \
14691469
DIRS=""; \
14701470
for D in `find . -name '*.c' -o -name '*.cpp' | sed 's,/[^/]*\.cp*$$,,' | uniq` ; do \
14711471
[ -e "$$D/Makefile.am" ] && [ -s "$$D/Makefile" ] || continue ; \
1472-
$(MAKE) $(AM_MAKEFLAGS) -k -s $${MAXPARMAKES_OPT} clean || { RES=$$?; echo "$@: FAILED: make clean before going to $$D" >&2; exit $$RES; } ; \
1472+
$(MAKE) $(AM_MAKEFLAGS) -k -s $${PARMAKES_OPT} clean || { RES=$$?; echo "$@: FAILED: make clean before going to $$D" >&2; exit $$RES; } ; \
14731473
echo " $@ in $${D}" ; \
1474-
( cd "$$D" && $(MAKE) $(AM_MAKEFLAGS) -k -s $${MAXPARMAKES_OPT} ) || { RES=$$?; echo "$@: FAILED: parallel make in $$D" >&2; \
1475-
echo "To investigate, try: $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) $${MAXPARMAKES_OPT} clean ; automake -f && ./config.status && clear && (cd $${D}/ && $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) V=1 $${MAXPARMAKES_OPT} 2>&1 ; echo $?) | tee /tmp/make.log ; grep -E '(\] Error|No rule to)' /tmp/make.log && less /tmp/make.log"; \
1474+
( cd "$$D" && $(MAKE) $(AM_MAKEFLAGS) -k -s $${PARMAKES_OPT} ) || { RES=$$?; echo "$@: FAILED: parallel make in $$D" >&2; \
1475+
echo "To investigate, try: (MAKEFLAGS='$(MAKEFLAGS)' ; export MAKEFLAGS; $(MAKE) $(AM_MAKEFLAGS) $${PARMAKES_OPT} clean ; automake -f && ./config.status && clear && (cd $${D}/ && $(MAKE) $(AM_MAKEFLAGS) V=1 $${PARMAKES_OPT} 2>&1 ; echo $$?) | tee /tmp/make.log ; RES=$$? ; grep -E '(\] Error|No rule to)' /tmp/make.log && less /tmp/make.log ; exit $$RES )"; \
14761476
echo "If builds were interrupted before, you may also have to re-initialize the build area completely, e.g.: git clean -fdX ; ./ci_build.sh && $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) $@" ; \
14771477
exit $$RES; } ; \
14781478
DIRS="$${DIRS} $${D}" ; \

ci_build.sh

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,14 @@ fi
513513
# For two-phase builds (quick parallel make first, sequential retry if failed)
514514
# how verbose should that first phase be? Nothing, automake list of ops, CLIs?
515515
# See build_to_only_catch_errors_target() for a consumer of this setting.
516+
# CI_PARMAKE_VERBOSITY_CPB is for "check-parallel-builds" part below.
516517
case "${CI_PARMAKE_VERBOSITY-}" in
517-
silent|quiet|verbose|default) ;;
518-
*) CI_PARMAKE_VERBOSITY=silent ;;
518+
silent|quiet|verbose|default)
519+
[ -n "${CI_PARMAKE_VERBOSITY_CPB-}" ] || CI_PARMAKE_VERBOSITY_CPB="${CI_PARMAKE_VERBOSITY-}"
520+
;;
521+
*) CI_PARMAKE_VERBOSITY=silent
522+
[ -n "${CI_PARMAKE_VERBOSITY_CPB-}" ] || CI_PARMAKE_VERBOSITY_CPB=quiet
523+
;;
519524
esac
520525

521526
# Set up the parallel make with reasonable limits, using several ways to
@@ -636,6 +641,11 @@ for L in $NODE_LABELS ; do
636641
[ -n "$CANBUILD_WITH_LIBLTDL" ] || CANBUILD_WITH_LIBLTDL=no ;;
637642
"NUT_BUILD_CAPS=libltdl"|"NUT_BUILD_CAPS=libltdl=yes")
638643
[ -n "$CANBUILD_WITH_LIBLTDL" ] || CANBUILD_WITH_LIBLTDL=yes ;;
644+
645+
# For now like this; VM systems with a clock skew can have natural
646+
# problems with parallel tasks, which we can not do much about.
647+
"NUT_BUILD_CAPS=check-parallel-builds=no")
648+
[ -n "${CI_DO_CHECK_PARALLEL_BUILDS-}" ] || CI_DO_CHECK_PARALLEL_BUILDS=false ;;
639649
esac
640650
done
641651

@@ -1945,6 +1955,16 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
19451955
echo "NOTE: adapted BUILD_TYPE 'default-all-errors' => '${BUILD_TYPE}'" >&2
19461956
fi
19471957

1958+
if [ x"${HAVE_CCACHE-}" = xyes ] && [ x"${CI_DO_CHECK_PARALLEL_BUILDS-}" = x ] ; then
1959+
# Ideally massive-build CI recipes would set this option
1960+
# for scenarios they are interested in, e.g. once per OS
1961+
# and make implementation, not all hundreds of builds?..
1962+
# On the other hand, catching issues (race conditions in
1963+
# recipes) is a big-numbers game...
1964+
CI_DO_CHECK_PARALLEL_BUILDS=true
1965+
echo "NOTE: we have ccache, so enabled 'make check-parallel-builds' for combos below" >&2
1966+
fi
1967+
19481968
# Try to run various build scenarios to collect build errors
19491969
# (no checks here) as configured further by caller's choice
19501970
# of BUILD_WARNFATAL and/or BUILD_WARNOPT envvars above.
@@ -2298,6 +2318,12 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
22982318
;;
22992319
esac
23002320

2321+
# Snippet from autogen.sh: restore files required by autoconf
2322+
# for non-"foreign" projects that a deep clean in other loops
2323+
# could have destroyed:
2324+
[ -f "${SCRIPTDIR}/NEWS" ] || { echo "Please see NEWS.adoc for actual contents" > "${SCRIPTDIR}/NEWS"; }
2325+
[ -f "${SCRIPTDIR}/README" ] || { echo "Please see README.adoc for actual contents" > "${SCRIPTDIR}/README"; }
2326+
23012327
configure_nut
23022328
) || {
23032329
RES_ALLERRORS=$?
@@ -2340,6 +2366,27 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
23402366
fi
23412367
}
23422368

2369+
# Check that the current MAKE implementation deals with parallel
2370+
# recipes properly. Ideally this is sped up by ccache. At least
2371+
# privately CI_FAILFAST=true to not retry this one sequentially:
2372+
if [ x"$CI_DO_CHECK_PARALLEL_BUILDS" = xtrue ] ; then
2373+
CI_FAILFAST=true \
2374+
CI_PARMAKE_VERBOSITY="${CI_PARMAKE_VERBOSITY_CPB-}" \
2375+
CHECK_PARALLEL_BUILDS_REGEN=false \
2376+
build_to_only_catch_errors_target check-parallel-builds && {
2377+
SUCCEEDED+=("TESTCOMBO=${TESTCOMBO}[check-parallel-builds]")
2378+
} || {
2379+
RES_ALLERRORS=$?
2380+
FAILED+=("TESTCOMBO=${TESTCOMBO}[check-parallel-builds]")
2381+
# Help find end of build (before cleanup noise) in logs:
2382+
echo "=== FAILED 'TESTCOMBO=${TESTCOMBO}' check-parallel-builds"
2383+
if [ "$CI_FAILFAST" = true ]; then
2384+
echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2
2385+
break
2386+
fi
2387+
}
2388+
fi
2389+
23432390
# Note: when `expr` calculates a zero value below, it returns
23442391
# an "erroneous" `1` as exit code. Why oh why?..
23452392
# (UPDATE: because expr returns boolean, and calculated 0 is false;

0 commit comments

Comments
 (0)