Zephyr in-project libraries

Dear Nordic, 

Could you please suggest and and expamle or advice how to use in-project libraries properly (not 'externally built' as an know example shows). It's better to move some code out to project libraries, but we've faced the issue: 

> c:/ncs/v1.9.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: error: zephyr\zephyr_pre0.elf uses VFP register arguments, src/lib/rand/libkkrand.a(rng.c.obj) does not
1> c:/ncs/v1.9.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file src/lib/rand/libkkrand.a(rng.c.obj)

What's going wrong here? As we understand, the issue caused by using mfloat-abi = soft option (but it could be just one of few issues here). To reach this point we have to add some strange directive:

target_link_libraries(kkrand PUBLIC app)
to CMakeLists.txt for the custom library. It's a cross-reference: after that, kkrand is included in the app target. If not, building of the library leads to some errors because compiler doesn't target architecture. 
Should note that CMakeLists structure is fully hierarchical with one root and of course includes find_package(zephyr...) directive.




  • At the moment there is an easy temporary overcome for that is just adding of few compile options (just a copy from gcc commannd line call): 

    add_compile_options(
      -mfloat-abi=hard
      -mcpu=cortex-m4  
      -mthumb  
      -mabi=aapcs  
      -mfpu=fpv4-sp-d16  
      -mfp16-format=ieee
      )
    It's not a solution because you can change some options in the future that could lead to some issues (e.g. change FP16 format) still it works on early development stage.
    Dear Nordic, is there any normal way to implement in-project libraries?
Related