[PATCH] D21478: [build] Make sure to link main executable with libpthread
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 13:21:54 PDT 2016
Is that a documented restriction?
We should have a comment saying why we need to do this.
Cheers,
Rafael
On 17 June 2016 at 16:12, Artem Belevich <tra at google.com> wrote:
> tra created this revision.
> tra added reviewers: rafael, MatzeB, chandlerc.
> tra added a subscriber: llvm-commits.
>
> Otherwise it gets linked in by one of the dependencies of shared
> libraries which may be too late and we end up with weird crashes in
> std::call_once().
>
>
> http://reviews.llvm.org/D21478
>
> Files:
> cmake/config-ix.cmake
> cmake/modules/AddLLVM.cmake
>
> Index: cmake/modules/AddLLVM.cmake
> ===================================================================
> --- cmake/modules/AddLLVM.cmake
> +++ cmake/modules/AddLLVM.cmake
> @@ -670,6 +670,9 @@
> if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO)
> llvm_externalize_debuginfo(${name})
> endif()
> + if (PTHREAD_LIB)
> + target_link_libraries(${name} ${PTHREAD_LIB})
> + endif()
> endmacro(add_llvm_executable name)
>
> function(export_executable_symbols target)
> @@ -953,7 +956,7 @@
> add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO ${ARGN})
> set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
> set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
> - target_link_libraries(${test_name} gtest_main gtest)
> + target_link_libraries(${test_name} gtest_main gtest ${PTHREAD_LIB})
>
> add_dependencies(${test_suite} ${test_name})
> get_target_property(test_suite_folder ${test_suite} FOLDER)
> Index: cmake/config-ix.cmake
> ===================================================================
> --- cmake/config-ix.cmake
> +++ cmake/config-ix.cmake
> @@ -110,7 +110,8 @@
> endif()
>
> if(HAVE_LIBPTHREAD)
> - set(PTHREAD_LIB pthread)
> + find_package(Threads REQUIRED)
> + set(PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
> endif()
>
> # Don't look for these libraries on Windows. Also don't look for them if we're
>
>
More information about the llvm-commits
mailing list