GNU bug report logs - #62438
[PATCH] gnu: llvm: fix riscv64 cross-compile.

Previous Next

Package: guix-patches;

Reported by: Z572 <873216071 <at> qq.com>

Date: Sat, 25 Mar 2023 12:14:01 UTC

Severity: normal

Tags: patch

Done: 宋文武 <iyzsong <at> envs.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Z572 <873216071 <at> qq.com>
To: 62438 <at> debbugs.gnu.org
Subject: [bug#62438] [PATCH] gnu: llvm: Fix riscv64 cross-compilation.
Date: Sat,  8 Apr 2023 13:32:59 +0800
* gnu/packages/llvm.scm (system->llvm-target-arch): New procedure.
(llvm-15,llvm-14,llvm-12): Use It.
---
 gnu/packages/llvm.scm | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index e5bf9f5cae..46cbd4d15a 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -101,6 +101,30 @@ (define* (system->llvm-target #:optional
              ("i686"        => "X86")
              ("i586"        => "X86"))))
 
+(define* (system->llvm-target-arch #:optional
+                                   (system (or (and=> (%current-target-system)
+                                                      gnu-triplet->nix-system)
+                                               (%current-system))))
+  "Return the LLVM target arch name that corresponds to SYSTEM, a system type such
+as \"x86_64-linux\"."
+  ;; See the 'cmake/config-ix.cmake' file of LLVM for a list of supported targets arch.
+  ;; start with # Determine the native architecture.
+  (letrec-syntax ((matches (syntax-rules (=>)
+                             ((_ (system-prefix => target) rest ...)
+                              (if (string-prefix? system-prefix system)
+                                  target
+                                  (matches rest ...)))
+                             ((_)
+                              (error "LLVM target arch for system is unknown" system)))))
+    (matches ("aarch64"     => "AArch64")
+             ("armhf"       => "ARM")
+             ("mips64el"    => "Mips")
+             ("powerpc"     => "PowerPC")
+             ("riscv64"     => "RISCV64")
+             ("x86_64"      => "X86_64")
+             ("i686"        => "X86")
+             ("i586"        => "X86"))))
+
 (define (llvm-uri component version)
   ;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz'
   ;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name.
@@ -598,7 +622,7 @@ (define-public llvm-15
                    #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
                                     (%current-target-system))
                    #$(string-append "-DLLVM_TARGET_ARCH="
-                                    (system->llvm-target))
+                                    (system->llvm-target-arch))
                    #$(string-append "-DLLVM_TARGETS_TO_BUILD="
                                     (system->llvm-target)))
                 '())
@@ -658,7 +682,7 @@ (define-public llvm-14
                    #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
                                     (%current-target-system))
                    #$(string-append "-DLLVM_TARGET_ARCH="
-                                    (system->llvm-target))
+                                    (system->llvm-target-arch))
                    #$(string-append "-DLLVM_TARGETS_TO_BUILD="
                                     (system->llvm-target)))
                 '())
@@ -910,7 +934,7 @@ (define-public llvm-12
                       #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
                                        (%current-target-system))
                       #$(string-append "-DLLVM_TARGET_ARCH="
-                                       (system->llvm-target))
+                                       (system->llvm-target-arch))
                       #$(string-append "-DLLVM_TARGETS_TO_BUILD="
                                        (system->llvm-target)))
                    #~())

base-commit: 6311493d7a6271bfbc51f4693857f9a12fe9965d
-- 
2.39.2





This bug report was last modified 1 year and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.