Permalink
Browse files

Move linking with jemalloc (and tcmalloc) first in the list

Jemalloc transparently enables multi-threading support (and starts
using thread-caching) as soon as an application starts spawning
threads. In order to detect this it intercepts calls to pthread_create
using symbol interposition. This only works in case jemalloc appears
before pthread in the symbol lookup scope.

This patch moves jemalloc linking first in the list, so that it appears
before pthread and it can correctly interpose on its symbols. tcmalloc
and its profiler are also moved there for consistency. Finally jemalloc
is now enabled in the options, so that it gets used if installed.
  • Loading branch information...
1 parent add89e4 commit 80687476bb722760be64a497d4446914cbd5ca72 @lcastelli lcastelli committed with scottmac Feb 11, 2011
Showing with 15 additions and 15 deletions.
  1. +14 −14 CMake/HPHPFindLibs.cmake
  2. +1 −1 CMake/Options.cmake
View
@@ -311,6 +311,20 @@ include_directories(${HPHP_HOME}/src)
include_directories(${HPHP_HOME}/src/system/gen)
macro(hphp_link target)
+ if (GOOGLE_HEAP_PROFILER_ENABLED OR GOOGLE_CPU_PROFILER_ENABLED)
+ target_link_libraries(${target} ${GOOGLE_PROFILER_LIB})
+ endif()
+
+ if (JEMALLOC_ENABLED)
+ target_link_libraries(${target} ${JEMALLOC_LIB})
+ endif()
+
+ if (GOOGLE_HEAP_PROFILER_ENABLED)
+ target_link_libraries(${target} ${GOOGLE_TCMALLOC_FULL_LIB})
+ elseif (GOOGLE_TCMALLOC_ENABLED)
+ target_link_libraries(${target} ${GOOGLE_TCMALLOC_MIN_LIB})
+ endif()
+
target_link_libraries(${target} ${Boost_LIBRARIES})
target_link_libraries(${target} ${MYSQL_CLIENT_LIBS})
target_link_libraries(${target} ${PCRE_LIBRARY})
@@ -358,20 +372,6 @@ endif()
target_link_libraries(${target} ${ICONV_LIB})
endif()
- if (GOOGLE_HEAP_PROFILER_ENABLED OR GOOGLE_CPU_PROFILER_ENABLED)
- target_link_libraries(${target} ${GOOGLE_PROFILER_LIB})
- endif()
-
- if (JEMALLOC_ENABLED)
- target_link_libraries(${target} ${JEMALLOC_LIB})
- endif()
-
- if (GOOGLE_HEAP_PROFILER_ENABLED)
- target_link_libraries(${target} ${GOOGLE_TCMALLOC_FULL_LIB})
- elseif (GOOGLE_TCMALLOC_ENABLED)
- target_link_libraries(${target} ${GOOGLE_TCMALLOC_MIN_LIB})
- endif()
-
target_link_libraries(${target} timelib)
target_link_libraries(${target} sqlite3)
View
@@ -17,7 +17,7 @@ option(ENABLE_FULL_SETLINE "Enable full setline function for debugger and code-c
option(WANT_FB_LIBMCC "want FB Memcache" OFF)
-option(USE_JEMALLOC "Use jemalloc" OFF)
+option(USE_JEMALLOC "Use jemalloc" ON)
option(USE_TCMALLOC "Use tcmalloc (if jemalloc is not used)" ON)
option(USE_GOOGLE_HEAP_PROFILER "Use Google heap profiler" OFF)

0 comments on commit 8068747

Please sign in to comment.