Truly independent web browser
Meta: Build mimalloc without padding
Andreas Kling28645bb32d0f
diff --git a/Meta/CMake/vcpkg/overlay-ports/mimalloc/pkgconfig-cxx.diff b/Meta/CMake/vcpkg/overlay-ports/mimalloc/pkgconfig-cxx.diffnew file mode 100644index 00000000000..52c0ac35374--- /dev/null+++ b/Meta/CMake/vcpkg/overlay-ports/mimalloc/pkgconfig-cxx.diff@@ -0,0 +1,19 @@+diff --git a/CMakeLists.txt b/CMakeLists.txt+index 5cc7ec5..578d235 100644+--- a/CMakeLists.txt++++ b/CMakeLists.txt+@@ -680,8 +680,13 @@ endif()+++ # pkg-config file support++set(mi_cxx_libraries "")++if(MI_USE_CXX)++ set(mi_cxx_libraries ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})++ list(REMOVE_ITEM mi_cxx_libraries ${CMAKE_C_IMPLICIT_LINK_LIBRARIES})++endif()+ set(mi_pc_libraries "")+-foreach(item IN LISTS mi_libraries)++foreach(item IN LISTS mi_libraries mi_cxx_libraries)+ if(item MATCHES " *[-].*")+ set(mi_pc_libraries "${mi_pc_libraries} ${item}")+ else()diff --git a/Meta/CMake/vcpkg/overlay-ports/mimalloc/portfile.cmake b/Meta/CMake/vcpkg/overlay-ports/mimalloc/portfile.cmakenew file mode 100644index 00000000000..192b1b1fc33--- /dev/null+++ b/Meta/CMake/vcpkg/overlay-ports/mimalloc/portfile.cmake@@ -0,0 +1,62 @@+# NB: This is vcpkg's own mimalloc 2.2.7 port with the padding after each block turned off in release builds. The secure+# build pads every block to check for overflows when it is freed, which pushes many allocations into the next size+# class. Debug builds keep the check.+vcpkg_from_github(+ OUT_SOURCE_PATH SOURCE_PATH+ REPO microsoft/mimalloc+ REF "v${VERSION}"+ SHA512 19f5481c98822c6a279e2f2d26d6c54918e18bcafd515a76ca3a3845f3a5e599236ea042f9cadaf793dce0c1ede347d76cc2fc5503094288362a78034d4d8f71+ HEAD_REF master+ PATCHES+ pkgconfig-cxx.diff+)++vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS+ FEATURES+ override MI_OVERRIDE+ secure MI_SECURE+)+string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" MI_BUILD_STATIC)+string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" MI_BUILD_SHARED)++vcpkg_cmake_configure(+ SOURCE_PATH "${SOURCE_PATH}"+ OPTIONS+ ${FEATURE_OPTIONS}+ -DMI_USE_CXX=ON+ -DMI_BUILD_OBJECT=OFF+ -DMI_BUILD_TESTS=OFF+ -DMI_BUILD_STATIC=${MI_BUILD_STATIC}+ -DMI_BUILD_SHARED=${MI_BUILD_SHARED}+ -DMI_INSTALL_TOPLEVEL=ON+ OPTIONS_DEBUG+ -DMI_DEBUG_FULL=ON+ OPTIONS_RELEASE+ -DMI_DEBUG_FULL=OFF+ -DMI_NO_PADDING=ON+)++vcpkg_cmake_install()++vcpkg_copy_pdbs()++file(COPY+ "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake"+ "${CMAKE_CURRENT_LIST_DIR}/usage"+ DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"+)+vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/mimalloc)++if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")+ vcpkg_replace_string(+ "${CURRENT_PACKAGES_DIR}/include/mimalloc.h"+ "!defined(MI_SHARED_LIB)"+ "0 // !defined(MI_SHARED_LIB)"+ )+endif()+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")++vcpkg_fixup_pkgconfig()++vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")diff --git a/Meta/CMake/vcpkg/overlay-ports/mimalloc/usage b/Meta/CMake/vcpkg/overlay-ports/mimalloc/usagenew file mode 100644index 00000000000..df1eac25126--- /dev/null+++ b/Meta/CMake/vcpkg/overlay-ports/mimalloc/usage@@ -0,0 +1,9 @@+mimalloc provides CMake targets:++ find_package(mimalloc CONFIG REQUIRED)+ target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:mimalloc-static>,mimalloc-static,mimalloc>)++To ensure the mimalloc-override.dll is loaded at runtime on Windows with+dynamic linkage, it is suggested to insert some call to the mimalloc API+in the main function, eg. `mi_version()`. Cf.+https://github.com/microsoft/mimalloc/blob/dev/readme.md#dynamic-override-on-windowsdiff --git a/Meta/CMake/vcpkg/overlay-ports/mimalloc/vcpkg-cmake-wrapper.cmake b/Meta/CMake/vcpkg/overlay-ports/mimalloc/vcpkg-cmake-wrapper.cmakenew file mode 100644index 00000000000..281d8ce1db5--- /dev/null+++ b/Meta/CMake/vcpkg/overlay-ports/mimalloc/vcpkg-cmake-wrapper.cmake@@ -0,0 +1,21 @@+_find_package(${ARGS})++if(CMAKE_CURRENT_LIST_DIR STREQUAL "${MIMALLOC_CMAKE_DIR}/${MIMALLOC_VERSION_DIR}")+ set(MIMALLOC_INCLUDE_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")+ # As in vcpkg.cmake+ if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")+ set(MIMALLOC_LIBRARY_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib")+ else()+ set(MIMALLOC_LIBRARY_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib")+ endif()+ set(MIMALLOC_OBJECT_DIR "MIMALLOC_OBJECT_DIR-NOTFOUND") # not installed+ set(MIMALLOC_TARGET_DIR "${MIMALLOC_LIBRARY_DIR}")+endif()++if(TARGET mimalloc AND NOT TARGET mimalloc-static)+ add_library(mimalloc-static INTERFACE IMPORTED)+ set_target_properties(mimalloc-static PROPERTIES INTERFACE_LINK_LIBRARIES mimalloc)+elseif(TARGET mimalloc-static AND NOT TARGET mimalloc)+ add_library(mimalloc INTERFACE IMPORTED)+ set_target_properties(mimalloc PROPERTIES INTERFACE_LINK_LIBRARIES mimalloc-static)+endif()diff --git a/Meta/CMake/vcpkg/overlay-ports/mimalloc/vcpkg.json b/Meta/CMake/vcpkg/overlay-ports/mimalloc/vcpkg.jsonnew file mode 100644index 00000000000..6145317c7a5--- /dev/null+++ b/Meta/CMake/vcpkg/overlay-ports/mimalloc/vcpkg.json@@ -0,0 +1,28 @@+{+ "name": "mimalloc",+ "version": "2.2.7",+ "port-version": 1,+ "description": "Compact general purpose allocator with excellent performance",+ "homepage": "https://github.com/microsoft/mimalloc",+ "license": "MIT",+ "supports": "!uwp",+ "dependencies": [+ {+ "name": "vcpkg-cmake",+ "host": true+ },+ {+ "name": "vcpkg-cmake-config",+ "host": true+ }+ ],+ "features": {+ "override": {+ "description": "Override the standard malloc interface (i.e. define entry points for 'malloc', 'free', etc)",+ "supports": "!windows | !static"+ },+ "secure": {+ "description": "Use full security mitigations (like guard pages, allocation randomization, double-free mitigation, and free-list corruption detection)"+ }+ }+}diff --git a/vcpkg.json b/vcpkg.jsonindex bfebfcb9441..41ce348e9ed 100644--- a/vcpkg.json+++ b/vcpkg.json@@ -379,7 +379,7 @@},{"name": "mimalloc",- "version": "2.2.7#0"+ "version": "2.2.7#1"},{"name": "mman",