From b0b93728f184a0213f9f4eb76b12f5f38e18feec Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 02:11:09 -0700 Subject: [PATCH 01/11] [jemalloc] Support non-Windows --- ports/jemalloc/portfile.cmake | 13 ++++++++----- ports/jemalloc/vcpkg.json | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ports/jemalloc/portfile.cmake b/ports/jemalloc/portfile.cmake index 013634577b0cb4..611208510fcaa9 100644 --- a/ports/jemalloc/portfile.cmake +++ b/ports/jemalloc/portfile.cmake @@ -10,6 +10,7 @@ vcpkg_from_github( fix-cmakelists.patch fix-utilities.patch fix-static-build.patch + add-unix-support.patch ) if (VCPKG_CRT_LINKAGE STREQUAL "dynamic") @@ -19,17 +20,19 @@ else() endif() vcpkg_configure_cmake( DISABLE_PARALLEL_CONFIGURE - SOURCE_PATH ${SOURCE_PATH} + SOURCE_PATH "${SOURCE_PATH}" PREFER_NINJA - OPTIONS -DGIT_FOUND=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON -Dwithout-export=${BUILD_STATIC_LIBRARY} + OPTIONS + -DGIT_FOUND=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON + -Dwithout-export=${BUILD_STATIC_LIBRARY} ) vcpkg_install_cmake() vcpkg_copy_pdbs() -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +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) +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/jemalloc/vcpkg.json b/ports/jemalloc/vcpkg.json index c23bdcaa803915..2e66f821ab5509 100644 --- a/ports/jemalloc/vcpkg.json +++ b/ports/jemalloc/vcpkg.json @@ -1,7 +1,9 @@ { "name": "jemalloc", "version-string": "4.3.1", - "port-version": 5, + "port-version": 6, "description": "jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support", - "homepage": "https://github.com/jemalloc/jemalloc-cmake" + "homepage": "https://github.com/jemalloc/jemalloc-cmake", + "license": "BSD-2-Clause", + "supports": "!arm & !uwp" } From 0f7eb77616d28765abe9cb81291f1640de316669 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 02:13:30 -0700 Subject: [PATCH 02/11] Update supports value, upload patch --- ports/jemalloc/add-unix-support.patch | 104 ++++++++++++++++++++++++++ ports/jemalloc/vcpkg.json | 2 +- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 ports/jemalloc/add-unix-support.patch diff --git a/ports/jemalloc/add-unix-support.patch b/ports/jemalloc/add-unix-support.patch new file mode 100644 index 00000000000000..e0e39ce0b57455 --- /dev/null +++ b/ports/jemalloc/add-unix-support.patch @@ -0,0 +1,104 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 55e6a5f..dee41b6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -492,6 +492,7 @@ if(NOT WIN32) + set(JEMALLOC_HAVE_SYSCALL 1) + endif() + ++ include(CheckFunctionExists) + CHECK_FUNCTION_EXISTS(secure_getenv HAVE_SECURE_GETENV) + if(HAVE_SECURE_GETENV) + set(JEMALLOC_HAVE_SECURE_GETENV 1) +diff --git a/Utilities.cmake b/Utilities.cmake +index 8fe8bb4..878dbe3 100644 +--- a/Utilities.cmake ++++ b/Utilities.cmake +@@ -628,17 +628,6 @@ function (ConfigureFile file_path output_path ExpandDefine) + # Use Powershell to convert autoconf file to a cmake conf file + # and see if that fixes the issue of line continuations and ; in the file + # PS Snipper +-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 { +-if($_ -match '^#undef[ \t]*[^ \t]*') +- { $_ -replace '^#undef[ \t]*([^ \t]*)','#cmakedefine $1 @$1@' } else {$_} +-} | +-Set-Content \"${ntv_file_path}.cmake\"" +-) + + if(EXISTS ${file_path}) + if(NOT ${ExpandDefine}) +@@ -646,17 +635,15 @@ if(EXISTS ${file_path}) + else() + file(REMOVE ${file_path}.cmake) + # Convert autoconf .in into a cmake .in +- execute_process(COMMAND powershell -Command "${PS_CMD}" +- RESULT_VARIABLE error_level +- ERROR_VARIABLE error_output) +- +- if(NOT ${error_level} EQUAL 0) +- message(FATAL_ERROR "Powershell completed with ${error_level} : ${error_output}") +- endif() ++ file(RELATIVE_PATH ntv_file_relative_path "${CMAKE_SOURCE_DIR}" "${file_path}") ++ file(READ "${file_path}" NTV_FILE_CONTENT) ++ string(REGEX REPLACE "#( *)undef +([^ ][^\n]+)\n" "#\\1cmakedefine \\2 @\\2@ \n" NTV_FILE_CONTENT "${NTV_FILE_CONTENT}") ++ file(WRITE "${CMAKE_BINARY_DIR}/${ntv_file_relative_path}" "${NTV_FILE_CONTENT}") + +- configure_file(${file_path}.cmake ${output_path} @ONLY NEWLINE_STYLE WIN32) ++ configure_file(${CMAKE_BINARY_DIR}/${ntv_file_relative_path} ${output_path} @ONLY NEWLINE_STYLE WIN32) + file(REMOVE ${file_path}.cmake) + endif() ++ include_directories("${CMAKE_SOURCE_DIR}/include") + else() + message(FATAL_ERROR "${file_path} not found") + endif() +@@ -728,9 +715,14 @@ set(SRC "${WORK_FOLDER}/getpagesize.c") + set(COMPILE_OUTPUT_FILE "${WORK_FOLDER}/getpagesize.log") + + file(WRITE ${SRC} ++"#ifdef _WIN32\n" + "#include \n" + "#include \n" ++"#else\n" ++"#include \n" ++"#endif\n" + "int main(int argc, const char** argv) {\n" ++"#ifdef _WIN32\n" + "int result;\n" + "#ifdef _WIN32\n" + "SYSTEM_INFO si;\n" +@@ -740,6 +732,9 @@ file(WRITE ${SRC} + "result = sysconf(_SC_PAGESIZE);\n" + "#endif\n" + "printf(\"%d\", result);\n" ++"#else\n" ++"printf(\"page size = %d\\n\", getpagesize());\n" ++"#endif\n" + "return 0;\n" + "}\n" + ) +@@ -776,6 +771,7 @@ function(JeCflagsAppend cflags APPEND_TO_VAR RESULT_VAR) + + # Combine the result to try + set(TFLAGS "${${APPEND_TO_VAR}} ${cflags}") ++ include(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG(${TFLAGS} status) + + if(status) +diff --git a/src/jemalloc.c b/src/jemalloc.c +index 38650ff..2b8c545 100644 +--- a/src/jemalloc.c ++++ b/src/jemalloc.c +@@ -988,7 +988,7 @@ malloc_conf_init(void) + int saved_errno = errno; + const char *linkname = + # ifdef JEMALLOC_PREFIX +- "/etc/"JEMALLOC_PREFIX"malloc.conf" ++ "/etc/JEMALLOC_PREFIXmalloc.conf" + # else + "/etc/malloc.conf" + # endif diff --git a/ports/jemalloc/vcpkg.json b/ports/jemalloc/vcpkg.json index 2e66f821ab5509..94d0ced6917add 100644 --- a/ports/jemalloc/vcpkg.json +++ b/ports/jemalloc/vcpkg.json @@ -5,5 +5,5 @@ "description": "jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support", "homepage": "https://github.com/jemalloc/jemalloc-cmake", "license": "BSD-2-Clause", - "supports": "!arm & !uwp" + "supports": "!arm & !uwp & !(windows & static)" } From 752578f34b3b50168c5b4f61084de67424a9ca78 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 02:13:38 -0700 Subject: [PATCH 03/11] cleanup baseline --- scripts/ci.baseline.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 11fe1ca062fced..c565c38692c357 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -398,12 +398,6 @@ isal:x64-windows=fail isal:x64-windows-static=fail isal:x64-windows-static-md=fail isal:x86-windows=fail -jemalloc:arm64-windows=fail -jemalloc:arm-uwp=fail -jemalloc:x64-linux=fail -jemalloc:x64-osx=fail -jemalloc:x64-uwp=fail -jemalloc:x64-windows-static=fail jinja2cpplight:arm-uwp=fail jinja2cpplight:x64-uwp=fail kfr:arm64-windows=fail From 5871faf413795880bc489e2cb81d955f9311f6cf Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 02:14:09 -0700 Subject: [PATCH 04/11] deprecate version-string --- ports/jemalloc/vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/jemalloc/vcpkg.json b/ports/jemalloc/vcpkg.json index 94d0ced6917add..f28d98f2e1b3c8 100644 --- a/ports/jemalloc/vcpkg.json +++ b/ports/jemalloc/vcpkg.json @@ -1,6 +1,6 @@ { "name": "jemalloc", - "version-string": "4.3.1", + "version": "4.3.1", "port-version": 6, "description": "jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support", "homepage": "https://github.com/jemalloc/jemalloc-cmake", From b22f3dcbb1f9517e76f1a6efb5495c3937dd3ece Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 02:14:17 -0700 Subject: [PATCH 05/11] version --- versions/baseline.json | 2 +- versions/j-/jemalloc.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index c315072c5e6ed3..ca23492b03e2ff 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3066,7 +3066,7 @@ }, "jemalloc": { "baseline": "4.3.1", - "port-version": 5 + "port-version": 6 }, "jinja2cpplight": { "baseline": "2018-05-08", diff --git a/versions/j-/jemalloc.json b/versions/j-/jemalloc.json index a27e65c4c646a3..cd289117f4b0ac 100644 --- a/versions/j-/jemalloc.json +++ b/versions/j-/jemalloc.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "ed300e5586d3558b58e25b909103810eeb65d812", + "version": "4.3.1", + "port-version": 6 + }, { "git-tree": "0ced62e7a268f8442b2e808df7b094afe8998c38", "version-string": "4.3.1", From 4fd4ef874879d37e809fdf2b28ec56d2da8110e1 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 19:57:45 -0700 Subject: [PATCH 06/11] Fix OSX build --- ports/jemalloc/add-unix-support.patch | 71 +++++++++++++++++++++------ 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/ports/jemalloc/add-unix-support.patch b/ports/jemalloc/add-unix-support.patch index e0e39ce0b57455..d1400b8db8b69b 100644 --- a/ports/jemalloc/add-unix-support.patch +++ b/ports/jemalloc/add-unix-support.patch @@ -1,8 +1,25 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 55e6a5f..dee41b6 100644 +index 55e6a5f..fa44dec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -492,6 +492,7 @@ if(NOT WIN32) +@@ -58,6 +58,7 @@ option(force_lazy_lock "Forcing lazy-lock to avoid allocator/threading bootstrap + # install_prefix - installation directory prefix + # with-xslroot= XSL stylesheet root path + option(build-tests "Build tests" OFF) ++option(disable-zone-allocator "Disable zone allocator for Darwin" ON) + + set (PACKAGE_NAME "jemalloc") + project (${PACKAGE_NAME} C) +@@ -205,7 +206,7 @@ set(abi "elf") + + # Whether malloc_usable_size definition can use const argument + CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H) +-if(HAVE_MALLOC_H) ++if(HAVE_MALLOC_H OR APPLE) + set(JEMALLOC_USABLE_SIZE_CONST const) + endif() + +@@ -492,6 +493,7 @@ if(NOT WIN32) set(JEMALLOC_HAVE_SYSCALL 1) endif() @@ -10,8 +27,17 @@ index 55e6a5f..dee41b6 100644 CHECK_FUNCTION_EXISTS(secure_getenv HAVE_SECURE_GETENV) if(HAVE_SECURE_GETENV) set(JEMALLOC_HAVE_SECURE_GETENV 1) +@@ -702,7 +704,7 @@ set(C_SRCS + src/witness.c + ) + +-if(CMAKE_SYSTEM_NAME MATCHES "Darwin") ++if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND NOT disable-zone-allocator) + list(APPEND C_SRCS src/zone.c) + endif() + diff --git a/Utilities.cmake b/Utilities.cmake -index 8fe8bb4..878dbe3 100644 +index 8fe8bb4..755e390 100644 --- a/Utilities.cmake +++ b/Utilities.cmake @@ -628,17 +628,6 @@ function (ConfigureFile file_path output_path ExpandDefine) @@ -56,32 +82,47 @@ index 8fe8bb4..878dbe3 100644 else() message(FATAL_ERROR "${file_path} not found") endif() -@@ -728,9 +715,14 @@ set(SRC "${WORK_FOLDER}/getpagesize.c") +@@ -728,18 +715,35 @@ set(SRC "${WORK_FOLDER}/getpagesize.c") set(COMPILE_OUTPUT_FILE "${WORK_FOLDER}/getpagesize.log") file(WRITE ${SRC} -+"#ifdef _WIN32\n" - "#include \n" +-"#include \n" "#include \n" ++"#ifdef _WIN32\n" ++"#include \n" ++"#elif defined(__APPLE__)\n" ++"#include \n" ++"#include \n" +"#else\n" +"#include \n" +"#endif\n" "int main(int argc, const char** argv) {\n" -+"#ifdef _WIN32\n" - "int result;\n" +-"int result;\n" "#ifdef _WIN32\n" ++"int result;\n" "SYSTEM_INFO si;\n" -@@ -740,6 +732,9 @@ file(WRITE ${SRC} - "result = sysconf(_SC_PAGESIZE);\n" + "GetSystemInfo(&si);\n" + "result = si.dwPageSize;\n" ++"printf(\"%d\", result);\n" ++"#elif defined(__APPLE__)\n" ++"int mib[2], value, pagesize;\n" ++"size_t size;\n" ++"mib[0] = CTL_HW;\n" ++"mib[1] = HW_PAGESIZE;\n" ++"size = sizeof value;\n" ++"if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)\n" ++" pagesize = -1;\n" ++"pagesize = value;\n" ++"printf(\"%d\", pagesize);\n" + "#else\n" +-"result = sysconf(_SC_PAGESIZE);\n" ++"printf(\"%d\", getpagesize());\n" "#endif\n" - "printf(\"%d\", result);\n" -+"#else\n" -+"printf(\"page size = %d\\n\", getpagesize());\n" -+"#endif\n" +-"printf(\"%d\", result);\n" "return 0;\n" "}\n" ) -@@ -776,6 +771,7 @@ function(JeCflagsAppend cflags APPEND_TO_VAR RESULT_VAR) +@@ -776,6 +780,7 @@ function(JeCflagsAppend cflags APPEND_TO_VAR RESULT_VAR) # Combine the result to try set(TFLAGS "${${APPEND_TO_VAR}} ${cflags}") From 5994ea285947f9f2dcd70853544403cec2bdd201 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 22:42:47 -0700 Subject: [PATCH 07/11] version --- versions/j-/jemalloc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/j-/jemalloc.json b/versions/j-/jemalloc.json index cd289117f4b0ac..86f33b392dedc5 100644 --- a/versions/j-/jemalloc.json +++ b/versions/j-/jemalloc.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "ed300e5586d3558b58e25b909103810eeb65d812", + "git-tree": "9927f742f31ed7298de5152335eadec99fc672ed", "version": "4.3.1", "port-version": 6 }, From 5e756913fbdff59201c05acff73d99d687cb2849 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 22:57:44 -0700 Subject: [PATCH 08/11] deprecate functions --- ports/jemalloc/portfile.cmake | 6 ++---- ports/jemalloc/vcpkg.json | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ports/jemalloc/portfile.cmake b/ports/jemalloc/portfile.cmake index 611208510fcaa9..035884c61d93ab 100644 --- a/ports/jemalloc/portfile.cmake +++ b/ports/jemalloc/portfile.cmake @@ -18,18 +18,16 @@ if (VCPKG_CRT_LINKAGE STREQUAL "dynamic") else() set(BUILD_STATIC_LIBRARY ON) endif() -vcpkg_configure_cmake( +vcpkg_cmake_configure( DISABLE_PARALLEL_CONFIGURE SOURCE_PATH "${SOURCE_PATH}" - PREFER_NINJA OPTIONS -DGIT_FOUND=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON -Dwithout-export=${BUILD_STATIC_LIBRARY} ) -vcpkg_install_cmake() - +vcpkg_cmake_install() vcpkg_copy_pdbs() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") diff --git a/ports/jemalloc/vcpkg.json b/ports/jemalloc/vcpkg.json index f28d98f2e1b3c8..0f86a97f7cb7a5 100644 --- a/ports/jemalloc/vcpkg.json +++ b/ports/jemalloc/vcpkg.json @@ -5,5 +5,11 @@ "description": "jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support", "homepage": "https://github.com/jemalloc/jemalloc-cmake", "license": "BSD-2-Clause", - "supports": "!arm & !uwp & !(windows & static)" + "supports": "!arm & !uwp & !(windows & static)", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + } + ] } From 5ba70d3bcd383fc061638390e94ce853bb717778 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 22:58:01 -0700 Subject: [PATCH 09/11] version --- versions/j-/jemalloc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/j-/jemalloc.json b/versions/j-/jemalloc.json index 86f33b392dedc5..9983b3e6e8e78f 100644 --- a/versions/j-/jemalloc.json +++ b/versions/j-/jemalloc.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "9927f742f31ed7298de5152335eadec99fc672ed", + "git-tree": "3c3dca7363ffe15e3a5920697ea312bd72260428", "version": "4.3.1", "port-version": 6 }, From 1e5e048b39606595b534c438b772aa7ac066d700 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 23:39:01 -0700 Subject: [PATCH 10/11] only force dynamic build on Windows --- ports/jemalloc/portfile.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/jemalloc/portfile.cmake b/ports/jemalloc/portfile.cmake index 035884c61d93ab..e6330744e9d7b1 100644 --- a/ports/jemalloc/portfile.cmake +++ b/ports/jemalloc/portfile.cmake @@ -1,4 +1,6 @@ -vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) +if (VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) +endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH From a0b8a9ca3848ef0c5f37a3930384725fe6875e85 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 14 Jun 2022 23:39:10 -0700 Subject: [PATCH 11/11] version --- versions/j-/jemalloc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/j-/jemalloc.json b/versions/j-/jemalloc.json index 9983b3e6e8e78f..f43d468c190ec2 100644 --- a/versions/j-/jemalloc.json +++ b/versions/j-/jemalloc.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "3c3dca7363ffe15e3a5920697ea312bd72260428", + "git-tree": "b46ade047a817b79a86ba0647901d501f9f16bf1", "version": "4.3.1", "port-version": 6 },