summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-05-13 23:17:49 +0200
committerLudovic Courtès <ludo@gnu.org>2020-05-13 23:35:57 +0200
commita4d76a514fed7bdd5f6dc0fdc69942d7ad3f65f1 (patch)
tree5b9cf90a4a75b88fe663860928060f06003d1ac5
parentad263045b9bf016d6f4fbb1f7fde0f51d3194944 (diff)
downloadguix-a4d76a514fed7bdd5f6dc0fdc69942d7ad3f65f1.tar.gz
compile: Reduce optimization levels for gnu/services and gnu/packages.
* guix/build/compile.scm (optimization-options)[strip-option]
[override-option]: New procedures.
Add case for "gnu/services".  Change "gnu/packages" to
'-O0 -Opartial-eval'.
-rw-r--r--guix/build/compile.scm29
1 files changed, 26 insertions, 3 deletions
diff --git a/guix/build/compile.scm b/guix/build/compile.scm
index c4dbb6e34c..63f24fa7d4 100644
--- a/guix/build/compile.scm
+++ b/guix/build/compile.scm
@@ -84,9 +84,32 @@
 
 (define (optimization-options file)
   "Return the default set of optimizations options for FILE."
-  (if (string-contains file "gnu/packages/")
-      (optimizations-for-level 1)                 ;build faster
-      (optimizations-for-level 3)))
+  (define (strip-option option lst)
+    (let loop ((lst lst)
+               (result '()))
+      (match lst
+        (()
+         (reverse result))
+        ((kw value rest ...)
+         (if (eq? kw option)
+             (append (reverse result) rest)
+             (loop rest (cons* value kw result)))))))
+
+  (define (override-option option value lst)
+    `(,option ,value ,@(strip-option option lst)))
+
+  (cond ((string-contains file "gnu/packages/")
+         ;; Level 0 is good enough but partial evaluation helps preserve the
+         ;; "macro writer's bill of rights".
+         (override-option #:partial-eval? #t
+                          (optimizations-for-level 0)))
+        ((string-contains file "gnu/services/")
+         ;; '-O2 -Ono-letrectify' compiles about ~20% faster than '-O2' for
+         ;; large files like gnu/services/mail.scm.
+         (override-option #:letrectify? #f
+                          (optimizations-for-level 2)))
+        (else
+         (optimizations-for-level 3))))
 
 (define (scm->go file)
   "Strip the \".scm\" suffix from FILE, and append \".go\"."