Message ID | tencent_8D1DD8728892C6DAF14D8BD4A92CFC3F4607@qq.com |
---|---|
State | New |
Headers | show |
Series | [bug#62438] gnu: llvm: Fix riscv64 cross-compilation. | expand |
Hi, Z572 <873216071@qq.com> skribis: > +(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")))) The only different compared to ‘system->llvm-target’ is “riscv64” instead of “riscv”. Why not add that line to ‘system->llvm-target’ instead of duplicating it? Thanks, Ludo’.
Ludovic Courtès <ludo@gnu.org> writes: > Hi, > > Z572 <873216071@qq.com> skribis: > >> +(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")))) > > The only different compared to ‘system->llvm-target’ is “riscv64” > instead of “riscv”. Why not add that line to ‘system->llvm-target’ > instead of duplicating it? ``` -- Performing Test HAS_MAYBE_UNINITIALIZED -- Performing Test HAS_MAYBE_UNINITIALIZED - Success CMake Error at cmake/config-ix.cmake:502 (message): Unknown architecture riscv Call Stack (most recent call first): CMakeLists.txt:776 (include) ``` because `LLVM_TARGETS_TO_BUILD' and `LLVM_TARGET_ARCH' is two option. The parameters of expectation are different. but for now, use same procedure `system->llvm-target'. for llvm 15.0.7 LLVM_TARGETS_TO_BUILD: allow `AArch64 AMDGPU ARC ARM AVR BPF CSKY DirectX Hexagon Lanai LoongArch M68k MSP430 Mips NVPTX PowerPC RISCV SPIRV Sparc SystemZ VE WebAssembly X86 XCore` see https://github.com/llvm/llvm-project/tree/release/15.x/llvm/lib/Target LLVM_TARGET_ARCH: allow `i[2-6]86 x86 amd64 x86_64 sparc powerrpc ppc64le aarch64 arm64 arm avr mips xcore msp430 hexagon s390x wasm32 wasm64 riscv32 riscv64 m68k` see https://github.com/llvm/llvm-project/blob/release/15.x/llvm/cmake/config-ix.cmake#L459-#L503 if use same procedure, some target will fail. > > Thanks, > Ludo’. -- over
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))) #~())