Commit 6f5906b6 authored by Stephanos Ioannidis's avatar Stephanos Ioannidis
Browse files

cmake: linker: lld: Do not link libc when minimal libc is used

When LLVM linker is used, the toolchain-provided C standard library is
always linked, even when the Zephyr minimal libc is selected, because `c`
is unconditionally specified in `link_order_library`, which causes `-lc` to
be specified in the linker flags.

This commit adds a check to ensure that `-lc` is not specified when the
Zephyr minimal libc is selected because it is a standalone C standard
library and it does not make sense to link two C standard libraries at
once.

Signed-off-by: default avatarStephanos Ioannidis <root@stephanos.io>
parent d8a696c3
Loading
Loading
Loading
Loading
+5 −1
Changes for cmake/linker/lld/linker_libraries.cmake: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -16,4 +16,8 @@ if(CONFIG_CPP
  set_property(TARGET linker PROPERTY link_order_library "c++")
endif()

set_property(TARGET linker APPEND PROPERTY link_order_library "c;rt")
if(NOT CONFIG_MINIMAL_LIBC)
  set_property(TARGET linker APPEND PROPERTY link_order_library "c")
endif()

set_property(TARGET linker APPEND PROPERTY link_order_library "rt")