Skip to content

Commit e077bed

Browse files
stephanosiokeith-packard
authored andcommitted
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: Stephanos Ioannidis <root@stephanos.io>
1 parent 9509789 commit e077bed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmake/linker/lld/linker_libraries.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ if(CONFIG_CPP
1616
set_property(TARGET linker PROPERTY link_order_library "c++")
1717
endif()
1818

19-
set_property(TARGET linker APPEND PROPERTY link_order_library "c;rt")
19+
if(NOT CONFIG_MINIMAL_LIBC)
20+
set_property(TARGET linker APPEND PROPERTY link_order_library "c")
21+
endif()
22+
23+
set_property(TARGET linker APPEND PROPERTY link_order_library "rt")

0 commit comments

Comments
 (0)