Skip to content

Commit f6a4e06

Browse files
committed
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
1 parent 9489659 commit f6a4e06

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

config.nims

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ switch "mm", "orc"
2727
switch "arm.nuttx.gcc.exe", "arm-none-eabi-gcc"
2828
switch "arm64.nuttx.gcc.exe", "aarch64-none-elf-gcc"
2929
switch "riscv32.nuttx.gcc.exe", "riscv64-unknown-elf-gcc"
30+
switch "riscv64.nuttx.gcc.exe", "riscv64-unknown-elf-gcc"
3031
switch "amd64.nuttx.gcc.exe", "x86_64-linux-gnu-gcc"
3132

3233
switch "nimcache", ".nimcache"
@@ -69,14 +70,19 @@ proc read_config(cfg: string): DotConfig =
6970
case arch
7071
of "arm", "arm64":
7172
result.arch = arch
72-
of "riscv":
73-
result.arch = "riscv32"
7473
of "sim":
7574
if defined(amd64):
7675
result.arch = "amd64"
7776
elif defined(aarch64):
7877
result.arch = "arm64"
7978
result.isSim = true
79+
of "ARCH_FAMILY":
80+
let arch = keyval[1].strip(chars = {'"'})
81+
case arch
82+
of "rv32":
83+
result.arch = "riscv32"
84+
of "rv64":
85+
result.arch = "riscv64"
8086
of "DEBUG_NOOPT":
8187
result.opt = oNone
8288
of "DEBUG_FULLOPT":

0 commit comments

Comments
 (0)