Context

GNU Make now has a --shuffle option that simulates non-deterministic ordering of target prerequisites. See https://trofi.github.io/posts/238-new-make-shuffle-mode.html, and also previous work in Debian by Santiago Vila.

While make always processes prerequisites left-to-right when running sequentially, prerequisites can be evaluated in an arbitrary order when building in parallel (make -j). This option is thus useful to trigger and debug issues that occur when building in parallel.

The --shuffle option can take an optional parameter: --shuffle=reverse evaluates prerequisites in reverse order (which is useful when testing packages and reproducing failures); --shuffle=random (the default) uses a random order, that can later be forced using --shuffle=<seed>.

Mass bug filing

How to debug issues

GNUMAKEFLAGS='--shuffle --trace' dpkg-buildpackage

GNUMAKEFLAGS='--shuffle=reverse --trace' dpkg-buildpackage
GNUMAKEFLAGS='--shuffle=1847628928 --trace' dpkg-buildpackage

Note that --shuffle is passed to downstream make instances (through the MAKEFLAGS environment variables). It thus detects both bugs in debian/rules and in upstream Makefiles.

Example bugs with patches

Known issues

Some packages use bmake (BSD make), which is incompatible with setting GNUMAKEFLAGS to --shuffle. What happens is that GNU Make passes --shuffle via MAKEFLAGS to child/recursive make invocations, but bmake does not understand it. The effect in the build log is usually bmake showing this error message:

usage: bmake [-BeikNnqrstWwX] 
            [-C directory] [-D variable] [-d flags] [-f makefile]
            [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]
            [-V variable] [-v variable] [variable=value] [target ...]

Affected packages are:

bsdowl
csh
herisvm
libmaa
libnbcompat
lowdown
makefs
mk-configure
paexec
runawk
udfclient
xidle