Skip to content

examples/hello_nim: Fix nimcache location #2247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

lupyuen
Copy link
Member

@lupyuen lupyuen commented Jan 2, 2024

Summary

The Nim Example App fails to build because the .nimcache is located 2 folders up. This PR fixes the location of .nimcache in the Makefile of the Nim Example App.

.nimcache is explained in this article.

Impact

Nim Example App builds and runs correctly after fixing the .nimcache location.

No impact on other apps, since the Makefile is used only by the Nim Example App.

Testing

We tested on QEMU Arm64:

$ tools/configure.sh -l qemu-armv8a:nsh
## TODO: Init networking: https://github.com/lupyuen2/wip-pinephone-nuttx/commit/77b8295eb761954370481ed113254b7e930f65c0
## TODO: Suppress warnings: https://github.com/lupyuen2/wip-pinephone-nuttx/commit/e82be7d1f9f662ef369a3c4adc8290a4035f9857

$ make menuconfig
## Enable "Application Configuration > Examples > Hello World Example (Nim)"
## Networking support: Enable "Networking support"
## Networking Support → SocketCAN Support:
##   Enable "SocketCAN Support"
##   Enable "sockopt support"
## RTOS Features → Tasks and Scheduling:
##   Enable "Support parent/child task relationships"
##   Enable "Retain child exit status"

$ make

Before Fixing

NuttX Build fails because .nimcache/hello_nim_async.h could not be found:

./hello_nim_main.c:26:10: fatal error: hello_nim_async.h: No such file or directory
   26 | #include "hello_nim_async.h"

(See the Build Log)

After Fixing

NuttX Build succeeds and Nim Example App runs correctly. Note that we need to suppress the warnings and initialise the network. We might need to fix these in a future PR.

$ qemu-system-aarch64 \
  -cpu cortex-a53 \
  -nographic \
  -machine virt,virtualization=on,gic-version=3 \
  -net none \
  -chardev stdio,id=con,mux=on \
  -serial chardev:con \
  -mon chardev=con,mode=readline \
  -kernel nuttx

NuttShell (NSH) NuttX-12.0.3
nsh> uname -a
NuttX  12.0.3 77b8295eb76 Jan  2 2024 04:53:17 arm64 qemu-armv8a

nsh> hello_nim
task_spawn: name=hello_nim entry=0x402a4f4c file_actions=0x403ede48 attr=0x403ede50 argv=0x403edf90
spawn_execattrs: Setting policy=2 priority=100 for pid=3
pthread_mutex_init: mutex=0x403e4918 attr=0
pthread_mutex_init: Returning 0
Hello from task 1! loops: 0
pthread_mutex_timedlock: mutex=0x403e4918
pthread_mutex_timedlock: Returning 0
pthread_mutex_unlock: mutex=0x403e4918
pthread_mutex_unlock: Returning 0
Hello from task 2! loops: 0
Hello from task 3! loops: 0
Hello from task 1! loops: 1
Hello from task 2! loops: 1
Hello from task 3! loops: 1
Hello from task 1! loops: 2
Hello from task 2! loops: 2
Hello from task 3! loops: 2
nxsig_tcbdispatch: TCB=0x403ebd40 pid=2 signo=17 code=5 value=0 masked=NO
nsh> 

(See the NuttX Log)

The Nim Example App fails to build because the `.nimcache` is located 2 folders up. This PR fixes the location of `.nimcache` in the `Makefile` of the Nim Example App.

`.nimcache` is explained in this article: https://lupyuen.github.io/articles/nim#inside-nim-on-nuttx
@xiaoxiang781216 xiaoxiang781216 merged commit 16bca8b into apache:master Jan 2, 2024
@xiaoxiang781216
Copy link
Contributor

@lupyuen why not enable nim in ci to avoid it may break in the future?

@lupyuen
Copy link
Member Author

lupyuen commented Jan 3, 2024

Thanks @xiaoxiang781216! Right now the hello_nim build fails on QEMU Arm64 because of the const warnings (since GCC -Werror is enabled). Lemme figure out if Nim Compiler can generate correct const code, then we can add it to CI.

For now: I shall run an Auto Daily Build on my GitHub Actions account (with GCC -Werror disabled). So I will know if the Nim Build breaks.

../../.nimcache/@m..@s..@s..@s..@s..@shome@svscode@s.choosenim@stoolchains@snim-@hdevel@slib@spure@sasyncdispatch.nim.c:362:285: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
  362 | IGNOF(tyObject_SelectorImpl__JWlu9aJYbxUSEZxA8xSjuMg), .depth = 0, .display = TM__gfe9a52b5gJr8GSrnr883iA_3, .traceImpl = (void*)eqtrace___pureZasyncdispatch_u2061, .flags = 0};
      |                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(List of warnings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants