unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: guix-devel@gnu.org
Subject: [PATCH] build: Speed up .go compilation.
Date: Fri, 08 Jan 2016 12:48:56 +0100	[thread overview]
Message-ID: <87mvsgxpef.fsf@T420.taylan> (raw)
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")

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

Here's an updated version that uses the same strategy as the one we
settled on for 'guix pull'.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-build-Speed-up-.go-compilation.patch --]
[-- Type: text/x-diff, Size: 4043 bytes --]

From 220a8caed6da22e349545899d5c51083bb3a8ac5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
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
 # <http://git.sv.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=e2c6bf3866d1186c60bacfbd4fe5037087ee5e3f>.
-.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-mtime<? f1 f2)
+  (< (stat:mtime (stat f1))
+     (stat:mtime (stat f2))))
+
+(define (scm->go 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-mtime<? file go))
+         (let ((module (file->module 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<? file go))
+               (with-mutex mutex
+                 (format #t "  GUILEC ~s~%" file)
+                 (force-output))
+               (compile-file file #:output-file go #:opts compile-options)
+               (with-mutex mutex
+                 (format #t "  WROTE ~s~%" go)
+                 (force-output)))))
+         files)))))
-- 
2.6.3


  reply	other threads:[~2016-01-08 11:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 16:41 [PATCH] Makefile: Speed up .go compilation Taylan Ulrich Bayırlı/Kammer
2016-01-08 11:48 ` Taylan Ulrich Bayırlı/Kammer [this message]
2016-01-08 17:06   ` [PATCH] build: " Ludovic Courtès
2016-01-09 19:38     ` Taylan Ulrich Bayırlı/Kammer
2016-01-09 21:59       ` Ludovic Courtès
2016-01-10 10:24         ` Taylan Ulrich Bayırlı/Kammer
2016-01-10 17:01           ` Mathieu Lirzin
2016-01-10 20:46             ` Taylan Ulrich Bayırlı/Kammer
2016-01-11 21:16           ` Ludovic Courtès
2016-01-10 13:34         ` Taylan Ulrich Bayırlı/Kammer
2016-01-10 15:11         ` Taylan Ulrich Bayırlı/Kammer
2016-01-10 17:27           ` Mathieu Lirzin
2016-01-10 20:52             ` Taylan Ulrich Bayırlı/Kammer
2016-01-10 21:18               ` Mathieu Lirzin
2016-01-11 21:05                 ` Ludovic Courtès
2016-01-11 21:47                   ` Taylan Ulrich Bayırlı/Kammer
2016-01-10 16:47     ` Mark H Weaver
2016-01-10 20:33       ` Taylan Ulrich Bayırlı/Kammer
2016-01-11 21:14       ` Ludovic Courtès
2016-01-11 21:56         ` Taylan Ulrich Bayırlı/Kammer
2016-01-14 14:02           ` Ludovic Courtès
2016-01-17 20:16             ` Ludovic Courtès
2016-01-18  8:05               ` Taylan Ulrich Bayırlı/Kammer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvsgxpef.fsf@T420.taylan \
    --to=taylanbayirli@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).