From mboxrd@z Thu Jan 1 00:00:00 1970 From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Subject: [PATCH] build: Speed up .go compilation. Date: Fri, 08 Jan 2016 12:48:56 +0100 Message-ID: <87mvsgxpef.fsf@T420.taylan> References: <87lha3rx04.fsf@T420.taylan> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHVWF-0002KM-Sl for guix-devel@gnu.org; Fri, 08 Jan 2016 06:47:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHVWE-0004jA-H6 for guix-devel@gnu.org; Fri, 08 Jan 2016 06:47:47 -0500 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:35440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHVWE-0004j0-6h for guix-devel@gnu.org; Fri, 08 Jan 2016 06:47:46 -0500 Received: by mail-wm0-x229.google.com with SMTP id f206so131963321wmf.0 for ; Fri, 08 Jan 2016 03:47:45 -0800 (PST) Received: from T420.taylan ([2a02:908:c32:de0:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id s8sm54134881wje.35.2016.01.08.03.47.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jan 2016 03:47:43 -0800 (PST) In-Reply-To: <87lha3rx04.fsf@T420.taylan> ("Taylan Ulrich \=\?utf-8\?Q\?\=5C\=22Bay\=C4\=B1rl\=C4\=B1\=2FKammer\=5C\=22\=22's\?\= message of "Thu, 12 Nov 2015 17:41:15 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain Here's an updated version that uses the same strategy as the one we settled on for 'guix pull'. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-build-Speed-up-.go-compilation.patch >From 220a8caed6da22e349545899d5c51083bb3a8ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?= Date: Thu, 5 Nov 2015 23:42:45 +0100 Subject: [PATCH] build: Speed up .go compilation. * build-aux/compile-all.scm: New file. * Makefile.am: Call build-aux/compile-all.scm to compile many .scm files in a single process. --- Makefile.am | 22 ++++++++-------------- build-aux/compile-all.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 build-aux/compile-all.scm diff --git a/Makefile.am b/Makefile.am index 760caed..4aa459d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -341,14 +341,6 @@ CLEANFILES = \ $(GOBJECTS) \ $(SCM_TESTS:tests/%.scm=%.log) -AM_V_GUILEC = $(AM_V_GUILEC_$(V)) -AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY)) -AM_V_GUILEC_0 = @echo " GUILEC" $@; - -# Flags passed to 'guild compile'. -GUILD_COMPILE_FLAGS = \ - -Wformat -Wunbound-variable -Warity-mismatch - # Unset 'GUILE_LOAD_COMPILED_PATH' altogether while compiling. Otherwise, if # $GUILE_LOAD_COMPILED_PATH contains $(moduledir), we may find .go files in # there that are newer than the local .scm files (for instance because the @@ -358,14 +350,16 @@ GUILD_COMPILE_FLAGS = \ # # XXX: Use the C locale for when Guile lacks # . -.scm.go: - $(AM_V_GUILEC)$(MKDIR_P) `dirname "$@"` ; \ +%.go: make-go ; @: +make-go: $(MODULES) + for f in $^; do \ + $(MKDIR_P) `dirname "$$f"` ; \ + done ; \ unset GUILE_LOAD_COMPILED_PATH ; \ LC_ALL=C \ $(top_builddir)/pre-inst-env \ - $(GUILD) compile -L "$(top_builddir)" -L "$(top_srcdir)" \ - $(GUILD_COMPILE_FLAGS) --target="$(host)" \ - -o "$@" "$<" + $(GUILE) -L "$(top_builddir)" -L "$(top_srcdir)" \ + --no-auto-compile -s build-aux/compile-all.scm $(host) $^ SUFFIXES = .go @@ -457,6 +451,6 @@ assert-final-inputs-self-contained: $(top_builddir)/pre-inst-env "$(GUILE)" \ "$(top_srcdir)/build-aux/check-final-inputs-self-contained.scm" -.PHONY: sync-descriptions gen-ChangeLog gen-AUTHORS clean-go +.PHONY: sync-descriptions gen-ChangeLog gen-AUTHORS clean-go make-go .PHONY: assert-no-store-file-names assert-binaries-available .PHONY: assert-final-inputs-self-contained diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm new file mode 100644 index 0000000..f546822 --- /dev/null +++ b/build-aux/compile-all.scm @@ -0,0 +1,44 @@ +(use-modules (system base target) + (ice-9 threads)) + +(define compile-options '(format unbound-variable arity-mismatch)) + +(define (file-mtimego file) + (string-append (string-drop-right file 4) ".go")) + +(define (file->module file) + (map string->symbol + (string-split (string-drop-right file 4) #\/))) + +(let* ((args (cdr (command-line))) + (target (car args)) + (files (cdr args))) + (for-each + (lambda (file) + (let ((go (scm->go file))) + (unless (and (file-exists? go) + (file-mtimemodule file))) + (format #t " LOAD ~s~%" module) + (resolve-interface module))))) + files) + (with-target target + (lambda () + (let ((mutex (make-mutex))) + (par-for-each + (lambda (file) + (let ((go (scm->go file))) + (unless (and (file-exists? go) + (file-mtime