From 727be4b538a7433f4c321cdd6a38a6f72b465f51 Mon Sep 17 00:00:00 2001 From: Arkadiy Shapkin Date: Wed, 10 May 2017 03:07:04 +0300 Subject: [jemalloc] Initial commit for jemalloc library --- ports/jemalloc/CONTROL | 4 +++ ports/jemalloc/fix-cmakelists.patch | 36 +++++++++++++++++++++++ ports/jemalloc/fix-utilities.patch | 30 +++++++++++++++++++ ports/jemalloc/portfile.cmake | 58 +++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 ports/jemalloc/CONTROL create mode 100644 ports/jemalloc/fix-cmakelists.patch create mode 100644 ports/jemalloc/fix-utilities.patch create mode 100644 ports/jemalloc/portfile.cmake diff --git a/ports/jemalloc/CONTROL b/ports/jemalloc/CONTROL new file mode 100644 index 000000000..e3c808657 --- /dev/null +++ b/ports/jemalloc/CONTROL @@ -0,0 +1,4 @@ +Source: jemalloc +Version: 4.3.1 +Description: jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support +Build-Depends: diff --git a/ports/jemalloc/fix-cmakelists.patch b/ports/jemalloc/fix-cmakelists.patch new file mode 100644 index 000000000..0094a15f5 --- /dev/null +++ b/ports/jemalloc/fix-cmakelists.patch @@ -0,0 +1,36 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 06e83ef..17526b0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -57,6 +57,7 @@ option(enable-lazy-lock "Enable lazy locking (only lock when multi-threaded" OFF + option(force_lazy_lock "Forcing lazy-lock to avoid allocator/threading bootstrap issues" OFF) + # install_prefix - installation directory prefix + # with-xslroot= XSL stylesheet root path ++option(build-tests "Build tests" OFF) + + set (PACKAGE_NAME "jemalloc") + project (${PACKAGE_NAME} C) +@@ -825,6 +826,17 @@ if(C_UTIL_INTEGRATION_DEFS) + "${C_UTIL_INTEGRATION_DEFS}") + endif() + ++install(FILES include/jemalloc/jemalloc${install_suffix}.h ++ DESTINATION include/jemalloc) ++ ++install(TARGETS ${LIBJEMALLOCSO} ++ EXPORT JemallocTargets ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) ++install(EXPORT JemallocTargets NAMESPACE jemalloc:: DESTINATION share/jemalloc) ++ ++if (build-tests) + ################################################################## + # Common source for Unit, Integration and stress test libraries + set(C_TESTLIB_SRCS +@@ -1028,4 +1040,4 @@ foreach(sourcefile ${TESTS_INTEGRATION}) + add_test(NAME ${exename} COMMAND ${exename}) + add_dependencies(check ${exename}) + endforeach(sourcefile ${TESTS_UNIT}) +- ++endif() diff --git a/ports/jemalloc/fix-utilities.patch b/ports/jemalloc/fix-utilities.patch new file mode 100644 index 000000000..32c39e0b3 --- /dev/null +++ b/ports/jemalloc/fix-utilities.patch @@ -0,0 +1,30 @@ +diff --git a/Utilities.cmake b/Utilities.cmake +index 562e948..d2d3530 100644 +--- a/Utilities.cmake ++++ b/Utilities.cmake +@@ -633,9 +633,11 @@ file(TO_NATIVE_PATH "${file_path}" ntv_file_path) + # This converts #undefs into #cmakedefines so configure_file can handle it + set(PS_CMD + "Get-Content \"${ntv_file_path}\" | +-ForEach { ++ForEach { + if($_ -match '^#undef[ \t]*[^ \t]*') +- { $_ -replace '^#undef[ \t]*([^ \t]*)','#cmakedefine $1 @$1@' } else {$_}}" ++ { $_ -replace '^#undef[ \t]*([^ \t]*)','#cmakedefine $1 @$1@' } else {$_} ++} | ++Set-Content \"${ntv_file_path}.cmake\"" + ) + + if(EXISTS ${file_path}) +@@ -646,9 +648,8 @@ if(EXISTS ${file_path}) + # Convert autoconf .in into a cmake .in + execute_process(COMMAND powershell -Command "${PS_CMD}" + RESULT_VARIABLE error_level +- ERROR_VARIABLE error_output +- OUTPUT_FILE ${file_path}.cmake) +- ++ ERROR_VARIABLE error_output) ++ + if(NOT ${error_level} EQUAL 0) + message(FATAL_ERROR "Powershell completed with ${error_level} : ${error_output}") + endif() diff --git a/ports/jemalloc/portfile.cmake b/ports/jemalloc/portfile.cmake new file mode 100644 index 000000000..22aa76f08 --- /dev/null +++ b/ports/jemalloc/portfile.cmake @@ -0,0 +1,58 @@ +if (VCPKG_LIBRARY_LINKAGE STREQUAL static) + message(STATUS "Warning: Static building not supported yet. Building dynamic.") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + +include(vcpkg_common_functions) + +set(GIT_URL "https://github.com/jemalloc/jemalloc-cmake.git") +set(GIT_REF "jemalloc-cmake.4.3.1") + +if(NOT EXISTS "${DOWNLOADS}/jemalloc-cmake.git") + message(STATUS "Cloning") + vcpkg_execute_required_process( + COMMAND ${GIT} clone --bare ${GIT_URL} ${DOWNLOADS}/jemalloc-cmake.git + WORKING_DIRECTORY ${DOWNLOADS} + LOGNAME clone + ) +endif() + +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src) + +if(NOT EXISTS "${SOURCE_PATH}/.git") + message(STATUS "Adding worktree") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}) + vcpkg_execute_required_process( + COMMAND ${GIT} worktree add -f --detach ${SOURCE_PATH} ${GIT_REF} + WORKING_DIRECTORY ${DOWNLOADS}/jemalloc-cmake.git + LOGNAME worktree + ) + message(STATUS "Patching") + vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-cmakelists.patch" + PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-utilities.patch" + ) +endif() + +# jemalloc uses git to get it version +find_program(GIT NAMES git git.cmd) +get_filename_component(GIT_EXE_PATH ${GIT} DIRECTORY) +set(ENV{PATH} "${GIT_EXE_PATH};$ENV{PATH}") + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA +) + +vcpkg_install_cmake() + +vcpkg_copy_pdbs() + +vcpkg_fixup_cmake_targets() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +# Handle copyright +file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/jemalloc) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/jemalloc/COPYING ${CURRENT_PACKAGES_DIR}/share/jemalloc/copyright) -- cgit v1.2.3 From 7399ea0d6ee6095266c8aa7d4c7706c53e30e5d1 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 8 Aug 2017 15:10:54 -0700 Subject: [jemalloc] Update to use vcpkg_from_github. Avoid adding config scripts that are not present in upstream. Rename DLLs to 'jemalloc' to match expectations elsewhere. --- ports/jemalloc/CONTROL | 2 +- ports/jemalloc/fix-cmakelists.patch | 43 ++++++++++++++++++++++++++----- ports/jemalloc/portfile.cmake | 50 +++++++++++-------------------------- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/ports/jemalloc/CONTROL b/ports/jemalloc/CONTROL index e3c808657..c867b4573 100644 --- a/ports/jemalloc/CONTROL +++ b/ports/jemalloc/CONTROL @@ -1,4 +1,4 @@ Source: jemalloc -Version: 4.3.1 +Version: 4.3.1-1 Description: jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support Build-Depends: diff --git a/ports/jemalloc/fix-cmakelists.patch b/ports/jemalloc/fix-cmakelists.patch index 0094a15f5..a19cb4050 100644 --- a/ports/jemalloc/fix-cmakelists.patch +++ b/ports/jemalloc/fix-cmakelists.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 06e83ef..17526b0 100644 +index 06e83ef..229e17a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ option(enable-lazy-lock "Enable lazy locking (only lock when multi-threaded" OFF @@ -10,7 +10,41 @@ index 06e83ef..17526b0 100644 set (PACKAGE_NAME "jemalloc") project (${PACKAGE_NAME} C) -@@ -825,6 +826,17 @@ if(C_UTIL_INTEGRATION_DEFS) +@@ -711,12 +712,8 @@ endif() + + # The original library, delivery product + set(LIBJEMALLOCLIB jemalloc${install_suffix}) +-add_library(${LIBJEMALLOCLIB} STATIC ${C_SRCS}) +- +-# Now add shared library. Needed for integration tests +-# and a benchmark +-set(LIBJEMALLOCSO jemallocso${install_suffix}) +-add_library(${LIBJEMALLOCSO} SHARED ${C_SRCS}) ++set(LIBJEMALLOCSO ${LIBJEMALLOCLIB}) ++add_library(${LIBJEMALLOCLIB} ${C_SRCS}) + + if(WIN32) + # May want to replace /d2Zi+ to /Zo +@@ -745,8 +745,6 @@ if(WIN32) + # either impport or export which is both wrong for a static library + set_target_properties(${LIBJEMALLOCLIB} + PROPERTIES +- COMPILE_DEFINITIONS +- "JEMALLOC_EXPORT=" + CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG + ${PROJECT_BINARY_DIR}/Debug + CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE +@@ -754,6 +752,9 @@ if(WIN32) + COMPILE_PDB_NAME + ${LIBJEMALLOCLIB} + ) ++ if(NOT BUILD_SHARED_LIBS) ++ target_compile_definitions(${LIBJEMALLOCLIB} "JEMALLOC_EXPORT=") ++ endif() + + endif() + +@@ -825,6 +822,14 @@ if(C_UTIL_INTEGRATION_DEFS) "${C_UTIL_INTEGRATION_DEFS}") endif() @@ -18,17 +52,14 @@ index 06e83ef..17526b0 100644 + DESTINATION include/jemalloc) + +install(TARGETS ${LIBJEMALLOCSO} -+ EXPORT JemallocTargets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) -+install(EXPORT JemallocTargets NAMESPACE jemalloc:: DESTINATION share/jemalloc) -+ +if (build-tests) ################################################################## # Common source for Unit, Integration and stress test libraries set(C_TESTLIB_SRCS -@@ -1028,4 +1040,4 @@ foreach(sourcefile ${TESTS_INTEGRATION}) +@@ -1028,4 +1033,4 @@ foreach(sourcefile ${TESTS_INTEGRATION}) add_test(NAME ${exename} COMMAND ${exename}) add_dependencies(check ${exename}) endforeach(sourcefile ${TESTS_UNIT}) diff --git a/ports/jemalloc/portfile.cmake b/ports/jemalloc/portfile.cmake index 22aa76f08..3fe6fdbb7 100644 --- a/ports/jemalloc/portfile.cmake +++ b/ports/jemalloc/portfile.cmake @@ -5,52 +5,30 @@ endif() include(vcpkg_common_functions) -set(GIT_URL "https://github.com/jemalloc/jemalloc-cmake.git") -set(GIT_REF "jemalloc-cmake.4.3.1") - -if(NOT EXISTS "${DOWNLOADS}/jemalloc-cmake.git") - message(STATUS "Cloning") - vcpkg_execute_required_process( - COMMAND ${GIT} clone --bare ${GIT_URL} ${DOWNLOADS}/jemalloc-cmake.git - WORKING_DIRECTORY ${DOWNLOADS} - LOGNAME clone - ) -endif() - -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src) - -if(NOT EXISTS "${SOURCE_PATH}/.git") - message(STATUS "Adding worktree") - file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}) - vcpkg_execute_required_process( - COMMAND ${GIT} worktree add -f --detach ${SOURCE_PATH} ${GIT_REF} - WORKING_DIRECTORY ${DOWNLOADS}/jemalloc-cmake.git - LOGNAME worktree - ) - message(STATUS "Patching") - vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-cmakelists.patch" - PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-utilities.patch" - ) -endif() - -# jemalloc uses git to get it version -find_program(GIT NAMES git git.cmd) -get_filename_component(GIT_EXE_PATH ${GIT} DIRECTORY) -set(ENV{PATH} "${GIT_EXE_PATH};$ENV{PATH}") +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO jemalloc/jemalloc-cmake + REF jemalloc-cmake.4.3.1 + SHA512 e94b62ec3a53acc0ab5acb247d7646bc172108e80f592bb41c2dd50d181cbbeb33d623adf28415ffc0a0e2de3818af2dfe4c04af75ac891ef5042bc5bb186886 + HEAD_REF master +) +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES + "${CMAKE_CURRENT_LIST_DIR}/fix-cmakelists.patch" + "${CMAKE_CURRENT_LIST_DIR}/fix-utilities.patch" +) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA + OPTIONS -DGIT_FOUND=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON ) vcpkg_install_cmake() vcpkg_copy_pdbs() -vcpkg_fixup_cmake_targets() - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) # Handle copyright -- cgit v1.2.3