bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] shuffle: disable by default


From: Yann E. MORIN
Subject: [PATCH] shuffle: disable by default
Date: Sun, 16 Oct 2022 12:17:12 +0200

Commit 621d3196fae9 ([SV 62100] Add '--shuffle' option support)
introduced randomisation of prerequisites, so as to detect more
build ordering issues, especially with parallel builds. It also
made randomisation the default.

However, this breaks Makefiles that were so far functional, when
they assumed the prerequisite ordering was kept (e.g. [0] [1]).
Even though those packages are semantically broken, there is no
reason to break them by changing the previous behaviour that they
expected.

This change reverts the default to keep the pre-requisite order
as it was before the introduction of the shuffling option.

Hopefully, with time, buildsystems (like Buildroot, OpenEmbedded,
as well as distributions) will enable shuffling and fix packages
upstream, so that in the future we may revert back to enabling
randomisation by default.

[0] 
http://autobuild.buildroot.org/results/468/468aa35c79cc8cbb34d86325c0b544a4841d14d3/build-end.log
[1] 
http://autobuild.buildroot.org/results/624/6242112c75c76e85b207ae72fdede5717f07903d/build-end.log

* src/main.c (switches): change default for --shuffle
* doc/make.1, doc/make.texi: Ditto
* tests/scripts/options/shuffle: Adapt: explicitly use =random, add
  new test to test =none by default

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Sergei Trofimovich <siarheit@google.com>
Cc: Paul Smith <psmith@gnu.org>
Cc: James Hilliard <james.hilliard1@gmail.com>

---
$ make check
...
options/shuffle ......................................... ok     (13 passed)
...
1203 Tests in 133 Categories Complete ... No Failures :-)
...
 Regression PASSED: GNU Make 4.3.91 (x86_64-pc-linux-gnu) built with gcc
---
 AUTHORS                       |  1 +
 doc/make.1                    |  2 +-
 doc/make.texi                 | 11 ++++++-----
 src/main.c                    |  2 +-
 tests/scripts/options/shuffle | 17 +++++++++++------
 5 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 35719b99..e8e4d6f8 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -77,6 +77,7 @@ Other contributors:
   Tim Magill <tim.magill@telops.gte.com>
   Markus Mauhart <qwe123@chello.at>
   Greg McGary <greg@mcgary.org>
+  Yann E. MORIN <yann.morin,1998@free.fr>
   Thien-Thi Nguyen <ttn@gnuvola.org>
   Han-Wen Nienhuys <hanwen@cs.uu.nl>
   Enrique Olaizola <enrique_olaizola16@hotmail.com>
diff --git a/doc/make.1 b/doc/make.1
index 0fd0104d..cfcd9480 100644
--- a/doc/make.1
+++ b/doc/make.1
@@ -347,7 +347,7 @@ mode with a specific
 value.  If
 .I MODE
 is omitted the default is
-.IR random .
+.IR none .
 .TP 0.5i
 \fB\-W\fR \fIfile\fR, \fB\-\-what\-if\fR=\fIfile\fR, 
\fB\-\-new\-file\fR=\fIfile\fR, \fB\-\-assume\-new\fR=\fIfile\fR
 Pretend that the target
diff --git a/doc/make.texi b/doc/make.texi
index 79dc34dc..ae114eb4 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -9684,10 +9684,10 @@ The @samp{--shuffle=} option accepts these values:
 
 @table @code
 @item random
-Choose a random seed for the shuffle.  This is the default if no mode is
-specified.  The chosen seed is also provided to sub-@code{make} commands.  The
-seed is included in error messages so that it can be re-used in future runs to
-reproduce the problem or verify that it has been resolved.
+Choose a random seed for the shuffle.  The chosen seed is also provided to
+sub-@code{make} commands.  The seed is included in error messages so that it
+can be re-used in future runs to reproduce the problem or verify that it has
+been resolved.
 
 @item reverse
 Reverse the order of goals and prerequisites, rather than a random shuffle.
@@ -9697,7 +9697,8 @@ Use @samp{random} shuffle initialized with the specified 
seed value.  The
 @var{seed} is an integer.
 
 @item none
-Disable shuffling.  This negates any previous @samp{--shuffle} options.
+Disable shuffling.  This negates any previous @samp{--shuffle} options.  This
+is the default if no mode is specified.
 @end table
 
 @item -t
diff --git a/src/main.c b/src/main.c
index afca0656..39cc9c4f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -491,7 +491,7 @@ static const struct command_switch switches[] =
     { CHAR_MAX+9, string, &jobserver_auth, 1, 0, 0, 0, 0, "jobserver-fds" },
     /* There is special-case handling for this in decode_switches() as well.  
*/
     { TEMP_STDIN_OPT, filename, &makefiles, 0, 0, 0, 0, 0, "temp-stdin" },
-    { CHAR_MAX+11, string, &shuffle_mode, 1, 1, 0, "random", 0, "shuffle" },
+    { CHAR_MAX+11, string, &shuffle_mode, 1, 1, 0, "none", 0, "shuffle" },
     { CHAR_MAX+12, string, &jobserver_style, 1, 0, 0, 0, 0, "jobserver-style" 
},
     { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
   };
diff --git a/tests/scripts/options/shuffle b/tests/scripts/options/shuffle
index 5661683c..d21c8be4 100644
--- a/tests/scripts/options/shuffle
+++ b/tests/scripts/options/shuffle
@@ -4,11 +4,13 @@ $description = "Test the --shuffle option.";
 
 $details = "Verify that --shuffle has expected effect on target order and 
argument order.";
 
-#
-# Test --shuffle=random
-#
+# TEST 0: No option should yield original order
 
-# TEST 1: Fixed seed should yield the same order from run to run.
+run_make_test('
+%: ; @echo $@
+all: a b c
+',
+              '', "a\nb\nc\nall");
 
 $makefile = &get_tmpfile;
 
@@ -20,6 +22,8 @@ all: a_ b_ c_ d_ e_ f_ g_ i_ j_ k_ l_
 EOF
 close(MAKEFILE);
 
+# TEST 1: Fixed seed should yield the same order from run to run.
+
 $log1 = &get_logfile;
 $log2 = &get_logfile;
 &run_make_with_options($makefile, "--shuffle=12345", $log1);
@@ -28,11 +32,12 @@ $log2 = &get_logfile;
 &compare_output(&read_file_into_string($log1), $log2);
 
 # TEST 2: Sequential runs should produce different orders.
+# The probability the two runs yield the same order is very low, but not null.
 
 $log3 = &get_logfile;
 $log4 = &get_logfile;
-&run_make_with_options($makefile, "--shuffle", $log3);
-&run_make_with_options($makefile, "--shuffle", $log4);
+&run_make_with_options($makefile, "--shuffle=random", $log3);
+&run_make_with_options($makefile, "--shuffle=random", $log4);
 
 ++$tests_run;
 if (&read_file_into_string($log3) ne &read_file_into_string($log4)) {
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]