transformations: Add support for zig.

* guix/transformations.scm (tuning-compiler): Add support for zig.

Change-Id: I40bd28071c97c0dd0a907c704072b52b26d2de28
Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
This commit is contained in:
Ekaitz Zarraga 2023-11-18 17:51:09 +01:00 committed by Efraim Flashner
parent 87bb9c9664
commit 2cc6e09a03
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -3,6 +3,7 @@
;;; Copyright © 2021 Marius Bakke <marius@gnu.org> ;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
;;; Copyright © 2023 Sarthak Shah <shahsarthakw@gmail.com> ;;; Copyright © 2023 Sarthak Shah <shahsarthakw@gmail.com>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 Ekaitz Zarraga <ekaitz@elenq.tech>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -439,7 +440,8 @@ (define tuning-compiler
actual compiler." actual compiler."
(define wrapper (define wrapper
#~(begin #~(begin
(use-modules (ice-9 match)) (use-modules (ice-9 match)
(ice-9 string-fun))
(define psabi #$(gcc-architecture->micro-architecture-level (define psabi #$(gcc-architecture->micro-architecture-level
micro-architecture)) micro-architecture))
@ -486,11 +488,20 @@ (define this
(apply (apply
execl next execl next
(append (cons next arguments) (append (cons next arguments)
(if (and (search-next "go") (cond
(string=? next (search-next "go"))) ((and (search-next "go")
'() (string=? next (search-next "go")))
(list (string-append "-march=" '())
#$micro-architecture))))))))))) ((and (search-next "zig")
(string=? next (search-next "zig")))
`(,(string-append
;; https://issues.guix.gnu.org/67075#3
"-Dcpu="
(string-replace-substring
#$micro-architecture "-" "_"))))
(else
(list (string-append "-march="
#$micro-architecture))))))))))))
(define program (define program
(program-file (string-append "tuning-compiler-wrapper-" micro-architecture) (program-file (string-append "tuning-compiler-wrapper-" micro-architecture)
@ -508,7 +519,7 @@ (define bin (string-append #$output "/bin"))
(symlink #$program (symlink #$program
(string-append bin "/" program))) (string-append bin "/" program)))
'("cc" "gcc" "clang" "g++" "c++" "clang++" '("cc" "gcc" "clang" "g++" "c++" "clang++"
"go"))))))) "go" "zig")))))))
(define (build-system-with-tuning-compiler bs micro-architecture) (define (build-system-with-tuning-compiler bs micro-architecture)
"Return a variant of BS, a build system, that ensures that the compiler that "Return a variant of BS, a build system, that ensures that the compiler that