This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 41a496351 config.nims: Support Nim Apps for RISC-V 32-bit and 64-bit
41a496351 is described below

commit 41a49635151abd91448d249194b104322da5da63
Author: Lee Lup Yuen <[email protected]>
AuthorDate: Wed Jan 3 01:41:03 2024 +0000

    config.nims: Support Nim Apps for RISC-V 32-bit and 64-bit
    
    NuttX Build fails when it compiles `examples/hello_nim` for RISC-V (32-bit 
and 64-bit). That's because the Nim Config Script `config.nims` couldn't 
identify the Nim Target Platform: `riscv32` or `riscv64`.
    
    This PR fixes `config.nims` so that Nim Compiler correctly derives the Nim 
Target Platform (`riscv32` or `riscv64`), by searching NuttX `.config` for 
`CONFIG_ARCH_FAMILY=rv32` or `rv64`.
    
    This logic is slightly different from the Nim Targets `arm` and `arm64`, 
which are currently derived from `CONFIG_ARCH=arm` and `arm64`.
    
    `config.nims` is explained in this article: 
https://lupyuen.github.io/articles/nim#inside-nim-on-nuttx
---
 config.nims | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/config.nims b/config.nims
index 0d6c4c74c..265573217 100644
--- a/config.nims
+++ b/config.nims
@@ -27,6 +27,7 @@ switch "mm", "orc"
 switch "arm.nuttx.gcc.exe", "arm-none-eabi-gcc"
 switch "arm64.nuttx.gcc.exe", "aarch64-none-elf-gcc"
 switch "riscv32.nuttx.gcc.exe", "riscv64-unknown-elf-gcc"
+switch "riscv64.nuttx.gcc.exe", "riscv64-unknown-elf-gcc"
 switch "amd64.nuttx.gcc.exe", "x86_64-linux-gnu-gcc"
 
 switch "nimcache", ".nimcache"
@@ -69,14 +70,19 @@ proc read_config(cfg: string): DotConfig =
       case arch
       of "arm", "arm64":
         result.arch = arch
-      of "riscv":
-        result.arch = "riscv32"
       of "sim":
         if defined(amd64):
           result.arch = "amd64"
         elif defined(aarch64):
           result.arch = "arm64"
         result.isSim = true
+    of "ARCH_FAMILY":
+      let arch = keyval[1].strip(chars = {'"'})
+      case arch
+      of "rv32":
+        result.arch = "riscv32"
+      of "rv64":
+        result.arch = "riscv64"
     of "DEBUG_NOOPT":
       result.opt = oNone
     of "DEBUG_FULLOPT":

Reply via email to