diff --git a/CMakeLists.txt b/CMakeLists.txt index da959c0f521da..41e1044946736 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -595,6 +595,9 @@ endforeach() set(ZEPHYR_CURRENT_MODULE_DIR) set(ZEPHYR_CURRENT_CMAKE_DIR) +get_property(LIBC_LINK_LIBRARIES TARGET zephyr_interface PROPERTY LIBC_LINK_LIBRARIES) +zephyr_link_libraries(${LIBC_LINK_LIBRARIES}) + set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h) set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json) set(struct_tags_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/struct_tags.json) diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 5242c7a057279..23b8cf77c12e4 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -112,6 +112,10 @@ function(zephyr_link_libraries) target_link_libraries(zephyr_interface INTERFACE ${ARGV}) endfunction() +function(zephyr_libc_link_libraries) + set_property(TARGET zephyr_interface APPEND PROPERTY LIBC_LINK_LIBRARIES ${ARGV}) +endfunction() + # See this file section 3.1. target_cc_option function(zephyr_cc_option) foreach(arg ${ARGV}) diff --git a/lib/libc/picolibc/CMakeLists.txt b/lib/libc/picolibc/CMakeLists.txt index bfbe4bca8c332..c32295e1d271a 100644 --- a/lib/libc/picolibc/CMakeLists.txt +++ b/lib/libc/picolibc/CMakeLists.txt @@ -13,7 +13,7 @@ if(NOT CONFIG_PICOLIBC_USE_MODULE) zephyr_compile_options(--specs=picolibc.specs) zephyr_compile_definitions(_POSIX_C_SOURCE=200809) - zephyr_link_libraries(-T/dev/null --specs=picolibc.specs c -lgcc) + zephyr_libc_link_libraries(-T/dev/null --specs=picolibc.specs c -lgcc) if(CONFIG_PICOLIBC_IO_FLOAT) zephyr_compile_definitions(PICOLIBC_DOUBLE_PRINTF_SCANF) zephyr_link_libraries(-DPICOLIBC_DOUBLE_PRINTF_SCANF)