apache / nuttx-apps

Apache NuttX Apps is a collection of tools, shells, network utilities, libraries, interpreters and can be used with the NuttX RTOS
https://nuttx.apache.org/
Apache License 2.0
263 stars 488 forks source link

example: dlang-app added #2410

Closed kassane closed 1 month ago

kassane commented 1 month ago

Summary

Add D (programming language) support, LDC2 (LLVM D Compiler) only! url: https://ldc-developers.github.io/

Impact

Another programming language alternative. Designed for 32-bit or higher devices. It allows FFI C++ [extern(C++)] and C [extern(C)] code, in addition to turning the DRT(runtime)/GC (optional) using betterC or creating a miniDRT, if required.

Testing

Reference

lupyuen commented 1 month ago

Tested OK on macOS and rv-virt:nsh thanks!

Test Log: https://gist.github.com/lupyuen/e6fe3423e282ff8603de5f248bcb9ae5

kassane commented 1 month ago

Tested OK on macOS and rv-virt:nsh thanks!

Nice! have you also tested arm (qemu or device)?


qemu-armv7a:nsh

ldc2/ldmd2 -g need libunwind[1], replacing for -O and add --float-abi=hard too:

$ qemu-system-arm -cpu cortex-a7 -nographic -M virt,virtualization=off,gic-version=2 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel nuttx
psci_detect: Detected PSCI v1.1
nx_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS1
work_start_highpri: Starting high-priority kernel worker thread(s)
nxtask_activate: hpwork pid=1,TCB=0x4013b2d8
nx_start_application: Starting init thread
task_spawn: name=nsh_main entry=0x4010b18c file_actions=0 attr=0x4013afbc argv=0x4013afb8
nxtask_activate: nsh_main pid=2,TCB=0x4013c690
lib_cxx_initialize: _sinit: 0x4012c000 _einit: 0x4012c000

NuttShell (NSH) NuttX-12.5.1
nsh> nx_start: CPU0: Beginning Idle Loop
nsh> hello_d
task_spawn: name=hello_d entry=0x4011e824 file_actions=0x4013d8e4 attr=0x4013d8ec argv=0x4013d980
spawn_execattrs: Setting policy=2 priority=100 for pid=3
nxtask_activate: hello_d pid=3,TCB=0x4013dd80
Hello World, [cortex-a7]!
hello_d_main: Saying hello from the dynamically constructed instance
DHelloWorld.HelloWorld: CONSTRUCTION FAILED!
hello_d_main: Saying hello from the instance constructed on the stack
DHelloWorld.HelloWorld: Hello, World!!
nxtask_exit: hello_d pid=3,TCB=0x4013dd80

[1]

arm-none-eabi-ld: unwind-arm.c:(.text.get_eit_entry+0x6c): undefined reference to `__exidx_end'
arm-none-eabi-ld: unwind-arm.c:(.text.get_eit_entry+0x70): undefined reference to `__exidx_start'
arm-none-eabi-ld: unwind-arm.c:(.text.get_eit_entry+0x74): undefined reference to `__exidx_start'
xiaoxiang781216 commented 1 month ago

@kassane could you add/reuse a defconfig to enable hellod ci?

lupyuen commented 1 month ago
arm-none-eabi-ld: unwind-arm.c:(.text.get_eit_entry+0x6c): undefined reference to `__exidx_end'
arm-none-eabi-ld: unwind-arm.c:(.text.get_eit_entry+0x70): undefined reference to `__exidx_start'
arm-none-eabi-ld: unwind-arm.c:(.text.get_eit_entry+0x74): undefined reference to `__exidx_start'

Hmmm I'm not sure why this happens, need to trace through this... (Oops! Like you mentioned: We need libunwind)

kassane commented 1 month ago

@kassane could you add/reuse a defconfig to enable hellod ci?

@xiaoxiang781216, I could try! I will do some experiments on the nuttx CI/CD (I haven't tested on it yet...)

Hmmm I'm not sure why this happens, need to trace through this... (Oops! Like you mentioned: We need libunwind)

@lupyuen, Exactly! ldc2 need libunwind for backtracing. But release mode can bypass!