From 8300945189b18adfc3e7a71bd096ad2355e0d83c Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 17 Sep 2019 18:07:47 +0800 Subject: [PATCH] cxx: force pthread to appear later in link line --- components/cxx/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/cxx/CMakeLists.txt b/components/cxx/CMakeLists.txt index 57e0aec7c0..852c4c884d 100644 --- a/components/cxx/CMakeLists.txt +++ b/components/cxx/CMakeLists.txt @@ -1,9 +1,17 @@ idf_component_register(SRCS "cxx_exception_stubs.cpp" - "cxx_guards.cpp") + "cxx_guards.cpp" + # Make sure that pthread is in component list + PRIV_REQUIRES pthread) target_link_libraries(${COMPONENT_LIB} PUBLIC stdc++ gcc) target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxa_guard_dummy") +# Force pthread to also appear later than stdc++ in link line +add_library(stdcpp_pthread INTERFACE) +idf_component_get_property(pthread pthread COMPONENT_LIB) +target_link_libraries(stdcpp_pthread INTERFACE stdc++ $) +target_link_libraries(${COMPONENT_LIB} PUBLIC stdcpp_pthread) + if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS) target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxx_fatal_exception") endif()