www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Undefined references in Druntime for microcontrollers

reply Severin Teona <teona.severin9 gmail.com> writes:
Hi guys,

I have been trying to port the current druntime for 
microcontrollers (that very little RAM and flash memory). I have 
been using the 'ldc-build-runtime' tool and finally I managed to 
compile something that looks alright.

The problem is that I compiled the druntime with the flag 
'BUILD_SHARED_LIBS=OFF' (as the microcontrollers don't work with 
dynamic libraries), and when I try to link the druntime with the 
application for the microcontroller, I get many errors about 
undefined references (references that would normally be present 
in those dynamic libraries). Few of them are:
- 'munmap'
- 'clock_gettime'
- `pthread_mutex_trylock'
etc.

Could you help me by telling me what libraries (and how) should I 
statically compile and link to the druntime? The 
microcontroller's CPU is an ARM Cortex-M4, and the libraries 
should be able to be compiled for this architecture.

Thank you so much!
Oct 18 2020
next sibling parent IGotD- <nise nise.com> writes:
On Monday, 19 October 2020 at 06:25:17 UTC, Severin Teona wrote:
 - 'munmap'
 - 'clock_gettime'
 - `pthread_mutex_trylock'
 etc.
These are typically calls found in a Unix system, Linux for example. In a microcontroller you will likely not support these at all except clock_gettime. You need to dissect druntime a bit further to remove these and/or find a replacement that does the same thing.
Oct 19 2020
prev sibling parent Denis Feklushkin <feklushkin.denis gmail.com> writes:
On Monday, 19 October 2020 at 06:25:17 UTC, Severin Teona wrote:

 Could you help me by telling me what libraries (and how) should 
 I statically compile and link to the druntime? The 
 microcontroller's CPU is an ARM Cortex-M4, and the libraries 
 should be able to be compiled for this architecture.

 Thank you so much!
Most probably they should be provided by your RTOS. At least, FreeRTOS have project for implement Posix thread calls.
Oct 19 2020