Skip to content

Commit ef1d67e

Browse files
authored
Merge pull request #1262 from microsoft/dev-main
update main to v2.3.0
2 parents 75d69f4 + 11262dc commit ef1d67e

81 files changed

Lines changed: 3563 additions & 1114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
on:
2+
workflow_dispatch: # run the workflow manually
3+
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true # Cancel any in-progress runs of this workflow when a new run is triggered on the same ref (branch or tag)
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
RELEASE: Release v3.3.0
13+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
14+
15+
name: Release
16+
jobs:
17+
build:
18+
name: Bundle
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
branch: [v1.9.8,v2.3.0,v3.3.0] # [dev,dev2,dev3]
23+
# we build on the oldest ubuntu version for better binary compatibility.
24+
os: [windows-latest, macOS-latest, macos-15-intel, ubuntu-22.04, ubuntu-22.04-arm]
25+
26+
steps:
27+
# Checkout: https://github.com/actions/checkout
28+
- name: Checkout repository
29+
uses: actions/checkout@v6
30+
with:
31+
ref: ${{ matrix.branch }}
32+
fetch-tags: true
33+
fetch-depth: 0
34+
35+
# Build
36+
- name: Build (Windows)
37+
if: runner.os == 'Windows'
38+
run: |
39+
./bin/bundle.bat
40+
41+
- name: Build (Linux, macOS)
42+
if: runner.os != 'Windows'
43+
run: |
44+
./bin/bundle.sh
45+
46+
# Create a release: https://github.com/softprops/action-gh-release (MIT license)
47+
- name: Release
48+
uses: softprops/action-gh-release@v2
49+
if: ${{ env.RELEASE != '' && env.RELEASE != 'no' }}
50+
with:
51+
name: ${{ env.RELEASE }}
52+
draft: true
53+
body_path: doc/release-notes.md
54+
files: |
55+
out/bundle/*.tar.gz

.github/workflows/test.yaml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
on:
2+
workflow_dispatch: # allow running the workflow manually
3+
push:
4+
branches:
5+
- 'dev*'
6+
tags:
7+
- 'v*'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true # Cancel any in-progress runs of this workflow when a new run is triggered on the same ref (branch or tag)
12+
13+
name: Test
14+
jobs:
15+
build:
16+
name: Test
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
tests: [basic,extra]
21+
os: [windows-latest, macos-latest, ubuntu-latest, macos-14, macos-15-intel, ubuntu-22.04-arm, windows-11-arm]
22+
exclude:
23+
- os: macos-14
24+
tests: extra
25+
26+
steps:
27+
# Checkout: https://github.com/actions/checkout
28+
- name: Checkout repository
29+
uses: actions/checkout@v6
30+
31+
# Basic
32+
- name: Debug
33+
if: matrix.tests == 'basic'
34+
run: |
35+
cmake . -B out/debug -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON
36+
cmake --build out/debug --parallel 4 --config Debug
37+
ctest --test-dir out/debug --verbose --timeout 240 -C Debug
38+
39+
- name: Release
40+
if: matrix.tests == 'basic'
41+
run: |
42+
cmake . -B out/release -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON
43+
cmake --build out/release --parallel 4 --config Release
44+
ctest --test-dir out/release --verbose --timeout 240 -C Release
45+
46+
- name: Secure
47+
if: matrix.tests == 'basic'
48+
run: |
49+
cmake . -B out/secure -DCMAKE_BUILD_TYPE=Release -DMI_SECURE=ON
50+
cmake --build out/secure --parallel 4 --config Release
51+
ctest --test-dir out/secure --verbose --timeout 240 -C Release
52+
53+
# Basic, C++
54+
- name: Debug, C++
55+
if: matrix.tests == 'basic' && runner.os != 'Windows' # windows already uses C++ by default
56+
run: |
57+
cmake . -B out/debug-cxx -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_USE_CXX=ON
58+
cmake --build out/debug-cxx --parallel 8 --config Debug
59+
ctest --test-dir out/debug-cxx --verbose --timeout 240 -C Debug
60+
61+
- name: Release, C++
62+
if: matrix.tests == 'basic' && runner.os == 'Linux' # windows already uses C++ by default; macOS interpose does not work well with C++
63+
run: |
64+
cmake . -B out/release-cxx -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_USE_CXX=ON
65+
cmake --build out/release-cxx --parallel 8 --config Release
66+
ctest --test-dir out/release-cxx --verbose --timeout 240 -C Release
67+
68+
# Extra, Windows x86
69+
- name: Debug, Win32
70+
if: matrix.tests == 'extra' && runner.os == 'Windows' && !endsWith(matrix.os,'arm')
71+
run: |
72+
cmake . -B out/debug-x86 -DCMAKE_BUILD_TYPE=Debug -A Win32
73+
cmake --build out/debug-x86 --parallel 4 --config Debug
74+
ctest --test-dir out/debug-x86 --verbose --timeout 240 -C Debug
75+
76+
- name: Release, Win32
77+
if: matrix.tests == 'extra' && runner.os == 'Windows' && !endsWith(matrix.os,'arm')
78+
run: |
79+
cmake . -B out/release-x86 -DCMAKE_BUILD_TYPE=Release -A Win32
80+
cmake --build out/release-x86 --parallel 4 --config Release
81+
ctest --test-dir out/release-x86 --verbose --timeout 240 -C Release
82+
83+
- name: Debug, clang-cl
84+
if: matrix.tests == 'extra' && runner.os == 'Windows' && !endsWith(matrix.os,'arm')
85+
run: |
86+
cmake . -B out/debug-clang -DCMAKE_BUILD_TYPE=Debug -A Win32 -T ClangCl
87+
cmake --build out/debug-clang --parallel 4 --config Debug
88+
ctest --test-dir out/debug-clang --verbose --timeout 240 -C Debug
89+
90+
- name: Release, clang-cl
91+
if: matrix.tests == 'extra' && runner.os == 'Windows' && !endsWith(matrix.os,'arm')
92+
run: |
93+
cmake . -B out/release-clang -DCMAKE_BUILD_TYPE=Release -A Win32 -T ClangCl
94+
cmake --build out/release-clang --parallel 4 --config Release
95+
ctest --test-dir out/release-clang --verbose --timeout 240 -C Release
96+
97+
# Extra
98+
- name: Release, SIMD
99+
if: matrix.tests == 'extra'
100+
run: |
101+
cmake . -B out/release-simd -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_OPT_SIMD=ON
102+
cmake --build out/release-simd --parallel 8 --config Release
103+
ctest --test-dir out/release-simd --verbose --timeout 240 -C Release
104+
105+
- name: Release, C++, SIMD
106+
if: matrix.tests == 'basic' && runner.os != 'Windows' && runner.os != 'macOS'
107+
run: |
108+
cmake . -B out/release-cxx -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_OPT_SIMD=ON -DMI_USE_CXX=ON
109+
cmake --build out/release-cxx --parallel 8 --config Release
110+
ctest --test-dir out/release-cxx --verbose --timeout 240 -C Release
111+
112+
- name: Debug, C++, clang++
113+
if: matrix.tests == 'extra' && runner.os == 'Linux'
114+
run: |
115+
CC=clang CXX=clang++ cmake . -B out/debug-clang-cxx -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_USE_CXX=ON
116+
cmake --build out/debug-clang-cxx --parallel 8 --config Debug
117+
ctest --test-dir out/debug-clang-cxx --verbose --timeout 240 -C Debug
118+
119+
- name: Release, C++, clang++
120+
if: matrix.tests == 'extra' && runner.os == 'Linux'
121+
run: |
122+
CC=clang CXX=clang++ cmake . -B out/release-clang-cxx -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_USE_CXX=ON
123+
cmake --build out/release-clang-cxx --parallel 8 --config Release
124+
ctest --test-dir out/release-clang-cxx --verbose --timeout 240 -C Release
125+
126+
- name: Debug, ASAN
127+
if: matrix.tests == 'extra' && runner.os == 'Linux'
128+
run: |
129+
CC=clang CXX=clang++ cmake . -B out/debug-asan -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_TRACK_ASAN=ON
130+
cmake --build out/debug-asan --parallel 8 --config Debug
131+
ctest --test-dir out/debug-asan --verbose --timeout 240 -C Debug
132+
133+
- name: Debug, UBSAN
134+
if: matrix.tests == 'extra' && runner.os == 'Linux'
135+
run: |
136+
CC=clang CXX=clang++ cmake . -B out/debug-ubsan -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_DEBUG_UBSAN=ON
137+
cmake --build out/debug-ubsan --parallel 8 --config Debug
138+
ctest --test-dir out/debug-ubsan --verbose --timeout 240 -C Debug
139+
140+
- name: Debug, TSAN
141+
if: matrix.tests == 'extra' && runner.os == 'Linux'
142+
run: |
143+
CC=clang CXX=clang++ cmake . -B out/debug-tsan -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_DEBUG_TSAN=ON
144+
cmake --build out/debug-tsan --parallel 8 --config Debug
145+
ctest --test-dir out/debug-tsan --verbose --timeout 240 -C Debug
146+
147+
- name: Debug, Guarded
148+
if: matrix.tests == 'extra' && matrix.os != 'windows-11-arm' && runner.os != 'macOS'
149+
run: |
150+
cmake . -B out/debug-guarded -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_GUARDED=ON
151+
cmake --build out/debug-guarded --parallel 8 --config Debug
152+
ctest --test-dir out/debug-guarded --verbose --timeout 240 -C Debug
153+
env:
154+
MIMALLOC_GUARDED_SAMPLE_RATE: 100
155+
156+
- name: Release, Guarded
157+
if: matrix.tests == 'extra' && runner.os == 'Linux' && startsWith(github.ref_name,'dev3')
158+
run: |
159+
cmake . -B out/release-guarded -DCMAKE_BUILD_TYPE=Release -DMI_OPT_ARCH=ON -DMI_GUARDED=ON
160+
cmake --build out/release-guarded --parallel 8 --config Release
161+
ctest --test-dir out/release-guarded --verbose --timeout 240 -C Release
162+
env:
163+
MIMALLOC_GUARDED_SAMPLE_RATE: 100

CMakeLists.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ option(MI_PADDING "Enable padding to detect heap block overflow (alway
99
option(MI_OVERRIDE "Override the standard malloc interface (i.e. define entry points for 'malloc', 'free', etc)" ON)
1010
option(MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF)
1111
option(MI_SHOW_ERRORS "Show error and warning messages by default (only enabled by default in DEBUG mode)" OFF)
12-
option(MI_GUARDED "Build with guard pages behind certain object allocations (implies MI_NO_PADDING=ON)" OFF)
12+
option(MI_GUARDED "Build with guard pages behind certain object allocations (enabled by default in a debug build)" OFF)
1313
option(MI_USE_CXX "Use the C++ compiler to compile the library (instead of the C compiler)" OFF)
1414
option(MI_OPT_ARCH "Only for optimized builds: turn on architecture specific optimizations (for arm64: '-march=armv8.1-a' (2016))" OFF)
1515
option(MI_SEE_ASM "Generate assembly files" OFF)
@@ -128,7 +128,7 @@ set(MI_OPT_ARCH_FLAGS "")
128128
set(MI_ARCH "unknown")
129129
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86|i[3456]86)$" OR CMAKE_GENERATOR_PLATFORM MATCHES "^(x86|Win32)$")
130130
set(MI_ARCH "x86")
131-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64)$" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x64" OR "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) # must be before arm64
131+
elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64)$" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x64" OR "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") # must be before arm64
132132
set(MI_ARCH "x64")
133133
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv[89].?|ARM64)$" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES)
134134
set(MI_ARCH "arm64")
@@ -273,15 +273,6 @@ if(MI_TRACK_ETW)
273273
endif()
274274
endif()
275275

276-
if(MI_GUARDED)
277-
message(STATUS "Compile guard pages behind certain object allocations (MI_GUARDED=ON)")
278-
list(APPEND mi_defines MI_GUARDED=1)
279-
if(NOT MI_NO_PADDING)
280-
message(STATUS " Disabling padding due to guard pages (MI_NO_PADDING=ON)")
281-
set(MI_NO_PADDING ON)
282-
endif()
283-
endif()
284-
285276
if(MI_SEE_ASM)
286277
message(STATUS "Generate assembly listings (MI_SEE_ASM=ON)")
287278
list(APPEND mi_cflags -save-temps)
@@ -303,19 +294,31 @@ endif()
303294

304295
if(MI_DEBUG_FULL)
305296
message(STATUS "Set debug level to full assertion and internal invariant checking (MI_DEBUG_FULL=ON, expensive)")
297+
set(MI_DEBUG ON)
306298
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking (mi_assert, mi_assert_internal, and mi_assert_expensive)
307299
elseif(MI_DEBUG_INTERNAL)
308300
message(STATUS "Set debug level to internal assertion and invariant checking (MI_DEBUG_INTERNAL=ON)")
301+
set(MI_DEBUG ON)
309302
list(APPEND mi_defines MI_DEBUG=2) # invariant checking (mi_assert and mi_assert_internal)
310303
elseif(MI_DEBUG)
311304
message(STATUS "Set debug level to assertion checking (MI_DEBUG=ON)")
312305
list(APPEND mi_defines MI_DEBUG=1) # assertion checking (mi_assert)
313306
elseif(CMAKE_BUILD_TYPE MATCHES "Debug")
314307
message(STATUS "Set debug level to internal assertion and invariant checking (CMAKE_BUILD_TYPE=Debug)")
315308
set(MI_DEBUG_INTERNAL ON)
309+
set(MI_DEBUG ON)
316310
list(APPEND mi_defines MI_DEBUG=2) # invariant checking (mi_assert and mi_assert_internal)
317311
endif()
318312

313+
if(MI_DEBUG AND !MI_GUARDED)
314+
message(STATUS "Enable MI_GUARDED (since MI_DEBUG=ON)")
315+
set(MI_GUARDED=ON)
316+
endif()
317+
if(MI_GUARDED)
318+
message(STATUS "Compile guard pages behind certain object allocations (MI_GUARDED=ON)")
319+
list(APPEND mi_defines MI_GUARDED=1)
320+
endif()
321+
319322
if(MI_NO_PADDING)
320323
message(STATUS "Suppress any padding of heap blocks (MI_NO_PADDING=ON)")
321324
list(APPEND mi_defines MI_PADDING=0)
@@ -381,7 +384,7 @@ endif()
381384
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
382385
if(MI_NO_THP)
383386
message(STATUS "Disable transparent huge pages support (MI_NO_THP=ON)")
384-
list(APPEND mi_defines MI_NO_THP=1)
387+
list(APPEND mi_defines MI_DEFAULT_ALLOW_THP=0)
385388
endif()
386389
endif()
387390

@@ -465,7 +468,7 @@ if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
465468
list(APPEND mi_cflags /Zc:__cplusplus)
466469
if(MI_OPT_ARCH AND NOT MI_CLANG_CL)
467470
if(MI_ARCH STREQUAL "arm64")
468-
set(MI_OPT_ARCH_FLAGS "/arch:armv8.1") # fast atomics
471+
set(MI_OPT_ARCH_FLAGS "/arch:armv8.1") # fast atomics (LSE)
469472
endif()
470473
endif()
471474
endif()
@@ -605,7 +608,7 @@ if(MI_BUILD_SHARED)
605608
# On windows, the import library name for the dll would clash with the static mimalloc.lib library
606609
# so we postfix the dll import library with `.dll.lib` (and also the .pdb debug file)
607610
set_property(TARGET mimalloc PROPERTY ARCHIVE_OUTPUT_NAME "${mi_libname}.dll" )
608-
install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.lib" DESTINATION ${CMAKE_INSTALL_LIBDIR})
611+
install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.lib" DESTINATION ${CMAKE_INSTALL_LIBDIR}/mimalloc-${mi_version})
609612
set_property(TARGET mimalloc PROPERTY PDB_NAME "${mi_libname}.dll")
610613
# don't try to install the pdb since it may not be generated depending on the configuration
611614
# install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -768,13 +771,10 @@ if (MI_OVERRIDE)
768771
if (MI_BUILD_SHARED)
769772
target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
770773
endif()
771-
if(NOT WIN32)
772-
# It is only possible to override malloc on Windows when building as a DLL.
773-
if (MI_BUILD_STATIC)
774-
target_compile_definitions(mimalloc-static PRIVATE MI_MALLOC_OVERRIDE)
775-
endif()
776-
if (MI_BUILD_OBJECT)
777-
target_compile_definitions(mimalloc-obj PRIVATE MI_MALLOC_OVERRIDE)
778-
endif()
774+
if (MI_BUILD_STATIC)
775+
target_compile_definitions(mimalloc-static PRIVATE MI_MALLOC_OVERRIDE)
776+
endif()
777+
if (MI_BUILD_OBJECT)
778+
target_compile_definitions(mimalloc-obj PRIVATE MI_MALLOC_OVERRIDE)
779779
endif()
780780
endif()

azure-pipelines.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# https://aka.ms/yaml
55

66
trigger:
7+
batch: true
78
branches:
89
include:
910
- main
@@ -236,9 +237,9 @@ jobs:
236237
Debug:
237238
BuildType: debug
238239
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON
239-
Release:
240-
BuildType: release
241-
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release
240+
# Release:
241+
# BuildType: release
242+
# cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release
242243
steps:
243244
- task: CMake@1
244245
inputs:

0 commit comments

Comments
 (0)