diff mbox series

[bug#62438,v2] gnu: llvm: Fix riscv64 cross-compilation.

Message ID 60563288b330dca2f53335fe7e385420666fb04f.1694083301.git.iyzsong@member.fsf.org
State New
Headers show
Series [bug#62438,v2] gnu: llvm: Fix riscv64 cross-compilation. | expand

Commit Message

vasilii.smirnov--- via Guix-patches" via Sept. 7, 2023, 10:42 a.m. UTC
From: Z572 <873216071@qq.com>

* gnu/packages/llvm.scm (system->llvm-target-arch): New procedure.
(llvm-15,llvm-14,llvm-12): Use It.
(system->llvm-target): Rewrite in terms of 'system->llvm-target-arch'.

Co-authored-by: 宋文武 <iyzsong@member.fsf.org>
---
 gnu/packages/llvm.scm | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)


base-commit: 5ef28595e9dff8b88ec3fcb4d887fbc380c9a8b8

Comments

Ludovic Courtès Oct. 19, 2023, 7:55 p.m. UTC | #1
Hi,

iyzsong@envs.net skribis:

> From: Z572 <873216071@qq.com>
>
> * gnu/packages/llvm.scm (system->llvm-target-arch): New procedure.
> (llvm-15,llvm-14,llvm-12): Use It.
> (system->llvm-target): Rewrite in terms of 'system->llvm-target-arch'.
>
> Co-authored-by: 宋文武 <iyzsong@member.fsf.org>

I guess you can go ahead and apply it (sorry for dropping the ball
earlier!).

Thanks,
Ludo’.
宋文武 Oct. 20, 2023, 9:58 a.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> iyzsong@envs.net skribis:
>
>> From: Z572 <873216071@qq.com>
>>
>> * gnu/packages/llvm.scm (system->llvm-target-arch): New procedure.
>> (llvm-15,llvm-14,llvm-12): Use It.
>> (system->llvm-target): Rewrite in terms of 'system->llvm-target-arch'.
>>
>> Co-authored-by: 宋文武 <iyzsong@member.fsf.org>
>
> I guess you can go ahead and apply it (sorry for dropping the ball
> earlier!).
>

Pushed, thank you!
diff mbox series

Patch

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index daff67f7f2..cd551f4e02 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -85,19 +85,32 @@  (define* (system->llvm-target #:optional
   "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.
+  (match (system->llvm-target-arch system)
+    ("RISCV64" "RISCV")
+    ("X86_64" "X86")
+    (x x)))
+
+(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 for system is unknown" system)))))
+                              (error "LLVM target arch for system is unknown" system)))))
     (matches ("aarch64"     => "AArch64")
              ("armhf"       => "ARM")
              ("mips64el"    => "Mips")
              ("powerpc"     => "PowerPC")
-             ("riscv"       => "RISCV")
-             ("x86_64"      => "X86")
+             ("riscv64"     => "RISCV64")
+             ("x86_64"      => "X86_64")
              ("i686"        => "X86")
              ("i586"        => "X86"))))
 
@@ -598,7 +611,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 +671,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)))
                 '())
@@ -901,7 +914,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)))
                    #~())