1
0
Fork 0
forked from fun/fun

Made MAX_FRAMES, MAX_FRAME_LOCALS, MAX_GLOBALS, OUTPUT_SIZE and STACK_SIZE configurable during build configuration using cmake defines (-D). No code changes. (0.40.5)

This commit is contained in:
Johannes Findeisen 2026-04-10 22:04:27 +02:00
commit bebe6dfda0
4 changed files with 45 additions and 0 deletions

View file

@ -24,6 +24,17 @@ Fun exposes several options you can toggle at configure time:
- `FUN_WITH_RUST` (ON/OFF) - Build and link Rust staticlib from `src/rust/`
- `FUN_WITH_OPENSSL` (ON/OFF) - Enable OpenSSL-backed helpers (MD5/SHA-256/SHA-512/RIPEMD-160)
### VM configuration constants
You can override internal VM limits at compile time by passing `-D<VAR>=<VALUE>` to CMake:
- `MAX_FRAMES` (default: 128) - Maximum depth of the call stack (frames)
- `MAX_FRAME_LOCALS` (default: 64) - Maximum number of local variables per frame
- `MAX_GLOBALS` (default: 128) - Maximum number of global variables
- `OUTPUT_SIZE` (default: 1024) - Size of the VM output buffer (number of values)
- `STACK_SIZE` (default: 1024) - Size of the VM evaluation stack (number of `Value` slots)
These are defined as `CACHE` variables, so they will persist in your `CMakeCache.txt`.
When configuring, the build prints a summary like:
```
@ -59,6 +70,12 @@ cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \
cmake --build build_release --target build
```
### Customizing VM limits
```
cmake -S . -B build_custom -DSTACK_SIZE=4096 -DMAX_GLOBALS=512
cmake --build build_custom --target fun
```
If `FUN_WITH_RUST` is enabled, ensure `cargo` is available in PATH; the build will invoke it and link the produced static library.
If `FUN_WITH_OPENSSL` is enabled, CMake must detect your system OpenSSL (libcrypto).