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'.
This commit is contained in:
Ludovic Courtès 2020-05-13 23:17:49 +02:00
parent ad263045b9
commit a4d76a514f
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -84,9 +84,32 @@ (define %warnings
(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\"."