Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
BUILD: add boost library and jemalloc
Browse files Browse the repository at this point in the history
[Summary]
1. add extra/boost/boost_1_59_0.tar.gz
2. add jemalloc(4.2.1): revision 3de0353 from https://github.com/jemalloc/jemalloc
  • Loading branch information
BohuTANG committed Oct 16, 2016
1 parent e6b2987 commit 8e576b1
Show file tree
Hide file tree
Showing 202 changed files with 69,753 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ INCLUDE(protobuf)
INCLUDE(mysql_version)
INCLUDE(libutils)
INCLUDE(dtrace)
INCLUDE(jemalloc)
INCLUDE(plugin)
INCLUDE(install_macros)
INCLUDE(install_layout)
Expand Down Expand Up @@ -493,6 +494,7 @@ MYSQL_CHECK_LZ4()
IF(NOT WITHOUT_SERVER)
MYSQL_CHECK_PROTOBUF()
ENDIF()
CHECK_JEMALLOC()

# Check for SYS_thread_selfid system call
CHECK_C_SOURCE_COMPILES("
Expand Down
60 changes: 60 additions & 0 deletions cmake/jemalloc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
INCLUDE(ExternalProject)

MACRO (USE_BUNDLED_JEMALLOC)
SET(SOURCE_DIR "${CMAKE_SOURCE_DIR}/extra/jemalloc")
SET(BINARY_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/extra/jemalloc/build")
SET(LIBJEMALLOC "libjemalloc")
SET(JEMALLOC_CONFIGURE_OPTS "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}" "--with-private-namespace=jemalloc_internal_" "--enable-cc-silence")
IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT APPLE) # see the comment in CMakeLists.txt
LIST(APPEND JEMALLOC_CONFIGURE_OPTS --enable-debug)
ENDIF()

IF(CMAKE_GENERATOR MATCHES "Makefiles")
SET(MAKE_COMMAND ${CMAKE_MAKE_PROGRAM})
ELSE() # Xcode/Ninja generators
SET(MAKE_COMMAND make)
ENDIF()

ExternalProject_Add(jemalloc
PREFIX extra/jemalloc
SOURCE_DIR ${SOURCE_DIR}
BINARY_DIR ${BINARY_DIR}
STAMP_DIR ${BINARY_DIR}
CONFIGURE_COMMAND "${SOURCE_DIR}/configure" ${JEMALLOC_CONFIGURE_OPTS}
BUILD_COMMAND ${MAKE_COMMAND} "build_lib_static"
INSTALL_COMMAND ""
)
ADD_LIBRARY(libjemalloc STATIC IMPORTED)
SET_TARGET_PROPERTIES(libjemalloc PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/lib/libjemalloc_pic.a")
ADD_DEPENDENCIES(libjemalloc jemalloc)
ENDMACRO()

IF(CMAKE_SYSTEM_NAME MATCHES "Linux" OR APPLE)
# Linux and OSX are the only systems where bundled jemalloc can be built without problems,
# as they both have GNU make and jemalloc actually compiles.
# Also, BSDs use jemalloc as malloc already
SET(WITH_JEMALLOC_DEFAULT "yes")
ELSE()
SET(WITH_JEMALLOC_DEFAULT "no")
ENDIF()

SET(WITH_JEMALLOC ${WITH_JEMALLOC_DEFAULT} CACHE STRING
"Which jemalloc to use. Possible values are 'no', 'bundled', 'system', 'yes' (system if possible, otherwise bundled)")

MACRO (CHECK_JEMALLOC)
IF(WITH_JEMALLOC STREQUAL "system" OR WITH_JEMALLOC STREQUAL "yes")
CHECK_LIBRARY_EXISTS(jemalloc malloc_stats_print "" HAVE_JEMALLOC)
IF (HAVE_JEMALLOC)
SET(LIBJEMALLOC jemalloc)
SET(MALLOC_LIBRARY "system jemalloc")
ELSEIF (WITH_JEMALLOC STREQUAL "system")
MESSAGE(FATAL_ERROR "system jemalloc is not found")
ELSEIF (WITH_JEMALLOC STREQUAL "yes")
SET(trybundled 1)
ENDIF()
ENDIF()
IF(WITH_JEMALLOC STREQUAL "bundled" OR trybundled)
USE_BUNDLED_JEMALLOC()
SET(MALLOC_LIBRARY "bundled jemalloc")
ENDIF()
ENDMACRO()
5 changes: 5 additions & 0 deletions extra/boost/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Download from:
http://jenkins.percona.com/downloads/boost/boost_1_59_0.tar.gz

md5sum:
51528a0e3b33d9e10aaa311d9eb451e3
Binary file added extra/boost/boost_1_59_0.tar.gz
Binary file not shown.
27 changes: 27 additions & 0 deletions extra/jemalloc/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Unless otherwise specified, files in the jemalloc source distribution are
subject to the following license:
--------------------------------------------------------------------------------
Copyright (C) 2002-2016 Jason Evans <jasone@canonware.com>.
All rights reserved.
Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved.
Copyright (C) 2009-2016 Facebook, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice(s),
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice(s),
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Loading

0 comments on commit 8e576b1

Please sign in to comment.