Message ID | tencent_59877F623A46E5A925ECB59E9B3CA9655908@qq.com |
---|---|
State | New |
Headers | show |
Series | [bug#62438] gnu: llvm: fix riscv64 cross-compile. | expand |
Z572 <873216071@qq.com> writes: > - (system->llvm-target)) > + (if (target-riscv64?) > + "RISCV64" > + (system->llvm-target))) > #$(string-append "-DLLVM_TARGETS_TO_BUILD=" > (system->llvm-target))) > '()) > @@ -658,7 +661,9 @@ (define-public llvm-14 > #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" > (%current-target-system)) > #$(string-append "-DLLVM_TARGET_ARCH=" > - (system->llvm-target)) > + (if (target-riscv64?) > + "RISCV64" > + (system->llvm-target))) > #$(string-append "-DLLVM_TARGETS_TO_BUILD=" > (system->llvm-target))) > '()) Hello, our `system->llvm-target` has riscv => "RISCV", does it wrong (should be changed to RISCV64) or does it right only for 32bit RISCV? And can system->llvm-target be fixed instead of fix each its usage? Thanks!
宋文武 <iyzsong@envs.net> writes: > Z572 <873216071@qq.com> writes: > > >> - (system->llvm-target)) >> + (if (target-riscv64?) >> + "RISCV64" >> + (system->llvm-target))) >> #$(string-append "-DLLVM_TARGETS_TO_BUILD=" >> (system->llvm-target))) >> '()) >> @@ -658,7 +661,9 @@ (define-public llvm-14 >> #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" >> (%current-target-system)) >> #$(string-append "-DLLVM_TARGET_ARCH=" >> - (system->llvm-target)) >> + (if (target-riscv64?) >> + "RISCV64" >> + (system->llvm-target))) >> #$(string-append "-DLLVM_TARGETS_TO_BUILD=" >> (system->llvm-target))) >> '()) > > Hello, our `system->llvm-target` has riscv => "RISCV", does it wrong > (should be changed to RISCV64) or does it right only for 32bit RISCV? > And can system->llvm-target be fixed instead of fix each its usage? > > Thanks! > > > > hello, system->llvm-target work for LLVM_TARGETS_TO_BUILD, but not work for LLVM_TARGET_ARCH. llvm.scm (system->llvm-target) also have a commit ;; See the 'lib/Target' directory of LLVM for a list of supported targets. see https://github.com/llvm/llvm-project/blob/1fdec59bffc11ae37eb51a1b9869f0696bfd5312/llvm/cmake/config-ix.cmake#L393-#L441, LLVM_TARGET_ARCH is work for RISCV64 and RISCV32, not RISCV. xxx|..........cmake/config-ix.cmake.............. 432| elseif (LLVM_NATIVE_ARCH MATCHES "wasm64") 433| set(LLVM_NATIVE_ARCH WebAssembly) 434| elseif (LLVM_NATIVE_ARCH MATCHES "riscv32") 435| set(LLVM_NATIVE_ARCH RISCV) 436| elseif (LLVM_NATIVE_ARCH MATCHES "riscv64") 437| set(LLVM_NATIVE_ARCH RISCV) xxx|.................other....................... see https://github.com/llvm/llvm-project/blob/1fdec59bffc11ae37eb51a1b9869f0696bfd5312/llvm/cmake/config-ix.cmake#L450-#L470, RISCV is work for LLVM_TARGETS_TO_BUILD, it can find /lib/Target/RISCV directory, if system->llvm_targets return "RISCV64", it cann't work,because only have RISCV directory. xxx|...............................cmake/config-ix.cmake....................... 450| list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) 451| if (NATIVE_ARCH_IDX EQUAL -1) 452| message(STATUS 453| "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code") 454| else () 455| message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}") 456| set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target) 457| set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo) 458| set(LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC) 459| set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter) 460| 461| # We don't have an ASM parser for all architectures yet. 462| if (EXISTS ${PROJECT_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/CMakeLists.txt) 463| set(LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser) 464| endif () 465| 466| # We don't have an disassembler for all architectures yet. 467| if (EXISTS ${PROJECT_SOURCE_DIR}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/CMakeLists.txt) 468| set(LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler) 469| endif () 470| endif () xxx|...........................................other........................... so a other idea is add a new procedure make -DLLVM_TARGETS_TO_BUILD and -DLLVM_DEFAULT_TARGET_TRIPLE don't use same procedure. or not set -DLLVM_TARGET_ARCH like nixpkgs https://github.com/NixOS/nixpkgs/blob/2766f77c32e171a04d59b636a91083bae862274e/pkgs/development/compilers/llvm/11/llvm/default.nix it build success on my computer too. Thoughts?
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index e5bf9f5cae..f8691414d8 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -26,6 +26,7 @@ ;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com> ;;; Copyright © 2022 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2022 Zhu Zihao <all_but_last@163.com> +;;; Copyright © 2023 Zheng Junjie <873216071@qq.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -598,7 +599,9 @@ (define-public llvm-15 #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" (%current-target-system)) #$(string-append "-DLLVM_TARGET_ARCH=" - (system->llvm-target)) + (if (target-riscv64?) + "RISCV64" + (system->llvm-target))) #$(string-append "-DLLVM_TARGETS_TO_BUILD=" (system->llvm-target))) '()) @@ -658,7 +661,9 @@ (define-public llvm-14 #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" (%current-target-system)) #$(string-append "-DLLVM_TARGET_ARCH=" - (system->llvm-target)) + (if (target-riscv64?) + "RISCV64" + (system->llvm-target))) #$(string-append "-DLLVM_TARGETS_TO_BUILD=" (system->llvm-target))) '()) @@ -910,7 +915,9 @@ (define-public llvm-12 #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE=" (%current-target-system)) #$(string-append "-DLLVM_TARGET_ARCH=" - (system->llvm-target)) + (if (target-riscv64?) + "RISCV64" + (system->llvm-target))) #$(string-append "-DLLVM_TARGETS_TO_BUILD=" (system->llvm-target))) #~())