From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:39496) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCwhr-0006kr-JK for guix-patches@gnu.org; Tue, 24 Sep 2019 22:07:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCwhq-0005Uu-Cg for guix-patches@gnu.org; Tue, 24 Sep 2019 22:07:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60095) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iCwhq-0005Uo-9X for guix-patches@gnu.org; Tue, 24 Sep 2019 22:07:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iCwhq-0003iy-2S for guix-patches@gnu.org; Tue, 24 Sep 2019 22:07:02 -0400 Subject: [bug#37510] [PATCH 1/1] compile: Fix race condition on completion progress. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:39470) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCwhO-0006kK-6g for guix-patches@gnu.org; Tue, 24 Sep 2019 22:06:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCwhM-0005Or-OJ for guix-patches@gnu.org; Tue, 24 Sep 2019 22:06:34 -0400 Received: from mail.onyx.syn-alias.com ([206.152.134.66]:56911 helo=smtp.centurylink.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCwhM-0005OP-ER for guix-patches@gnu.org; Tue, 24 Sep 2019 22:06:32 -0400 From: ericbavier@centurylink.net Date: Tue, 24 Sep 2019 21:07:06 -0500 Message-Id: <20190925020706.6034-1-ericbavier@centurylink.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 37510@debbugs.gnu.org Cc: Eric Bavier From: Eric Bavier This prevent a race condition where multiple compilation threads could report the same completion. * guix/build/compile.scm (compile-files): Increment in same mutex region as the compilation is reported. Further reading: When compiling many scheme files, or with '-j1', this is not usually a problem, but with multiple build jobs and a handful of scheme files to update, you may encounter unexpected output. E.g. I recently saw this from `make -j2`: ``` Compiling Scheme modules... [ 25%] LOAD gnu/packages/haskell.scm ;;; note: source file ./gnu/packages/haskell.scm ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/haskell.go ;;; note: source file ./gnu/packages/haskell.scm ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/haskell.go [ 50%] LOAD gnu/packages/idris.scm ;;; note: source file ./gnu/packages/idris.scm ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/idris.go ;;; note: source file ./gnu/packages/idris.scm ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/idris.go [ 75%] GUILEC gnu/packages/haskell.go [ 75%] GUILEC gnu/packages/idris.go make[2]: Leaving directory '/home/bavier/projects/guix' make[1]: Leaving directory '/home/bavier/projects/guix' ``` --- guix/build/compile.scm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/guix/build/compile.scm b/guix/build/compile.scm index c127456fd0..f77e49340a 100644 --- a/guix/build/compile.scm +++ b/guix/build/compile.scm @@ -173,7 +173,8 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"." (define (build file) (with-mutex progress-lock - (report-compilation file total completed)) + (report-compilation file total completed) + (set! completed (+ 1 completed))) ;; Exit as soon as something goes wrong. (exit-on-exception @@ -185,9 +186,7 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"." #:output-file (string-append build-directory "/" (scm->go relative)) #:opts (append warning-options - (optimization-options relative))))))) - (with-mutex progress-lock - (set! completed (+ 1 completed)))) + (optimization-options relative)))))))) (with-augmented-search-path %load-path source-directory (with-augmented-search-path %load-compiled-path build-directory -- 2.23.0