Building LDC runtime for a microcontroller

Severin Teona teona.severin9 at gmail.com
Mon Sep 7 15:23:28 UTC 2020


Hello,

I have been trying to build the LDC runtime for a Nucleo-f429zi 
board with a Cortex-M4 CPU, by following [1]. The target is not 
dependent on
any operating system (as the target board uses a STM32 
microcontroller), so the gcc toolchain I have used is 
arm-none-eabi-gcc(9.3.1).
The error I am getting after running “CC=arm-none-eabi-gcc 
ldc-build-runtime --reset --ninja 
--dFlags="-mtriple=thumb-none-linux-eabi” is:

———
CMake Error at 
/snap/cmake/549/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
   The C compiler

     
"/home/teona/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc"

   is not able to compile a simple test program.

   It fails with the following output:

     Change Dir: 
/home/teona/runtime_thumb/ldc-build-runtime.tmp/CMakeFiles/CMakeTmp

     Run Build Command(s):/usr/bin/ninja cmTC_31c30 && [1/2] 
Building C object CMakeFiles/cmTC_31c30.dir/testCCompiler.c.o
     [2/2] Linking C executable cmTC_31c30
     FAILED: cmTC_31c30
     : && 
/home/teona/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc  -rdynamic CMakeFiles/cmTC_31c30.dir/testCCompiler.c.o -o cmTC_31c30   && :
     arm-none-eabi-gcc: error: unrecognized command line option 
'-rdynamic'
     ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
———

After searching online for a solution, I found that the same 
issue appeared when using Golang and one answer [2] stated that 
it might work by passing to the linker “-Wl,-export-dynamic” 
instead of “-rdynamic”. Do you have any idea how I could do that?
CMake version is 3.18,
arm-none-eabi-gcc version is 6.3.1,
ldc2 version is 1.23.0 and the system I am running on is Ubuntu 
18.04 LTS.

I would also appreciate any advice regarding ways to build or 
create a small runtime for microcontrollers (runtime that can fit 
in the memory of a microcontroller).
Thank you very much,
Teona

[1]: https://wiki.dlang.org/Building_LDC_runtime_libraries
[2]: 
https://github.com/golang/go/issues/36633#issuecomment-576411479


More information about the Digitalmars-d-learn mailing list