[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Makefile: Speed up .go compilation.
From: |
Taylan Ulrich Bayırlı/Kammer |
Subject: |
[PATCH] Makefile: Speed up .go compilation. |
Date: |
Thu, 12 Nov 2015 17:41:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
This does the same thing as the 'guix pull' patch, but for our Makefile.
Improvement suggestions welcome, since it's pretty hacky.
>From f205496e8f08c3621d2ffe2c802da1f9e367e2b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
<address@hidden>
Date: Thu, 5 Nov 2015 23:42:45 +0100
Subject: [PATCH 1/2] 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 | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 14 deletions(-)
create mode 100644 build-aux/compile-all.scm
diff --git a/Makefile.am b/Makefile.am
index 67d483b..bf73823 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -335,14 +335,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
@@ -352,14 +344,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
@@ -451,6 +445,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..b97ce8f
--- /dev/null
+++ b/build-aux/compile-all.scm
@@ -0,0 +1,41 @@
+(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"))
+
+(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))
+ (format #t " LOAD ~s~%" file)
+ (save-module-excursion
+ (lambda ()
+ (primitive-load file))))))
+ 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.5.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Makefile: Speed up .go compilation.,
Taylan Ulrich Bayırlı/Kammer <=