config.nims: Support Nim Apps for RISC-V 32-bit and 64-bit#2251
Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom Jan 4, 2024
Merged
config.nims: Support Nim Apps for RISC-V 32-bit and 64-bit#2251xiaoxiang781216 merged 1 commit intoapache:masterfrom
xiaoxiang781216 merged 1 commit intoapache:masterfrom
Conversation
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
xiaoxiang781216
approved these changes
Jan 4, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_nimfor RISC-V (32-bit and 64-bit). That's because the Nim Config Scriptconfig.nimscouldn't identify the Nim Target Platform:riscv32orriscv64.This PR fixes
config.nimsso that Nim Compiler correctly derives the Nim Target Platform (riscv32orriscv64), by searching NuttX.configforCONFIG_ARCH_FAMILY=rv32orrv64.This logic is slightly different from the Nim Targets
armandarm64, which are currently derived fromCONFIG_ARCH=armandarm64.config.nimsis 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_nimenabled 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_nimbecausearchandcpuin Nim Compiler are empty:(Failed Build Log for 32-bit RISC-V)
After Fixing: NuttX Build succeeds with the correct
archandcpuin Nim Compiler:(Fixed Build Log for 32-bit RISC-V)
RISC-V 64-bit
NuttX Build succeeds with the correct
archandcpuin Nim Compiler:(Fixed Build Log for 64-bit RISC-V)
Arm64
For Regression Testing: NuttX Build succeeds with the correct
archandcpuin Nim Compiler:(Build Log for Arm64)
Nim Exception
For Arm64:
hello_nimruns correctly on Arm64 QEMU:(NuttX Log for Arm64)
For RISC-V 32-bit and 64-bit:
hello_nimhalts with a Load Access Fault for 32-bit RISC-V:(NuttX Exception for 32-bit RISC-V)
hello_nimalso 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)