CMakeLists.txt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. idf_component_register(SRCS "cxx_exception_stubs.cpp"
  2. "cxx_guards.cpp"
  3. # Make sure that pthread is in component list
  4. PRIV_REQUIRES pthread)
  5. if(NOT CONFIG_CXX_EXCEPTIONS)
  6. set(WRAP_FUNCTIONS
  7. _Unwind_SetEnableExceptionFdeSorting
  8. __register_frame_info_bases
  9. __register_frame_info
  10. __register_frame
  11. __register_frame_info_table_bases
  12. __register_frame_info_table
  13. __register_frame_table
  14. __deregister_frame_info_bases
  15. __deregister_frame_info
  16. _Unwind_Find_FDE
  17. _Unwind_GetGR
  18. _Unwind_GetCFA
  19. _Unwind_GetIP
  20. _Unwind_GetIPInfo
  21. _Unwind_GetRegionStart
  22. _Unwind_GetDataRelBase
  23. _Unwind_GetTextRelBase
  24. _Unwind_SetIP
  25. _Unwind_SetGR
  26. _Unwind_GetLanguageSpecificData
  27. _Unwind_FindEnclosingFunction
  28. _Unwind_Resume
  29. _Unwind_RaiseException
  30. _Unwind_DeleteException
  31. _Unwind_ForcedUnwind
  32. _Unwind_Resume_or_Rethrow
  33. _Unwind_Backtrace
  34. __cxa_call_unexpected
  35. __gxx_personality_v0)
  36. foreach(wrap ${WRAP_FUNCTIONS})
  37. target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}")
  38. endforeach()
  39. endif()
  40. target_link_libraries(${COMPONENT_LIB} PUBLIC stdc++ gcc)
  41. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxa_guard_dummy")
  42. # Force libpthread to appear later than libstdc++ in link line since libstdc++ depends on libpthread.
  43. # Furthermore, force libcxx to appear later than libgcc because some libgcc unwind code is wrapped, if C++
  44. # exceptions are disabled. libcxx (this component) provides the unwind code wrappers.
  45. # This is to prevent linking of libgcc's unwind code which considerably increases the binary size.
  46. idf_component_get_property(pthread pthread COMPONENT_LIB)
  47. idf_component_get_property(cxx cxx COMPONENT_LIB)
  48. add_library(stdcpp_pthread INTERFACE)
  49. target_link_libraries(stdcpp_pthread INTERFACE stdc++ $<TARGET_FILE:${pthread}>)
  50. target_link_libraries(${COMPONENT_LIB} PUBLIC stdcpp_pthread)
  51. add_library(libgcc_cxx INTERFACE)
  52. target_link_libraries(libgcc_cxx INTERFACE gcc $<TARGET_FILE:${cxx}>)
  53. target_link_libraries(${COMPONENT_LIB} PUBLIC libgcc_cxx)
  54. if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS)
  55. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxx_fatal_exception")
  56. endif()