@shd101wyy/yo 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.github/skills/yo-async-effects/async-effects-recipes.md +6 -6
  2. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +34 -0
  3. package/.github/skills/yo-syntax/syntax-cheatsheet.md +441 -2
  4. package/out/cjs/index.cjs +563 -567
  5. package/out/cjs/yo-cli.cjs +656 -651
  6. package/out/cjs/yo-lsp.cjs +614 -618
  7. package/out/esm/index.mjs +582 -586
  8. package/out/types/src/codegen/codegen-c.d.ts +2 -2
  9. package/out/types/src/codegen/functions/collection.d.ts +2 -2
  10. package/out/types/src/codegen/functions/context.d.ts +3 -2
  11. package/out/types/src/codegen/types/collection.d.ts +2 -2
  12. package/out/types/src/codegen/utils/index.d.ts +4 -1
  13. package/out/types/src/doc/builder.d.ts +2 -2
  14. package/out/types/src/evaluator/calls/closure-type.d.ts +2 -2
  15. package/out/types/src/evaluator/calls/record-type.d.ts +11 -0
  16. package/out/types/src/evaluator/context.d.ts +8 -9
  17. package/out/types/src/evaluator/index.d.ts +3 -3
  18. package/out/types/src/evaluator/types/record.d.ts +14 -0
  19. package/out/types/src/evaluator/types/validation.d.ts +2 -2
  20. package/out/types/src/evaluator/values/anonymous-module.d.ts +5 -5
  21. package/out/types/src/evaluator/values/impl.d.ts +1 -1
  22. package/out/types/src/expr.d.ts +2 -4
  23. package/out/types/src/function-value.d.ts +1 -1
  24. package/out/types/src/lsp/document-manager.d.ts +1 -1
  25. package/out/types/src/module-manager.d.ts +3 -3
  26. package/out/types/src/test-runner.d.ts +1 -0
  27. package/out/types/src/types/creators.d.ts +3 -4
  28. package/out/types/src/types/definitions.d.ts +8 -19
  29. package/out/types/src/types/guards.d.ts +3 -3
  30. package/out/types/src/types/tags.d.ts +0 -1
  31. package/out/types/src/types/utils.d.ts +1 -1
  32. package/out/types/src/value-tag.d.ts +0 -1
  33. package/out/types/src/value.d.ts +6 -13
  34. package/out/types/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +1 -1
  36. package/std/error.yo +6 -6
  37. package/std/prelude.yo +1 -7
  38. package/vendor/mimalloc/.github/workflows/release.yaml +55 -0
  39. package/vendor/mimalloc/.github/workflows/stale.yaml +27 -0
  40. package/vendor/mimalloc/.github/workflows/test.yaml +163 -0
  41. package/vendor/mimalloc/CMakeLists.txt +52 -33
  42. package/vendor/mimalloc/azure-pipelines.yml +4 -3
  43. package/vendor/mimalloc/bin/bundle.bat +74 -0
  44. package/vendor/mimalloc/bin/bundle.sh +232 -0
  45. package/vendor/mimalloc/cmake/mimalloc-config-version.cmake +2 -2
  46. package/vendor/mimalloc/contrib/docker/alpine/Dockerfile +1 -1
  47. package/vendor/mimalloc/contrib/docker/alpine-arm32v7/Dockerfile +2 -2
  48. package/vendor/mimalloc/contrib/docker/alpine-x86/Dockerfile +1 -1
  49. package/vendor/mimalloc/contrib/docker/manylinux-x64/Dockerfile +1 -1
  50. package/vendor/mimalloc/contrib/vcpkg/portfile.cmake +4 -3
  51. package/vendor/mimalloc/contrib/vcpkg/vcpkg.json +1 -1
  52. package/vendor/mimalloc/doc/mimalloc-doc.h +42 -4
  53. package/vendor/mimalloc/doc/release-notes.md +15 -0
  54. package/vendor/mimalloc/ide/vs2022/mimalloc-lib.vcxproj +3 -3
  55. package/vendor/mimalloc/ide/vs2022/mimalloc-override-static-lib.vcxproj +511 -0
  56. package/vendor/mimalloc/ide/vs2022/mimalloc-override-static-lib.vcxproj.filters +117 -0
  57. package/vendor/mimalloc/ide/vs2022/mimalloc-test-dep.vcxproj +360 -0
  58. package/vendor/mimalloc/ide/vs2022/mimalloc-test-override-static.vcxproj +310 -0
  59. package/vendor/mimalloc/ide/vs2022/mimalloc.sln +92 -35
  60. package/vendor/mimalloc/include/mimalloc/atomic.h +178 -182
  61. package/vendor/mimalloc/include/mimalloc/bits.h +8 -10
  62. package/vendor/mimalloc/include/mimalloc/internal.h +76 -32
  63. package/vendor/mimalloc/include/mimalloc/prim.h +25 -18
  64. package/vendor/mimalloc/include/mimalloc/track.h +7 -2
  65. package/vendor/mimalloc/include/mimalloc/types.h +57 -29
  66. package/vendor/mimalloc/include/mimalloc-override.h +10 -10
  67. package/vendor/mimalloc/include/mimalloc-stats.h +18 -6
  68. package/vendor/mimalloc/include/mimalloc.h +22 -12
  69. package/vendor/mimalloc/readme.md +42 -17
  70. package/vendor/mimalloc/src/alloc-aligned.c +13 -11
  71. package/vendor/mimalloc/src/alloc-override.c +97 -17
  72. package/vendor/mimalloc/src/alloc-posix.c +44 -27
  73. package/vendor/mimalloc/src/alloc.c +73 -23
  74. package/vendor/mimalloc/src/arena-meta.c +3 -3
  75. package/vendor/mimalloc/src/arena.c +380 -192
  76. package/vendor/mimalloc/src/bitmap.c +68 -18
  77. package/vendor/mimalloc/src/bitmap.h +8 -4
  78. package/vendor/mimalloc/src/free.c +83 -47
  79. package/vendor/mimalloc/src/heap.c +94 -40
  80. package/vendor/mimalloc/src/init.c +273 -102
  81. package/vendor/mimalloc/src/libc.c +53 -8
  82. package/vendor/mimalloc/src/options.c +43 -40
  83. package/vendor/mimalloc/src/os.c +110 -45
  84. package/vendor/mimalloc/src/page-map.c +14 -8
  85. package/vendor/mimalloc/src/page-queue.c +9 -6
  86. package/vendor/mimalloc/src/page.c +26 -16
  87. package/vendor/mimalloc/src/prim/emscripten/prim.c +10 -1
  88. package/vendor/mimalloc/src/prim/osx/alloc-override-zone.c +35 -16
  89. package/vendor/mimalloc/src/prim/unix/prim.c +26 -22
  90. package/vendor/mimalloc/src/prim/wasi/prim.c +7 -4
  91. package/vendor/mimalloc/src/prim/windows/prim.c +247 -44
  92. package/vendor/mimalloc/src/random.c +8 -3
  93. package/vendor/mimalloc/src/stats.c +59 -48
  94. package/vendor/mimalloc/src/theap.c +85 -44
  95. package/vendor/mimalloc/src/threadlocal.c +102 -41
  96. package/vendor/mimalloc/test/main-override-static.c +31 -2
  97. package/vendor/mimalloc/test/main-override.c +27 -14
  98. package/vendor/mimalloc/test/main-static-dep.cpp +46 -0
  99. package/vendor/mimalloc/test/main-static-dep.h +11 -0
  100. package/vendor/mimalloc/test/test-api-fill.c +2 -2
  101. package/vendor/mimalloc/test/test-stress.c +3 -3
  102. package/vendor/mimalloc/test/test-wrong.c +11 -7
  103. package/out/types/src/evaluator/calls/module-type.d.ts +0 -11
  104. package/out/types/src/evaluator/types/module.d.ts +0 -19
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shd101wyy/yo",
3
3
  "displayName": "Yo",
