aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-07-23 16:57:25 +0200
committerLudovic Courtès <ludo@gnu.org>2019-07-24 00:31:22 +0200
commit96a9a8d398b0bbb44ad96d41597a8f0323628e86 (patch)
treec96c4047345798bab316908fd7a562b86da989b1 /gnu
parentc42db89ff992037841e7937059db952571af86fa (diff)
downloadguix-96a9a8d398b0bbb44ad96d41597a8f0323628e86.tar
guix-96a9a8d398b0bbb44ad96d41597a8f0323628e86.tar.gz
gnu: llvm: Add 'system->llvm-target' procedure.
* gnu/packages/llvm.scm (system->llvm-target): New procedure.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/llvm.scm25
1 files changed, 24 insertions, 1 deletions
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 1fe9af38e0..9efb4a4841 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -46,7 +46,30 @@
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
- #:use-module (gnu packages xml))
+ #:use-module (gnu packages xml)
+ #:export (system->llvm-target))
+
+(define* (system->llvm-target #:optional
+ (system (or (and=> (%current-target-system)
+ gnu-triplet->nix-system)
+ (%current-system))))
+ "Return the LLVM target name that corresponds to SYSTEM, a system type such
+as \"x86_64-linux\"."
+ ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
+ (letrec-syntax ((matches (syntax-rules (=>)
+ ((_ (system-prefix => target) rest ...)
+ (if (string-prefix? system-prefix system)
+ target
+ (matches rest ...)))
+ ((_)
+ (error "LLVM target for system is unknown" system)))))
+ (matches ("aarch64" => "AArch64")
+ ("armhf" => "ARM")
+ ("mips64el" => "Mips")
+ ("powerpc" => "PowerPC")
+ ("riscv" => "RISCV")
+ ("x86_64" => "X86")
+ ("i686" => "X86"))))
(define-public llvm-8
(package