aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/llvm.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/llvm.scm')
-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