stacker 0.1.23

A stack growth library useful when implementing deeply recursive algorithms that may accidentally blow the stack.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
name: Test

on:
  push:
    branches:
      - master
    paths-ignore:
      - "*.mkd"
      - "LICENSE"
  pull_request:
    types: [opened, reopened, synchronize]
  workflow_dispatch:

jobs:
  native-test:
    name: Test ${{ matrix.manifest }} on ${{ matrix.os }} with ${{ matrix.rust_toolchain }} and ${{ matrix.mode }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        rust_toolchain: [nightly, stable, 1.91.0]
        os: [ubuntu-latest, windows-latest, macOS-latest, windows-11-arm]
        mode: ["--release", "-Zminimal-versions", ""]
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
        # Pedantic flags
        cflags: ["-Werror -Wundef", ""]
        exclude:
          - rust_toolchain: stable
            mode: -Zminimal-versions
          - rust_toolchain: 1.91.0
            mode: -Zminimal-versions
          - os: windows-latest
            cflags: "-Werror -Wundef"
          - os: windows-11-arm
            cflags: "-Werror -Wundef"
        include:
          - os: windows-latest
            extra_target: i686-pc-windows-msvc
          - os: windows-11-arm
            rust_toolchain: nightly
            extra_target: arm64ec-pc-windows-msvc
    timeout-minutes: 10
    env:
      CFLAGS: ${{ matrix.cflags }}
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust ${{ matrix.rust_toolchain }}
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust_toolchain }}
          profile: minimal
          default: true
          target: ${{ matrix.extra_target }}
      - name: Test ${{ matrix.manifest}} with ${{ matrix.mode }}
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --manifest-path=${{ matrix.manifest }} ${{ matrix.mode }} -- --nocapture
      - name: Test ${{ matrix.manifest}} examples with ${{ matrix.mode }}
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --manifest-path=${{ matrix.manifest }} ${{ matrix.mode }} --examples -- --nocapture
      - if: ${{ matrix.extra_target }}
        name: Test ${{ matrix.manifest}} with ${{ matrix.mode }} as ${{ matrix.extra_target }}
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --target=${{ matrix.extra_target }} --manifest-path=${{ matrix.manifest }} ${{ matrix.mode }} -- --nocapture
      - if: ${{ matrix.extra_target }}
        name: Test ${{ matrix.manifest}} examples with ${{ matrix.mode }} as ${{ matrix.extra_target }}
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --target=${{ matrix.extra_target }} --manifest-path=${{ matrix.manifest }} ${{ matrix.mode }} --examples -- --nocapture

  clang-cl-test:
    name: Test ${{ matrix.manifest }} on ${{ matrix.rust_target }} with ${{ matrix.clang_cl }}
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
        rust_target:
          - x86_64-pc-windows-msvc
          - i686-pc-windows-msvc
        include:
          - rust_target: x86_64-pc-windows-msvc
            clang_cl: C:/msys64/mingw64/bin/clang-cl.exe
            package: mingw-w64-x86_64-clang
          - rust_target: i686-pc-windows-msvc
            clang_cl: C:/msys64/mingw32/bin/clang-cl.exe
            package: mingw-w64-i686-clang
    steps:
      - uses: actions/checkout@v4
      - uses: msys2/setup-msys2@v2
        with:
          release: false
          install: ${{ matrix.package }}
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          default: true
          target: ${{ matrix.rust_target }}
      - uses: actions-rs/cargo@v1
        with:
          command: test
          args: --target=${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }} -- --nocapture
        env:
          CC: ${{ matrix.clang_cl }}
          CFLAGS: "-Werror -Wundef"

  windows-gnu-test:
    name: Test ${{ matrix.manifest }} on ${{ matrix.rust_target }} with ${{ matrix.rust_toolchain }}
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        rust_toolchain: [nightly, stable]
        rust_target:
          - x86_64-pc-windows-gnu
          - i686-pc-windows-gnu
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
        include:
          - rust_target: x86_64-pc-windows-gnu
            mingw_path: C:/msys64/mingw64/bin
            package: mingw-w64-x86_64-gcc
          - rust_target: i686-pc-windows-gnu
            mingw_path: C:/msys64/mingw32/bin
            package: mingw-w64-i686-gcc
    steps:
      - uses: actions/checkout@v4
      - uses: msys2/setup-msys2@v2
        with:
          release: false
          install: ${{ matrix.package }}
      - run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
      - run: echo "${{ matrix.mingw_path }}" | Out-File -FilePath $env:GITHUB_PATH -Append
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust_toolchain }}
          profile: minimal
          target: ${{ matrix.rust_target }}
          default: true
      - uses: actions-rs/cargo@v1
        with:
          command: test
          args: --target ${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }}
        env:
          CFLAGS: "-Werror -Wundef"

  cross-windows-gnullvm-check:
    name: Check ${{ matrix.manifest }} to ${{ matrix.rust_target }} with stable
    runs-on: ubuntu-22.04
    env:
      LLVM_MINGW_VERSION: "20250417"
    strategy:
      fail-fast: false
      matrix:
        rust_target:
          - aarch64-pc-windows-gnullvm
          - i686-pc-windows-gnullvm
          - x86_64-pc-windows-gnullvm
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: llvm-mingw-version
          key: ${{ env.LLVM_MINGW_VERSION }}
      - name: Install llvm-mingw
        if: steps.cache.outputs.cache-hit != 'true'
        run: curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/${{ env.LLVM_MINGW_VERSION }}/llvm-mingw-${{ env.LLVM_MINGW_VERSION }}-ucrt-ubuntu-22.04-x86_64.tar.xz | tar xJf -
      - name: Add llvm-mingw to PATH
        run: echo "${{ github.workspace }}/llvm-mingw-${{ env.LLVM_MINGW_VERSION }}-ucrt-ubuntu-22.04-x86_64/bin" >> $GITHUB_PATH
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          target: ${{ matrix.rust_target }}
      - name: Check
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: --target ${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }}

  cross-linux-test:
    name: Test ${{ matrix.manifest }} on ${{ matrix.rust_target }} with nightly ${{ matrix.mode }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust_target:
          - aarch64-linux-android
          - arm-linux-androideabi
          - armv7-linux-androideabi
          - x86_64-linux-android
          - aarch64-unknown-linux-gnu
          - arm-unknown-linux-gnueabi
          - armv7-unknown-linux-gnueabihf
          - loongarch64-unknown-linux-gnu
          - i686-unknown-linux-gnu
          - i686-unknown-linux-musl
          # No libstd available :(
          # - mips-unknown-linux-gnu
          # - mips64-unknown-linux-gnuabi64
          # - mips64el-unknown-linux-gnuabi64
          # - mipsel-unknown-linux-gnu
          - powerpc-unknown-linux-gnu
          # https://github.com/rust-embedded/cross/pull/440
          # - powerpc64-unknown-linux-gnu
          - x86_64-unknown-linux-musl
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
        mode: ["--release", "-Zminimal-versions", ""]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          target: ${{ matrix.rust_target }}
          default: true
      - name: Install cross
        run: |
          cargo install cross --git https://github.com/cross-rs/cross
      - name: Test
        run: |
          cross test --target ${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }}  ${{ matrix.mode }} -- --test-threads=1 --nocapture

  native-build:
    name: Build ${{ matrix.manifest }} to ${{ matrix.rust_target }} on nightly
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust_target:
          # BSDs: could be tested with full system emulation
          - i686-unknown-freebsd
          - x86_64-unknown-freebsd
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          target: ${{ matrix.rust_target }}
          default: true
      - name: Build ${{ matrix.rust_target }}
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --target ${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }}

  cross-build:
    name: Cross-compile ${{ matrix.manifest }} to ${{ matrix.rust_target }} with cargo-cross
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust_target:
          # https://github.com/rust-embedded/cross/issues/333
          - powerpc64le-unknown-linux-gnu
          # FIXME: Testing hangs, should be verified once-in-a-while manually.
          # could be made work by using full system emulation
          # https://github.com/rust-embedded/cross/issues/242
          #
          # Currently tested manually with full-system emulation.
          - s390x-unknown-linux-gnu
          # FIXME: tests could be made work by using full system emulation, maybe?
          #
          # Currently tested manually on real hardware.
          # FIXME: https://github.com/rust-embedded/cross/pull/440
          # - sparc64-unknown-linux-gnu
          # BSDs: could be tested with full system emulation
          - x86_64-unknown-netbsd
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust nightly
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          target: ${{ matrix.rust_target }}
          default: true
      - name: Build ${{ matrix.rust_target }}
        uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --target ${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }}

  cross-ios-build:
    name: Cross-compile ${{ matrix.manifest }} to ${{ matrix.rust_target }} on ${{ matrix.rust_toolchain }}
    runs-on: macos-latest
    strategy:
      fail-fast: false
      matrix:
        rust_toolchain: [nightly, stable]
        rust_target:
          - aarch64-apple-ios
          - x86_64-apple-ios
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust_toolchain }}
          profile: minimal
          target: ${{ matrix.rust_target }}
          default: true
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --target=${{ matrix.rust_target }} --manifest-path=${{ matrix.manifest }}

  cross-windows-build:
    name: Cross-compile ${{ matrix.manifest }} for ${{ matrix.rust_target }} from x86_64-unknown-linux-gnu
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: true
      matrix:
        rust_target:
          - x86_64-pc-windows-msvc
          - i686-pc-windows-msvc
        manifest: ["psm/Cargo.toml", "Cargo.toml"]
        xwin_version: ["0.1.6"]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          target: ${{ matrix.rust_target }}
      - name: Add toolchain shims
        run: |
          set -eux
          sudo ln -s clang-14 /usr/bin/clang-cl
          sudo ln -s llvm-ar-14 /usr/bin/llvm-lib
          sudo ln -s lld-link-14 /usr/bin/lld-link
      - name: Install Windows SDK
        run: |
          set -eux
          xwin_version=${{ matrix.xwin_version }}
          xwin_prefix="xwin-$xwin_version-x86_64-unknown-linux-musl"

          # Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`.
          curl --fail -L https://github.com/Jake-Shadle/xwin/releases/download/$xwin_version/$xwin_prefix.tar.gz | tar -xzv -C /home/runner/.cargo/bin --strip-components=1 $xwin_prefix/xwin

          # Splat the CRT and SDK files to /tmp/xwin/crt and /tmp/xwin/sdk respectively
          xwin --accept-license 1 splat --output /tmp/xwin
      - name: Test
        env:
          CC: "clang-cl"
          CXX: "clang-cl"
          AR: "llvm-lib"
          CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: "lld-link"
          CARGO_TARGET_I686_PC_WINDOWS_MSVC_LINKER: "lld-link"
          # Note that we only disable unused-command-line-argument here since clang-cl
          # doesn't implement all of the options supported by cl, but the ones it doesn't
          # are _generally_ not interesting.
          CFLAGS: "-Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/tmp/xwin/crt/include /imsvc/tmp/xwin/sdk/include/ucrt /imsvc/tmp/xwin/sdk/include/um /imsvc/tmp/xwin/sdk/include/shared"
          # Inform the linker where to search for libraries
          RUSTFLAGS: "-Lnative=/tmp/xwin/crt/lib/x86_64 -Lnative=/tmp/xwin/sdk/lib/um/x86_64 -Lnative=/tmp/xwin/sdk/lib/ucrt/x86_64"
        run: |
          set -eux
          cargo build --target ${{ matrix.rust_target }} --manifest-path ${{ matrix.manifest }}

  wasm-test:
    name: Test stacker on WASM
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust nightly
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          default: true
          target: wasm32-wasip1
      - run: |
          curl -Lf https://github.com/bytecodealliance/wasmtime/releases/download/v24.0.0/wasmtime-v24.0.0-x86_64-linux.tar.xz | tar xJf - -C ${{ runner.tool_cache }}
          echo "${{ runner.tool_cache }}/wasmtime-v24.0.0-x86_64-linux" >> $GITHUB_PATH
          echo "CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime run --" >> $GITHUB_ENV
      - run: cargo test --target wasm32-wasip1 --all -- --nocapture

  miri-test:
    name: Test stacker with Miri on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust nightly with Miri
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          components: miri
          default: true
      - name: Setup Miri
        run: cargo miri setup
      - name: Test with Miri
        run: cargo miri test -- --nocapture