config.nims: Support Nim Apps for RISC-V 32-bit and 64-bit #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
NuttX Build fails when it compiles
examples/hello_nim
for RISC-V (32-bit and 64-bit). That's because the Nim Config Scriptconfig.nims
couldn't identify the Nim Target Platform:riscv32
orriscv64
.This PR fixes
config.nims
so that Nim Compiler correctly derives the Nim Target Platform (riscv32
orriscv64
), by searching NuttX.config
forCONFIG_ARCH_FAMILY=rv32
orrv64
.This logic is slightly different from the Nim Targets
arm
andarm64
, which are currently derived fromCONFIG_ARCH=arm
andarm64
.config.nims
is explained in this article.Impact
With this PR, Nim Apps will build correctly for 32-bit and 64-bit RISC-V.
There is no impact on other platforms, like Arm and Arm64.
Testing
We tested by building QEMU NuttX with
examples/hello_nim
enabled for RISC-V 32-bit, RISC-V 64-bit and Arm64 (for regression testing).RISC-V 32-bit
Before Fixing: NuttX Build fails for
hello_nim
becausearch
andcpu
in Nim Compiler are empty:(Failed Build Log for 32-bit RISC-V)
After Fixing: NuttX Build succeeds with the correct
arch
andcpu
in Nim Compiler:(Fixed Build Log for 32-bit RISC-V)
RISC-V 64-bit
NuttX Build succeeds with the correct
arch
andcpu
in Nim Compiler:(Fixed Build Log for 64-bit RISC-V)
Arm64
For Regression Testing: NuttX Build succeeds with the correct
arch
andcpu
in Nim Compiler:(Build Log for Arm64)
Nim Exception
For Arm64:
hello_nim
runs correctly on Arm64 QEMU:(NuttX Log for Arm64)
For RISC-V 32-bit and 64-bit:
hello_nim
halts with a Load Access Fault for 32-bit RISC-V:(NuttX Exception for 32-bit RISC-V)
hello_nim
also halts with a Load Access Fault for 64-bit RISC-V:(NuttX Exception for 64-bit RISC-V)
This will be fixed later. For now, we tested a Simple Nim Function that runs correctly on 32-bit and 64-bit RISC-V:
(Simple Nim Log for 32-bit RISC-V)
(Simple Nim Log for 64-bit RISC-V)