Skip to content

Commit 3c56e0d

Browse files
stephanosiogalak
authored andcommitted
cmake: ld: Disable manual linking of libgcc components for host
When the host toolchain is used, `-nostdlib` option is not specified and therefore all default libraries, including the libgcc and its components, are automatically linked -- so it is not necessary to manually link them here. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent b0cb741 commit 3c56e0d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

cmake/linker/ld/target.cmake

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ endif()
1313

1414
set_ifndef(LINKERFLAGPREFIX -Wl)
1515

16-
if(CONFIG_EXCEPTIONS)
17-
# When building with C++ Exceptions, it is important that crtbegin and crtend
18-
# are linked at specific locations.
19-
# The location is so important that we cannot let this be controlled by normal
20-
# link libraries, instead we must control the link command specifically as
21-
# part of toolchain.
22-
set(CMAKE_CXX_LINK_EXECUTABLE
23-
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${LIBGCC_DIR}/crtbegin.o <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${LIBGCC_DIR}/crtend.o")
16+
if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "host")
17+
if(CONFIG_EXCEPTIONS)
18+
# When building with C++ Exceptions, it is important that crtbegin and crtend
19+
# are linked at specific locations.
20+
# The location is so important that we cannot let this be controlled by normal
21+
# link libraries, instead we must control the link command specifically as
22+
# part of toolchain.
23+
set(CMAKE_CXX_LINK_EXECUTABLE
24+
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${LIBGCC_DIR}/crtbegin.o <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${LIBGCC_DIR}/crtend.o")
25+
endif()
2426
endif()
2527

2628
# Run $LINKER_SCRIPT file through the C preprocessor, producing ${linker_script_gen}

0 commit comments

Comments
 (0)