Fix T57998: crash at start with jemalloc package on some Linux distributions.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 23 Nov 2018 10:24:04 +0000 (11:24 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 23 Nov 2018 10:26:31 +0000 (11:26 +0100)
The jemalloc library must be ahead of pthread in linking order, so jemalloc
can find the pthread symbols for its background thread.

build_files/cmake/macros.cmake

index 2b4d454a6a7228350e7bfa99029557d6fcb1bf7d..0143335d3b14927eed7341e4ec737087e2835924 100644 (file)
@@ -370,6 +370,11 @@ function(setup_liblinks
        set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
        set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
 
+       # jemalloc must be early in the list, to be before pthread (see T57998)
+       if(WITH_MEM_JEMALLOC)
+               target_link_libraries(${target} ${JEMALLOC_LIBRARIES})
+       endif()
+
        target_link_libraries(
                ${target}
                ${PNG_LIBRARIES}
@@ -485,9 +490,6 @@ function(setup_liblinks
                        )
                endif()
        endif()
-       if(WITH_MEM_JEMALLOC)
-               target_link_libraries(${target} ${JEMALLOC_LIBRARIES})
-       endif()
        if(WITH_MOD_CLOTH_ELTOPO)
                target_link_libraries(${target} ${LAPACK_LIBRARIES})
        endif()