4
- "version": "0.1.24",
4
+ "version": "0.1.26",
5
5
  "main": "./out/cjs/index.cjs",
6
6
  "module": "./out/esm/index.mjs",
7
7
  "types": "./out/types/src/index.d.ts",
package/std/error.yo CHANGED
@@ -19,19 +19,19 @@ export AnyError;
19
19
  /// Allows using `String` directly as an error type.
20
20
  impl(String, Error());
21
21
 
22
- /// Non-resumable exception handling effect module.
22
+ /// Non-resumable exception handling effect record.
23
23
  /// Use `throw` to raise an `AnyError` and abort the current computation.
24
- Exception :: module(
24
+ Exception :: struct(
25
25
  throw : (fn(forall(ResumeType : Type), error : AnyError) -> ResumeType)
26
26
  );
27
27
  export Exception;
28
28
 
29
29
 
30
- /// Creates a resumable exception module parameterized by the resume type.
30
+ /// Creates a resumable exception effect record parameterized by the resume type.
31
31
  /// Unlike `Exception`, the handler can return a value to resume the computation.
32
- ResumableException :: (fn(comptime(ResumeType) : Type) -> comptime(Module))(
33
- module(
32
+ ResumableException :: (fn(comptime(ResumeType) : Type) -> comptime(Type))(
33
+ struct(
34
34
  throw : (fn(error : AnyError) -> ResumeType)
35
35
  )
36
36
  );
37
- export ResumableException;
37
+ export ResumableException;
package/std/prelude.yo CHANGED
@@ -4228,9 +4228,6 @@ TypeInfo :: enum(
4228
4228
  ),
4229
4229
 
4230
4230
  // Meta types
4231
- Module(
4232
- fields : ComptimeList(TypeFieldInfo)
4233
- ),
4234
4231
  Trait(
4235
4232
  fields : ComptimeList(TraitFieldInfo),
4236
4233
  kind : TraitKind
@@ -4281,9 +4278,6 @@ impl(TypeInfo,
4281
4278
  is_trait : (fn(comptime(self) : TypeInfo) -> comptime(bool))(
4282
4279
  match(self, .Trait(_, _) => true, _ => false)
4283
4280
  ),
4284
- is_module : (fn(comptime(self) : TypeInfo) -> comptime(bool))(
4285
- match(self, .Module(_) => true, _ => false)
4286
- ),
4287
4281
  is_void : (fn(comptime(self) : TypeInfo) -> comptime(bool))(
4288
4282
  match(self, .Void => true, _ => false)
4289
4283
  ),
@@ -6190,7 +6184,7 @@ export JoinHandle;
6190
6184
  ///
6191
6185
  /// Provides `io.async`, `io.await`, `io.spawn`, and `io.state` operations.
6192
6186
  /// Automatically injected into `main` when declared with `using(io : IO)`.
6193
- IO :: module(
6187
+ IO :: struct(
6194
6188
  /// Create a new `Future` from an async closure.
6195
6189
  async : (fn(forall(T : Type, ...(E)), action : Impl(Fn(using(...(E))) -> T)) -> Impl(Future(T, ...(E)))),
6196
6190
  /// Await a `Future`, suspending until its result is ready.
@@ -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.2
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.10,v2.3.2,v3.3.2] # [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
@@ -0,0 +1,27 @@
1
+ on:
2
+ workflow_dispatch: # allow running the workflow manually
3
+ schedule:
4
+ - cron: "15 21 * * *" # minute, hour, day (1-31), month (1-12), day of the week (0 - 6 or SUN-SAT)
5
+
6
+ name: Close inactive issues
7
+ jobs:
8
+ close-issues:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ issues: write
12
+ pull-requests: write
13
+ steps:
14
+ - uses: actions/stale@v10
15
+ with:
16
+ days-before-issue-stale: 360
17
+ days-before-issue-close: 14
18
+ stale-issue-label: "stale"
19
+ stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 14 days. Thank you for your contributions!"
20
+ close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale. Please feel free to reopen if this is still an active issue."
21
+ days-before-pr-stale: -1
22
+ days-before-pr-close: -1
23
+ stale-pr-label: "stale"
24
+ stale-pr-message: "This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 14 days. Thank you for your contributions!"
25
+ close-pr-message: "This PR was closed because it has been inactive for 14 days since being marked as stale. Please feel free to reopen if you think this PR should still be considered. Thank you again for your help."
26
+ operations-per-run: 32
27
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -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' && 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
@@ -4,11 +4,12 @@ project(libmimalloc C)
4
4
  set(CMAKE_C_STANDARD 11)
5
5
  set(CMAKE_CXX_STANDARD 17)
6
6
 
7
- option(MI_SECURE "Use full security mitigations (like guard pages, allocation randomization, double-free mitigation, and free-list corruption detection)" OFF)
7
+ option(MI_SECURE "Use security mitigations (like meta data guard pages, allocation randomization, double-free mitigation, and free-list corruption detection)" OFF)
8
+ option(MI_SECURE_FULL "Use full security mitigations including guard pages at the end of each mimalloc page (may be expensive)" OFF)
8
9
  option(MI_OVERRIDE "Override the standard malloc interface (i.e. define entry points for 'malloc', 'free', etc)" ON)
9
10
  option(MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF)
10
11
  option(MI_SHOW_ERRORS "Show error and warning messages by default (only enabled by default in DEBUG mode)" OFF)
11
- 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)
12
13
  option(MI_USE_CXX "Use the C++ compiler to compile the library (instead of the C compiler)" OFF)
13
14
  option(MI_OPT_ARCH "Only for optimized builds: turn on architecture specific optimizations (for x64: '-march=haswell;-mavx2' (2013), for arm64: '-march=armv8.1-a' (2016))" OFF)
14
15
  option(MI_OPT_SIMD "Use SIMD instructions (requires MI_OPT_ARCH to be enabled)" OFF)
@@ -47,6 +48,10 @@ option(MI_SEE_ASM "Generate assembly files" OFF)
47
48
  option(MI_NO_USE_CXX "Use plain C compilation (has priority over MI_USE_CXX)" OFF)
48
49
  option(MI_NO_OPT_ARCH "Do not use architecture specific optimizations (like '-march=armv8.1-a' for example) (has priority over MI_OPT_ARCH)" OFF)
49
50
 
51
+ # experimental
52
+ option(MI_WIN_INIT_USE_RAW_DLLMAIN "Use the raw DLL main entry point for mimalloc initialization; can be more robust but can also lead to link errors with other libraries" OFF)
53
+ option(MI_WIN_INIT_USE_TLS_DLLMAIN "Use legacy TLS entries with DllMain for mimalloc initialization" OFF)
54
+
50
55
  # deprecated options
51
56
  option(MI_WIN_USE_FLS "Use Fiber local storage on Windows to detect thread termination (deprecated)" OFF)
52
57
  option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
@@ -106,7 +111,7 @@ endif()
106
111
  # -----------------------------------------------------------------------------
107
112
 
108
113
  message(STATUS "")
109
- if (NOT CMAKE_BUILD_TYPE)
114
+ if(NOT CMAKE_BUILD_TYPE)
110
115
  if ("${CMAKE_BINARY_DIR}" MATCHES ".*((D|d)ebug|asan|tsan|ubsan|valgrind)$")
111
116
  message(STATUS "No build type selected, default to 'Debug'")
112
117
  set(CMAKE_BUILD_TYPE "Debug")
@@ -116,12 +121,12 @@ if (NOT CMAKE_BUILD_TYPE)
116
121
  endif()
117
122
  endif()
118
123
 
119
- if (CMAKE_GENERATOR MATCHES "^Visual Studio.*$")
124
+ if(CMAKE_GENERATOR MATCHES "^Visual Studio.*$")
120
125
  message(STATUS "Note: when building with Visual Studio the build type is specified when building.")
121
126
  message(STATUS "For example: 'cmake --build . --config=Release")
122
127
  endif()
123
128
 
124
- if("${CMAKE_BINARY_DIR}" MATCHES ".*(S|s)ecure$")
129
+ if(NOT MI_SECURE AND NOT MI_SECURE_FULL AND "${CMAKE_BINARY_DIR}" MATCHES ".*(S|s)ecure$")
125
130
  message(STATUS "Default to secure build")
126
131
  set(MI_SECURE "ON")
127
132
  endif()
@@ -132,7 +137,7 @@ set(MI_OPT_ARCH_FLAGS "")
132
137
  set(MI_ARCH "unknown")
133
138
  if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86|i[3456]86)$" OR CMAKE_GENERATOR_PLATFORM MATCHES "^(x86|Win32)$")
134
139
  set(MI_ARCH "x86")
135
- 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
140
+ 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
136
141
  set(MI_ARCH "x64")
137
142
  elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv[89].?|ARM64)$" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES)
138
143
  set(MI_ARCH "arm64")
@@ -242,8 +247,12 @@ if(WIN32)
242
247
  endif()
243
248
  endif()
244
249
 
245
- if(MI_SECURE)
246
- message(STATUS "Set full secure build (MI_SECURE=ON)")
250
+ if(MI_SECURE_FULL)
251
+ set(MI_SECURE ON)
252
+ message(STATUS "Set full secure build (MI_SECURE_FULL=ON)")
253
+ list(APPEND mi_defines MI_SECURE=5)
254
+ elseif(MI_SECURE)
255
+ message(STATUS "Set secure build (MI_SECURE=ON)")
247
256
  list(APPEND mi_defines MI_SECURE=4)
248
257
  endif()
249
258
 
@@ -298,15 +307,6 @@ if(MI_TRACK_ETW)
298
307
  endif()
299
308
  endif()
300
309
 
301
- if(MI_GUARDED)
302
- message(STATUS "Compile guard pages behind certain object allocations (MI_GUARDED=ON)")
303
- list(APPEND mi_defines MI_GUARDED=1)
304
- if(NOT MI_NO_PADDING)
305
- message(STATUS " Disabling padding due to guard pages (MI_NO_PADDING=ON)")
306
- set(MI_NO_PADDING ON)
307
- endif()
308
- endif()
309
-
310
310
  if(MI_SEE_ASM)
311
311
  message(STATUS "Generate assembly listings (MI_SEE_ASM=ON)")
312
312
  if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR MI_CLANG_CL)
@@ -332,9 +332,11 @@ endif()
332
332
 
333
333
  if(MI_DEBUG_FULL)
334
334
  message(STATUS "Set debug level to full assertion and internal invariant checking (MI_DEBUG_FULL=ON, expensive)")
335
+ set(MI_DEBUG ON)
335
336
  list(APPEND mi_defines MI_DEBUG=3) # full invariant checking (mi_assert, mi_assert_internal, and mi_assert_expensive)
336
337
  elseif(MI_DEBUG_INTERNAL)
337
338
  message(STATUS "Set debug level to internal assertion and invariant checking (MI_DEBUG_INTERNAL=ON)")
339
+ set(MI_DEBUG ON)
338
340
  list(APPEND mi_defines MI_DEBUG=2) # invariant checking (mi_assert and mi_assert_internal)
339
341
  elseif(MI_DEBUG)
340
342
  message(STATUS "Set debug level to assertion checking (MI_DEBUG=ON)")
@@ -342,9 +344,19 @@ elseif(MI_DEBUG)
342
344
  elseif(CMAKE_BUILD_TYPE MATCHES "Debug")
343
345
  message(STATUS "Set debug level to internal assertion and invariant checking (CMAKE_BUILD_TYPE=Debug)")
344
346
  set(MI_DEBUG_INTERNAL ON)
347
+ set(MI_DEBUG ON)
345
348
  list(APPEND mi_defines MI_DEBUG=2) # invariant checking (mi_assert and mi_assert_internal)
346
349
  endif()
347
350
 
351
+ if(MI_DEBUG AND !MI_GUARDED)
352
+ message(STATUS "Enable MI_GUARDED (since MI_DEBUG=ON)")
353
+ set(MI_GUARDED=ON)
354
+ endif()
355
+ if(MI_GUARDED)
356
+ message(STATUS "Compile guard pages behind certain object allocations (MI_GUARDED=ON)")
357
+ list(APPEND mi_defines MI_GUARDED=1)
358
+ endif()
359
+
348
360
  if(MI_NO_PADDING)
349
361
  message(STATUS "Suppress any padding of heap blocks (MI_NO_PADDING=ON)")
350
362
  list(APPEND mi_defines MI_PADDING=0)
@@ -398,7 +410,7 @@ endif()
398
410
  if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
399
411
  if(MI_NO_THP)
400
412
  message(STATUS "Disable transparent huge pages support (MI_NO_THP=ON)")
401
- list(APPEND mi_defines MI_NO_THP=1)
413
+ list(APPEND mi_defines MI_DEFAULT_ALLOW_THP=0)
402
414
  endif()
403
415
  endif()
404
416
 
@@ -407,16 +419,26 @@ if(MI_LIBC_MUSL)
407
419
  list(APPEND mi_defines MI_LIBC_MUSL=1)
408
420
  endif()
409
421
 
410
- if(MI_WIN_USE_FLS)
411
- message(STATUS "Use the Fiber API to detect thread termination (deprecated) (MI_WIN_USE_FLS=ON)")
412
- list(APPEND mi_defines MI_WIN_USE_FLS=1)
413
- endif()
414
-
415
422
  if(MI_WIN_DIRECT_TLS)
416
423
  message(STATUS "Use only direct TLS slots on Windows to avoid extra tests in the malloc fast path -- this only works if the program uses less than 64 TlsAlloc'd slots in total! (MI_WIN_USE_ONLY_DIRECT_TLS=ON)")
417
424
  list(APPEND mi_defines MI_WIN_DIRECT_TLS=1)
418
425
  endif()
419
426
 
427
+ if(MI_WIN_INIT_USE_RAW_DLLMAIN)
428
+ message(STATUS "Use raw Dll main entry on Windows to initialize and finalize mimalloc (MI_WIN_INIT_USE_RAW_DLLMAIN=ON)")
429
+ message(STATUS "Note: this can lead to link errors if other libraries also try to define a raw Dll main entry point")
430
+ list(APPEND mi_defines MI_WIN_INIT_USE_RAW_DLLMAIN=1)
431
+ elseif(MI_WIN_INIT_USE_TLS_DLLMAIN)
432
+ message(STATUS "Use Dll main entry with TLS entries on Windows to initialize and finalize mimalloc (MI_WIN_INIT_USE_TLS_DLLMAIN=ON)")
433
+ list(APPEND mi_defines MI_WIN_INIT_USE_TLS_DLLMAIN=1)
434
+ elseif(MI_WIN_USE_FLS)
435
+ message(STATUS "Deprecated: Use the Fiber API to detect thread termination (deprecated) (MI_WIN_USE_FLS=ON)")
436
+ list(APPEND mi_defines MI_WIN_INIT_USE_FLS=1)
437
+ else()
438
+ # default uses CRT with TLS entries for initialization and finalization
439
+ # list(APPEND mi_defines MI_WIN_INIT_USE_CRT_TLS=1)
440
+ endif()
441
+
420
442
  # Check /proc/cpuinfo for an SV39 MMU and limit the virtual address bits.
421
443
  # (this will skip the aligned hinting in that case. Issue #939, #949)
422
444
  if (EXISTS /proc/cpuinfo)
@@ -493,7 +515,7 @@ if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914) # vs2017+
493
515
  if(MI_ARCH STREQUAL "x64")
494
516
  set(MI_OPT_ARCH_FLAGS "/arch:AVX2")
495
517
  elseif(MI_ARCH STREQUAL "arm64")
496
- set(MI_OPT_ARCH_FLAGS "/arch:armv8.1")
518
+ set(MI_OPT_ARCH_FLAGS "/arch:armv8.1") # fast atomics (LSE)
497
519
  endif()
498
520
  endif()
499
521
  endif()
@@ -645,7 +667,7 @@ if(MI_BUILD_SHARED)
645
667
  # On windows, the import library name for the dll would clash with the static mimalloc.lib library
646
668
  # so we postfix the dll import library with `.dll.lib` (and also the .pdb debug file)
647
669
  set_property(TARGET mimalloc PROPERTY ARCHIVE_OUTPUT_NAME "${mi_libname}.dll" )
648
- install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.lib" DESTINATION ${CMAKE_INSTALL_LIBDIR})
670
+ install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.lib" DESTINATION ${CMAKE_INSTALL_LIBDIR}/mimalloc-${mi_version})
649
671
  set_property(TARGET mimalloc PROPERTY PDB_NAME "${mi_libname}.dll")
650
672
  # don't try to install the pdb since it may not be generated depending on the configuration
651
673
  # install(FILES "$<TARGET_FILE_DIR:mimalloc>/${mi_libname}.dll.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -808,13 +830,10 @@ if (MI_OVERRIDE)
808
830
  if (MI_BUILD_SHARED)
809
831
  target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
810
832
  endif()
811
- if(NOT WIN32)
812
- # It is only possible to override malloc on Windows when building as a DLL.
813
- if (MI_BUILD_STATIC)
814
- target_compile_definitions(mimalloc-static PRIVATE MI_MALLOC_OVERRIDE)
815
- endif()
816
- if (MI_BUILD_OBJECT)
817
- target_compile_definitions(mimalloc-obj PRIVATE MI_MALLOC_OVERRIDE)
818
- endif()
833
+ if (MI_BUILD_STATIC)
834
+ target_compile_definitions(mimalloc-static PRIVATE MI_MALLOC_OVERRIDE)
835
+ endif()
836
+ if (MI_BUILD_OBJECT)
837
+ target_compile_definitions(mimalloc-obj PRIVATE MI_MALLOC_OVERRIDE)
819
838
  endif()
820
839
  endif()
@@ -4,6 +4,7 @@
4
4
  # https://aka.ms/yaml
5
5
 
6
6
  trigger:
7
+ batch: true
7
8
  branches:
8
9
  include:
9
10
  - main
@@ -247,9 +248,9 @@ jobs:
247
248
  Debug:
248
249
  BuildType: debug
249
250
  cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON
250
- Release:
251
- BuildType: release
252
- cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release
251
+ # Release:
252
+ # BuildType: release
253
+ # cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release
253
254
  steps:
254
255
  - task: CMake@1
255
256
  inputs:
@@ -0,0 +1,74 @@
1
+ @echo off
2
+ rem ------------------------------------------------------------------
3
+ rem Build a binary release
4
+ rem ------------------------------------------------------------------
5
+ setlocal
6
+
7
+ mkdir "out/bundle"
8
+
9
+ set MI_TAG=
10
+ for /F "tokens=*" %%x in ('git describe --tag 2^> nul') do (set MI_TAG=%%x)
11
+ set MI_COMMIT=
12
+ for /F "tokens=*" %%x in ('git rev-parse HEAD 2^> nul') do (set MI_COMMIT=%%x)
13
+
14
+ echo.
15
+ echo Tag : %MI_TAG%
16
+ echo Commit: %MI_COMMIT%
17
+
18
+ rem (not needed as it is already done on other platforms)
19
+ rem curl --proto =https --tlsv1.2 -f -L -o "https://github.com/microsoft/mimalloc/archive/%MI_COMMIT%.tar.gz" "out/bundle/mimalloc-%MI_TAG%-source.tar.gz"
20
+
21
+ call:bundle x64 debug Debug "-A x64 -T ClangCl" || goto :err
22
+ call:bundle x64 release Release "-A x64 -T ClangCl -DMI_OPT_ARCH=ON" || goto :err
23
+ call:bundle x64 secure Release "-A x64 -T ClangCl -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
24
+ call:archive x64 || goto:err
25
+
26
+ call:bundle x86 debug Debug "-A Win32 -T ClangCl" || goto :err
27
+ call:bundle x86 release Release "-A Win32 -T ClangCl -DMI_OPT_ARCH=ON" || goto :err
28
+ call:bundle x86 secure Release "-A Win32 -T ClangCl -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
29
+ call:archive x86 || goto:err
30
+
31
+ call:bundle arm64 debug Debug "-A ARM64 -T ClangCl" || goto :err
32
+ call:bundle arm64 release Release "-A ARM64 -T ClangCl -DMI_OPT_ARCH=ON" || goto :err
33
+ call:bundle arm64 secure Release "-A ARM64 -T ClangCl -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
34
+ call:archive arm64 || goto:err
35
+
36
+ call:bundle arm64ec debug Debug "-A Arm64EC" || goto :err
37
+ call:bundle arm64ec release Release "-A Arm64EC -DMI_OPT_ARCH=ON" || goto :err
38
+ call:bundle arm64ec secure Release "-A Arm64EC -DMI_OPT_ARCH=ON -DMI_SECURE=ON" || goto:err
39
+ call:archive arm64ec || goto:err
40
+
41
+ echo.
42
+ echo Done
43
+ exit /b 0
44
+
45
+ :err
46
+ echo Failed with error: %errorlevel%
47
+ exit /b %errorlevel%
48
+
49
+
50
+ :bundle
51
+ rem bundle: 1:arch 2:build-variant 3:build-type 4:cmake options
52
+ echo.
53
+ echo Build: %~1 %~2: %~3
54
+ mkdir "out/bundle/prefix-%~1"
55
+ cmake . -B "out/bundle/%~2-%~1" -DCMAKE_BUILD_TYPE=%~3 %~4 || goto :err
56
+ cmake --build "out/bundle/%~2-%~1" --config %~3 || goto :err
57
+ if "%~1" == "x64" (ctest --test-dir "out/bundle/%~2-%~1" -C %~3 || goto :err)
58
+ if "%~1" == "x86" (ctest --test-dir "out/bundle/%~2-%~1" -C %~3 || goto :err)
59
+ cmake --install "out/bundle/%~2-%~1" --prefix "out/bundle/prefix-%~1" --config %~3 || goto :err
60
+ exit /b %errorlevel%
61
+
62
+
63
+ :archive
64
+ rem archive: 1:arch
65
+ echo.
66
+ echo Archive: %~1
67
+ if "%~1" == "x64" (xcopy /Y /F "bin/minject.exe" "out/bundle/prefix-%~1/bin")
68
+ if "%~1" == "x86" (xcopy /Y /F "bin/minject32.exe" "out/bundle/prefix-%~1/bin")
69
+ if "%~1" == "arm64" (xcopy /Y /F "bin/minject-arm64.exe" "out/bundle/prefix-%~1/bin")
70
+ if "%~1" == "arm64ec" (xcopy /Y /F "bin/minject-arm64.exe" "out/bundle/prefix-%~1/bin")
71
+ cd "out/bundle/prefix-%~1"
72
+ tar -czvf "../mimalloc-%MI_TAG%-windows-%~1.tar.gz" .
73
+ cd ../../..
74
+ exit /b %errorlevel%