2023-08-28 02:02:08 -04:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
|
|
|
|
|
|
|
if(${target} STREQUAL "linux")
|
|
|
|
return() # This component is not necessary on the POSIX/Linux simulator
|
|
|
|
endif()
|
|
|
|
|
2019-04-28 03:38:23 -04:00
|
|
|
idf_component_register(SRCS "cxx_exception_stubs.cpp"
|
2019-09-17 06:07:47 -04:00
|
|
|
"cxx_guards.cpp"
|
2024-02-18 03:07:41 -05:00
|
|
|
"cxx_init.cpp"
|
2019-09-17 06:07:47 -04:00
|
|
|
# Make sure that pthread is in component list
|
2024-02-18 03:07:41 -05:00
|
|
|
PRIV_REQUIRES pthread esp_system)
|
2018-01-11 21:49:13 -05:00
|
|
|
|
2021-02-07 03:51:52 -05:00
|
|
|
if(NOT CONFIG_CXX_EXCEPTIONS)
|
|
|
|
set(WRAP_FUNCTIONS
|
|
|
|
__register_frame_info_bases
|
|
|
|
__register_frame_info
|
|
|
|
__register_frame
|
|
|
|
__register_frame_info_table_bases
|
|
|
|
__register_frame_info_table
|
|
|
|
__register_frame_table
|
|
|
|
__deregister_frame_info_bases
|
|
|
|
__deregister_frame_info
|
|
|
|
_Unwind_Find_FDE
|
|
|
|
_Unwind_GetGR
|
|
|
|
_Unwind_GetCFA
|
|
|
|
_Unwind_GetIP
|
|
|
|
_Unwind_GetIPInfo
|
|
|
|
_Unwind_GetRegionStart
|
|
|
|
_Unwind_GetDataRelBase
|
|
|
|
_Unwind_GetTextRelBase
|
|
|
|
_Unwind_SetIP
|
|
|
|
_Unwind_SetGR
|
|
|
|
_Unwind_GetLanguageSpecificData
|
|
|
|
_Unwind_FindEnclosingFunction
|
|
|
|
_Unwind_Resume
|
|
|
|
_Unwind_RaiseException
|
|
|
|
_Unwind_DeleteException
|
|
|
|
_Unwind_ForcedUnwind
|
|
|
|
_Unwind_Resume_or_Rethrow
|
|
|
|
_Unwind_Backtrace
|
|
|
|
__cxa_call_unexpected
|
|
|
|
__gxx_personality_v0)
|
|
|
|
|
|
|
|
foreach(wrap ${WRAP_FUNCTIONS})
|
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2022-11-18 07:29:39 -05:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
# libstdc++ depends on C library, so it should appear later in link order.
|
|
|
|
# Otherwise we get undefined references for esp-clang toolchain.
|
2022-11-23 07:00:11 -05:00
|
|
|
target_link_libraries(${COMPONENT_LIB} PUBLIC stdc++ c ${CONFIG_COMPILER_RT_LIB_NAME})
|
2022-11-18 07:29:39 -05:00
|
|
|
else()
|
|
|
|
target_link_libraries(${COMPONENT_LIB} PUBLIC stdc++ gcc)
|
|
|
|
endif()
|
2019-06-04 07:05:33 -04:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxa_guard_dummy")
|
2024-02-18 03:07:41 -05:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxx_init_dummy")
|
2018-01-11 21:49:13 -05:00
|
|
|
|
2021-02-07 03:51:52 -05:00
|
|
|
# Force libpthread to appear later than libstdc++ in link line since libstdc++ depends on libpthread.
|
|
|
|
# Furthermore, force libcxx to appear later than libgcc because some libgcc unwind code is wrapped, if C++
|
|
|
|
# exceptions are disabled. libcxx (this component) provides the unwind code wrappers.
|
|
|
|
# This is to prevent linking of libgcc's unwind code which considerably increases the binary size.
|
2023-08-03 09:25:53 -04:00
|
|
|
# Also force libnewlib to appear later than libstdc++ in link line since libstdc++ depends on
|
|
|
|
# some functions in libnewlib, e.g. getentropy().
|
2019-09-17 06:07:47 -04:00
|
|
|
idf_component_get_property(pthread pthread COMPONENT_LIB)
|
2023-08-03 09:25:53 -04:00
|
|
|
idf_component_get_property(newlib newlib COMPONENT_LIB)
|
2021-02-07 03:51:52 -05:00
|
|
|
idf_component_get_property(cxx cxx COMPONENT_LIB)
|
2023-08-03 09:25:53 -04:00
|
|
|
add_library(stdcpp_deps INTERFACE)
|
2022-11-18 07:29:39 -05:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2023-08-03 09:25:53 -04:00
|
|
|
target_link_libraries(stdcpp_deps INTERFACE stdc++ c $<TARGET_FILE:${pthread}> $<TARGET_FILE:${newlib}>)
|
2022-11-18 07:29:39 -05:00
|
|
|
else()
|
2023-08-03 09:25:53 -04:00
|
|
|
target_link_libraries(stdcpp_deps INTERFACE stdc++ $<TARGET_FILE:${pthread}> $<TARGET_FILE:${newlib}>)
|
2022-11-18 07:29:39 -05:00
|
|
|
endif()
|
2023-08-03 09:25:53 -04:00
|
|
|
target_link_libraries(${COMPONENT_LIB} PUBLIC stdcpp_deps)
|
2021-02-07 03:51:52 -05:00
|
|
|
add_library(libgcc_cxx INTERFACE)
|
2022-11-23 07:00:11 -05:00
|
|
|
target_link_libraries(libgcc_cxx INTERFACE ${CONFIG_COMPILER_RT_LIB_NAME} $<TARGET_FILE:${cxx}>)
|
2021-02-07 03:51:52 -05:00
|
|
|
target_link_libraries(${COMPONENT_LIB} PUBLIC libgcc_cxx)
|
2019-09-17 06:07:47 -04:00
|
|
|
|
2019-04-24 09:02:25 -04:00
|
|
|
if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS)
|
2019-06-04 07:05:33 -04:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxx_fatal_exception")
|
2018-01-11 21:49:13 -05:00
|
|
|
endif()
|