mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-26 14:28:15 -05:00
transformations: Wrap go binary.
* guix/transformations.scm (tuning-compiler): Adjust to wrap the go binary with the appropriate environment variable. (build-system-with-tuning-compiler): Remove custom 'set-microarchitecture phase.
This commit is contained in:
parent
11751b016d
commit
1fd4f544b3
1 changed files with 22 additions and 24 deletions
|
@ -441,6 +441,9 @@ (define wrapper
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (ice-9 match))
|
(use-modules (ice-9 match))
|
||||||
|
|
||||||
|
(define psabi #$(gcc-architecture->micro-architecture-level
|
||||||
|
micro-architecture))
|
||||||
|
|
||||||
(define* (search-next command
|
(define* (search-next command
|
||||||
#:optional
|
#:optional
|
||||||
(path (string-split (getenv "PATH")
|
(path (string-split (getenv "PATH")
|
||||||
|
@ -469,10 +472,25 @@ (define this
|
||||||
(match (search-next (basename command))
|
(match (search-next (basename command))
|
||||||
(#f (exit 127))
|
(#f (exit 127))
|
||||||
(next
|
(next
|
||||||
(apply execl next
|
(if (and (search-next "go")
|
||||||
|
(string=? next (search-next "go")))
|
||||||
|
(cond
|
||||||
|
((string-prefix? "arm" psabi)
|
||||||
|
(setenv "GOARM" (string-take-right psabi 1)))
|
||||||
|
((string-prefix? "powerpc" psabi)
|
||||||
|
(setenv "GOPPC64" psabi))
|
||||||
|
((string-prefix? "x86_64" psabi)
|
||||||
|
(setenv "GOAMD" (string-take-right psabi 2)))
|
||||||
|
(else #t))
|
||||||
|
'())
|
||||||
|
(apply
|
||||||
|
execl next
|
||||||
(append (cons next arguments)
|
(append (cons next arguments)
|
||||||
|
(if (and (search-next "go")
|
||||||
|
(string=? next (search-next "go")))
|
||||||
|
'()
|
||||||
(list (string-append "-march="
|
(list (string-append "-march="
|
||||||
#$micro-architecture))))))))))
|
#$micro-architecture)))))))))))
|
||||||
|
|
||||||
(define program
|
(define program
|
||||||
(program-file (string-append "tuning-compiler-wrapper-" micro-architecture)
|
(program-file (string-append "tuning-compiler-wrapper-" micro-architecture)
|
||||||
|
@ -489,7 +507,8 @@ (define bin (string-append #$output "/bin"))
|
||||||
(for-each (lambda (program)
|
(for-each (lambda (program)
|
||||||
(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")))))))
|
||||||
|
|
||||||
(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
|
||||||
|
@ -564,27 +583,6 @@ (define (lower* . args)
|
||||||
|
|
||||||
(bag
|
(bag
|
||||||
(inherit lowered)
|
(inherit lowered)
|
||||||
(arguments
|
|
||||||
(substitute-keyword-arguments (bag-arguments lowered)
|
|
||||||
;; We add the tuning parameter after the default GO flags are set.
|
|
||||||
((#:phases phases '%standard-phases)
|
|
||||||
#~(modify-phases #$phases
|
|
||||||
(add-after 'setup-go-environment 'set-microarchitecture
|
|
||||||
(lambda _
|
|
||||||
(cond
|
|
||||||
((string-prefix? "arm" #$psabi)
|
|
||||||
(setenv "GOARM" (string-take-right #$psabi 1))
|
|
||||||
(format #t "Setting GOARM to ~s."
|
|
||||||
(getenv "GOARM")))
|
|
||||||
((string-prefix? "powerpc" #$psabi)
|
|
||||||
(setenv "GOPPC64" #$psabi)
|
|
||||||
(format #t "Setting GOPPC64 to ~s."
|
|
||||||
(getenv "GOPPC64")))
|
|
||||||
((string-prefix? "x86_64" #$psabi)
|
|
||||||
(setenv "GOAMD" (string-take-right #$psabi 2))
|
|
||||||
(format #t "Setting GOAMD to ~s.\n"
|
|
||||||
(getenv "GOAMD")))
|
|
||||||
(else #t))))))))
|
|
||||||
(build-inputs
|
(build-inputs
|
||||||
;; Arrange so that the compiler wrapper comes first in $PATH.
|
;; Arrange so that the compiler wrapper comes first in $PATH.
|
||||||
`(("tuning-compiler" ,(tuning-compiler micro-architecture))
|
`(("tuning-compiler" ,(tuning-compiler micro-architecture))
|
||||||
|
|
Loading…
Reference in a new issue