From 342ec250c34ba854eb2a9803c5401972fcecc13d Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 5 May 2013 15:06:33 +0100 Subject: [PATCH] Ugly hack to avoid recompiling the same thing multiple times in parallel. --- util/pl/unix.pl | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/util/pl/unix.pl b/util/pl/unix.pl index 72d3b441e1..b76981dc55 100644 --- a/util/pl/unix.pl +++ b/util/pl/unix.pl @@ -189,13 +189,18 @@ sub fixtests sub fixdeps { - my ($str) = @_; + my ($str, $fakes) = @_; my @t = split(/\s+/, $str); $str = ''; foreach my $t (@t) { $str .= ' ' if $str ne ''; + if (exists($fakes->{$t})) + { + $str .= $fakes->{$t}; + next; + } if ($t =~ /^[^\/]+$/) { $str .= '$(TEST_D)/' . $t; @@ -265,6 +270,7 @@ sub get_tests my %deps; my %tests; my %alltests; + my %fakes; while (my $line = ) { chomp $line; @@ -287,7 +293,22 @@ sub get_tests || $line =~ /^(?test_(ss|gen) .*):(?.*)/) { my $t = $+{t}; - $deps{$t} = $+{d}; + my $d = $+{d}; + # If there are multiple targets stupid FreeBSD make runs the + # rules once for each dependency that matches one of the + # targets. Running the same rule twice concurrently causes + # breakage, so replace with a fake target. + if ($t =~ /\s/) + { + ++$fake; + my @targets = split /\s+/, $t; + $t = "_fake$fake"; + foreach my $f (@targets) + { + $fakes{$f} = $t; + } + } + $deps{$t} = $d; $deps{$t} =~ s/#.*$//; for (;;) { @@ -326,7 +347,7 @@ sub get_tests $d =~ s/\.\.\/apps/\$(BIN_D)/g; $d =~ s/\.\.\/util/\$(TEST_D)/g; $d = fixtests($d, \%tests); - $d = fixdeps($d); + $d = fixdeps($d, \%fakes); my $r = $targets{$t}; $r =~ s/\.\.\/apps/..\/\$(BIN_D)/g; @@ -392,7 +413,18 @@ sub get_tests $scripts .= "\nocsp:\n\tcp -R test/ocsp-tests \$(TEST_D)\n"; $scripts .= "\smime:\n\tcp -R test/smime-certs \$(TEST_D)\n"; - my $all = 'test: ' . join(' ', keys %alltests); + my $all = 'test:'; + foreach my $t (keys %alltests) + { + if (exists($fakes{$t})) + { + $all .= " $fakes{$t}"; + } + else + { + $all .= " $t"; + } + } return "$scripts\n$copies\n$tests\n$all\n\n$each"; } -- 2.25.1