1# Copyright (c) 2024 Nordic Semiconductor 2# 3# SPDX-License-Identifier: Apache-2.0 4 5set_linker_property(NO_CREATE PROPERTY c_library "-lc") 6set_linker_property(NO_CREATE PROPERTY rt_library "-lgcc") 7set_linker_property(NO_CREATE PROPERTY c++_library "-lstdc++") 8set_linker_property(NO_CREATE PROPERTY math_library "-lm") 9# Keeping default include dir empty. The linker will then select libraries 10# from its default search path. The toolchain may adjust the value to a 11# specific location, for example gcc infrastructure will set the value based 12# on output from --print-libgcc-file-name. 13set_linker_property(NO_CREATE PROPERTY lib_include_dir "") 14 15if(CONFIG_CPP 16 # When new link principle is fully introduced, then the below condition can 17 # be removed, and instead the external module c++ should use: 18 # set_property(TARGET linker PROPERTY c++_library "<external_c++_lib>") 19 AND NOT CONFIG_EXTERNAL_MODULE_LIBCPP 20) 21 set_property(TARGET linker PROPERTY link_order_library "c++") 22endif() 23 24 25if(CONFIG_NEWLIB_LIBC AND CMAKE_C_COMPILER_ID STREQUAL "GNU") 26 # We are using c;rt;c (expands to '-lc -lgcc -lc') in code below. 27 # This is needed because when linking with newlib on aarch64, then libgcc has a 28 # link dependency to libc (strchr), but libc also has dependencies to libgcc. 29 # Lib C depends on libgcc. e.g. libc.a(lib_a-fvwrite.o) references __aeabi_idiv 30 set_property(TARGET linker APPEND PROPERTY link_order_library "math;c;rt;c") 31else() 32 set_property(TARGET linker APPEND PROPERTY link_order_library "c;rt") 33endif() 34