Subject: Re: [bug#62438] [PATCH] gnu: llvm: fix riscv64 cross-compile.

From: Z572 <[email-masked]>
Date: Sun, 11 Jun 2023 22:57:08 +0800

Ludovic Courtès <[email-masked]> writes:

> Hi,
>
> Z572 <[email-masked]> 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