Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
eabc8c6
bump version and move installer to 0.15.1
ityonemo Aug 22, 2025
fd0cd06
brings sema json analysis up to modern zig
ityonemo Aug 23, 2025
3d627dc
full export of erlnif functions
ityonemo Aug 24, 2025
350bbdb
changes callconv symbol
ityonemo Aug 24, 2025
af2c3ea
most tests passing, except for commented-out tests
ityonemo Aug 25, 2025
e8d5000
undisable disabled tests
ityonemo Aug 25, 2025
42e0a54
un-skip key tests
ityonemo Aug 25, 2025
ded6718
transition to segregating code via compilation model and using Sema p…
ityonemo Aug 25, 2025
012517c
switches over to fully templated semantic analysis
ityonemo Aug 26, 2025
c9f2c24
fixes templating error in sema_c
ityonemo Aug 26, 2025
39cb4bf
re-enable advanced allocation strategies
ityonemo Aug 26, 2025
4548251
re-enable disabled guides
ityonemo Aug 26, 2025
878fd7e
restores allocators and c guides
ityonemo Aug 26, 2025
8febba3
routes sema through the new build.zig template
ityonemo Aug 28, 2025
b94858c
purge old build.zig and semantic analysis systems
ityonemo Aug 28, 2025
32bc6ac
removes compiler errors
ityonemo Aug 28, 2025
d4b7ca6
refactor to use 'module' as the keyword for extra modules
ityonemo Aug 28, 2025
200964c
fixes module specification errors
ityonemo Aug 28, 2025
702b23e
rename from modules to extra_modules
ityonemo Aug 28, 2025
057d3cb
activates project dependencies
ityonemo Aug 30, 2025
f2eccb6
completes build zig override and options normalization
ityonemo Sep 1, 2025
6fd0a5e
stashes semantic analysis pass in its own linksection in the shared o…
ityonemo Sep 1, 2025
3f819b2
adds in the test for precompilation
ityonemo Sep 4, 2025
6bf6b12
splits out sema building from sema execution
ityonemo Sep 4, 2025
027fbab
Merge branch 'v0.15.1' into nif-precompilation
ityonemo Sep 4, 2025
dfd8252
actual test conditions on precompiled_test
ityonemo Sep 4, 2025
615ba03
obtains precompiled data from stashed semantic analysis json
ityonemo Sep 11, 2025
4b3d09d
adds basic precompiled module test
ityonemo Sep 12, 2025
69c8def
enable web retreival of precompiled assets
ityonemo Sep 13, 2025
a0e6519
adds guards on FORCE_RECOMPILE and FORCE_RELOAD
ityonemo Sep 13, 2025
91539aa
adds web-based precompilation
ityonemo Sep 20, 2025
2f6e770
precompiled documentation in the guides
ityonemo Sep 20, 2025
3807165
updates optimize and error_tracing options
ityonemo Sep 21, 2025
71b1d28
adds test on recursive resources
ityonemo Sep 24, 2025
b6e6be0
adds get_list_cell
ityonemo Sep 25, 2025
0e31c5d
documentation updates
ityonemo Sep 25, 2025
edcd09c
fix the zig version command for linux
ityonemo Sep 25, 2025
315c440
workflow updates macos/windows
ityonemo Sep 25, 2025
6e115e5
compat for versions without :json
ityonemo Sep 25, 2025
9f27a85
make sure sema json is a single binary
ityonemo Sep 25, 2025
c91ee46
remove mcp tools
ityonemo Sep 27, 2025
4534b7e
compat for Elixir version < 1.16
ityonemo Sep 27, 2025
e97136b
force trace for debug
ityonemo Sep 27, 2025
000af4d
disable build_zig_override_test
ityonemo Sep 27, 2025
ccdd4c7
format and temporarily remove another test
ityonemo Sep 28, 2025
a356390
vibecoded macos sema_json
ityonemo Sep 28, 2025
fa8dbbd
resolves memory-mapping segfault in linux
ityonemo Sep 30, 2025
d33de02
don't forget to clear local precompiled
ityonemo Oct 1, 2025
e74b36b
fixes embedded sema test strategy
ityonemo Oct 1, 2025
da57924
remove trace and bump freebsd llvm to 20
ityonemo Oct 1, 2025
9317ef3
normalize use of json across elixir versions
ityonemo Oct 1, 2025
5ae5717
disables testing multiplatform if the erts version is too low
ityonemo Oct 3, 2025
3c8e8c9
moves error return test
ityonemo Oct 4, 2025
891f516
MacOS errors resolved
ityonemo Oct 4, 2025
84f09a8
common objcopy for windows, freebsd
ityonemo Oct 4, 2025
de683f5
add windows include dir
ityonemo Oct 5, 2025
825e78d
make sure we're using dll for windows
ityonemo Oct 5, 2025
e347888
switches llvm to 20, freebsd
ityonemo Oct 5, 2025
cd58d50
updates with win64 cross-compilation capability
ityonemo Oct 10, 2025
451b983
disable build_files_test and reenable compile_error
ityonemo Oct 10, 2025
5e3999f
fixes freebsd to use stable elixir
ityonemo Oct 10, 2025
4ce875a
freebsd objcopy invocation
ityonemo Oct 11, 2025
8655656
freebsd objcopy invocation
ityonemo Oct 11, 2025
80cc022
error message normalization
ityonemo Oct 12, 2025
09b0f04
path normalization for windows
ityonemo Oct 12, 2025
30fc1dd
Merge branch 'v0.15.1' of https://github.com/E-xyza/zigler into v0.15.1
ityonemo Oct 12, 2025
034ebd9
repeat json
ityonemo Oct 12, 2025
401bffa
rror message normalization
ityonemo Oct 12, 2025
7f9af8c
Merge branch 'v0.15.1' of https://github.com/e-xyza/zigler into v0.15.1
ityonemo Oct 12, 2025
cdff7c5
fix precompiled_sema command
ityonemo Oct 12, 2025
970e817
remove skip_windows
ityonemo Oct 13, 2025
c089ca1
fix get_list_cell
ityonemo Oct 13, 2025
d949c03
disable error return traces in windows (for threaded)
ityonemo Oct 26, 2025
43e7835
fixes? windows dependency path issue
ityonemo Oct 26, 2025
421056f
windows: fixes staging dir error
ityonemo Oct 26, 2025
6bc6367
fixes erlang error test
ityonemo Oct 26, 2025
93adb17
prevent stack tracing bug in GPA for windows
ityonemo Oct 26, 2025
5828bf9
validate directory existence first
ityonemo Oct 27, 2025
168832b
repairs staging dir test
ityonemo Oct 27, 2025
3ebcf55
renames extramodule build module
ityonemo Oct 27, 2025
9fd8545
bump installer to 0.15.2
ityonemo Oct 27, 2025
c18c8e9
select 0.15.2 for zig_get
ityonemo Oct 27, 2025
b92a03d
general dependency lock update
ityonemo Oct 27, 2025
406a497
0.19.1 update and add precompiled assets
ityonemo Oct 27, 2025
13d2ebc
fix precompiled tests with new uploads for 0.15.2
ityonemo Oct 27, 2025
86a117d
fixes macos tmp drive issue by forcing symlink resolution
ityonemo Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Setup Erlang
with:
otp-version: '27.3'
elixir-version: '1.18.3'
elixir-version: '1.17.3'

- uses: actions/cache@v3
id: deps-cache
Expand All @@ -33,7 +33,7 @@ jobs:
- name: get zig
run: |
if [ ! -d zig ]; then
git clone -b 0.14.1 https://github.com/ziglang/zig.git
git clone -b 0.15.1 https://github.com/ziglang/zig.git
fi

- name: Test in FreeBSD
Expand All @@ -43,9 +43,9 @@ jobs:
mem: 8192
usesh: true
prepare: |
pkg install -y erlang-runtime27
pkg install -y elixir-devel
pkg install -y llvm19
pkg install -y erlang-runtime28
pkg install -y elixir
pkg install -y llvm20
pkg install -y ca_root_nss

pkg install -y cmake zstd libxml2 lzma ninja
Expand All @@ -57,7 +57,7 @@ jobs:
mkdir -p build

cd build
cmake .. -G Ninja -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="/usr/local/llvm19;/usr/local;/usr/local/lib" -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/lib" -DCMAKE_BUILD_TYPE=ReleaseSafe
cmake .. -G Ninja -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="/usr/local/llvm20;/usr/local;/usr/local/lib" -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/lib" -DCMAKE_BUILD_TYPE=ReleaseSafe

ninja -C .

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
strategy:
matrix:
pair:
- otp-version: '27.3'
elixir-version: '1.18.3'
- otp-version: '28.1'
elixir-version: '1.19.1'
- otp-version: '28.1'
elixir-version: '1.18.4'
- otp-version: '27.3'
elixir-version: '1.17.3'
- otp-version: '26.2'
elixir-version: '1.16.3'
- otp-version: '25.3'
elixir-version: '1.15.8'
- otp-version: '24.3'
elixir-version: '1.14.5'
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:

- name: Get Zig version
id: zig-version
run: echo "version=$(mix eval 'IO.puts(Zig.version())')" >> $GITHUB_OUTPUT
run: echo "version=$(mix run --no-compile --no-start -e 'IO.puts(Zig.version())')" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: zig-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Get Zig version
id: zig-version
run: mix eval "IO.puts(Zig.version())"
run: mix run --no-compile --no-start -e "IO.puts(Zig.version())"

- uses: actions/cache@v3
id: zig-cache
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on: push
jobs:
test:
runs-on: windows-latest
env:
ImageOS: win22

steps:
- name: Checkout repository
Expand All @@ -13,8 +15,8 @@ jobs:
- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.18.3' # adjust as needed
otp-version: '27.3' # adjust as needed
elixir-version: '1.18.4' # adjust as needed
otp-version: '28.1' # adjust as needed

- uses: actions/cache@v3
id: deps-cache
Expand All @@ -38,7 +40,7 @@ jobs:
id: zig-version
shell: bash
run: |
VERSION=$(mix eval "IO.puts(Zig.version())" | tail -n 1)
VERSION=$(mix run --no-compile --no-start -e "IO.puts(Zig.version())" | tail -n 1)
echo "zig_version=$VERSION" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
Expand All @@ -53,4 +55,4 @@ jobs:
- name: Run Tests
env:
RUNNING_CI: "TRUE"
run: mix test --exclude no_ci --exclude on_upgrade --exclude skip_windows
run: mix test --exclude no_ci --exclude on_upgrade --trace
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,12 @@ zigler-*.tar
# other compiled files
*.a

# local development files
.envrc

/test/code
/test/corner_cases/staging
/test/corner_cases/staging

# precompilation test module
/precompiled/bin
/precompiled/lib
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ by adding `zigler` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:zigler, "~> 0.14.1", runtime: false}
{:zigler, "~> 0.15.1", runtime: false}
]
end
```
Expand All @@ -36,7 +36,7 @@ end

TBD.

`~/.cache/zigler/zig-linux-<arch>-0.14.1`
`~/.cache/zigler/zig-linux-<arch>-0.15.1`

### Main Installation

Expand Down
24 changes: 21 additions & 3 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,26 @@ Thanks to Dave Cottlehuber @dch for testing.

- no changes.

## Upcoming
- `precompiled` mode that will let you obtain packages with precompiled assets.
## 0.15.2

## Possible
- Breaking changes:
- rename "packages" option to "extra_modules"
- unification of path scheme ("./" is project-rooted)
- renamed `release_mode` to `optimize`. Also note the new optimize policy defaults
to `ReleaseSafe` in non-dev, non-test modes and defaults to `Debug` in test and dev.
- Policy changes:
- error return traces by default in ReleaseSafe builds
- Temporary Regressions:
- Error return traces are disabled in MacOS (due to https://github.com/ziglang/zig/issues/25433)
- on_upgrade tests are failing in elixir 1.19.x; may or may not reflect a real problem.
- Outstanding issues:
- c_ulonglong doesn't work on windows; c_long doesn't work on other platforms.
- Features:
- add "dependency" option for zig dependencies
- `precompiled` option that will let you use precompiled library assets. NOTE: this feature is highly
experimental and functions might need to be compiled for different erts versions. This will likely
be changed in the future.
- adds `beam.get_list_cell`

## Possible Future Changes
- `struct` which lets you declare a struct inside your zig code as the module's struct
12 changes: 11 additions & 1 deletion guides/01-nifs.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ For more on marshalling collection datatypes, see [`collections`](collections.ht

You may also manually marshal types into and out of the beam by using the
[`beam.term`](beam.html#term) datatype. To do so, you must first import the [`beam`](beam.html)
package. The `beam.term` type is an opaque, wrapped datatype that ensures safe manipulation of terms
module. The `beam.term` type is an opaque, wrapped datatype that ensures safe manipulation of terms
as a token in your zig code.

```elixir
Expand Down Expand Up @@ -216,6 +216,16 @@ test "erroring" do
end
```

> ### Error Return Trace Availability {: .info}
>
> errorReturnTrace is enabled by default in Debug and ReleaseSafe builds, and disabled in ReleaseFast
> and ReleaseSmall builds. This differs from the zig default.
>
> Note that the erlang compiler has a --no-debug-info parameter that might be set; if this flag is
> set, then errorReturnTrace will be disabled in ReleaseSafe builds.
>
> To override this policy, set the `:error_tracing` option.

### A few notes on the above code.

- to marshal a value out of a `beam.term` and into a zig static type, use [`beam.get`](beam.html#get).
Expand Down
13 changes: 7 additions & 6 deletions guides/03-allocators.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ higher alignment than the maximum alignment for builtin types.

```elixir
~Z"""
const std = @import("std");

pub fn allocate_large_aligned(count: usize) !usize {
const page = try beam.allocator.allocWithOptions(u8, count, 4096, null);
const alignment = comptime std.mem.Alignment.fromByteUnits(4096);
const page = try beam.allocator.alignedAlloc(u8, alignment, count);
defer beam.allocator.free(page);

return @intFromPtr(page.ptr);
Expand Down Expand Up @@ -151,7 +154,7 @@ pub fn noleak() !bool {
}
"""

@tag [erroring: true, skip_windows: true]
@tag :erroring
test "leak checks with debug allocator" do
require Logger
Logger.warning("====== the following leak message is expected: =========== START")
Expand All @@ -166,14 +169,12 @@ end
## Building composable allocators backed by zig's beam allocator

Because zigler's beam allocators conform to zig's allocator interface, you may use use any
composable allocator in the standard library or any composable allocator from an imported zig
package, passing any one of the beam allocators into place.
composable allocator in the standard library or any composable allocator from an imported module,
passing any one of the beam allocators into place.

```elixir
~Z"""
pub fn with_arena() !beam.term {
const std = @import("std");

var arena = std.heap.ArenaAllocator.init(beam.allocator);
defer arena.deinit();

Expand Down
4 changes: 2 additions & 2 deletions guides/04-nif_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ defmodule LeakCheckTest do
}
"""

@tag [erroring: true, skip_windows: true]
@tag :erroring
test "leak check" do
require Logger
Logger.warning("====== the following leak message is expected: =========== START")
Expand Down Expand Up @@ -177,7 +177,7 @@ defmodule LeakCheckAllTest do
}
"""

@tag [erroring: true, skip_windows: true]
@tag :erroring
test "leak check" do
require Logger
Logger.warning("====== the following leak message is expected: =========== START")
Expand Down
6 changes: 3 additions & 3 deletions guides/06-c_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ This example shows you how to link in a system library (which can be `.a`, `.so`
`.dll`). Zig will resolve the extension based on the operating system native rules. To use the
functions in the library, there must also be an associated `.h` file with `extern` functions.

If you wish to package a `.so` file with the project, you have two options:
If you wish to distribute a `.so` file with the project, you have two options:

1. package the file in the `priv` directory and use `{:priv, "path/to/lib.so"}`. Note that in this
1. distribute the file in the `priv` directory and use `{:priv, "path/to/lib.so"}`. Note that in this
case, you must provide `lib` prefix and `.so` or `.dylib` or `.dll` extensions, if applicable.
1. package the file using an absolute or relative path (relative the code file location). use
1. distribute the file using an absolute or relative path (relative the code file location). use
`"path/to/lib.so"`. You must provide `lib` and `.so` or `.dylib` or `.dll` extension.

In this example we'll use the `cblas_dasum` function, which takes a length, an pointer to
Expand Down
61 changes: 46 additions & 15 deletions guides/08-module_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ defmodule Attribute do
end
```

## adding packages
## adding modules

It's possible to add zig files as packages using the `packages` keyword option. The name of the
package is the key, and the value is a tuple of the path to the zig file that acts as the package
and a list of dependencies for the package.
It's possible to add zig files as modules using the `extra_modules` keyword option. The name of the
module is the key, and the value is a tuple of the path to the zig file that acts as the module
and a list of transitive module dependencies.

### Example extra.zig

```zig
````zig
pub const value = 47;
```

Expand All @@ -86,7 +86,7 @@ defmodule PackageFile do
use ExUnit.Case, async: true
use Zig,
otp_app: :zigler,
packages: [extra: {"test/_support/package/extra.zig", [:beam]}]
extra_modules: [extra: {"./test/_support/module/extra.zig", [:beam]}]

~Z"""
const extra = @import("extra");
Expand All @@ -96,7 +96,7 @@ defmodule PackageFile do
}
"""

test "package file" do
test "module file" do
assert 47 = extra_value()
end
end
Expand All @@ -105,18 +105,16 @@ end
## Release Mode

Zig has several release modes, and you can specify which release mode to build your program under
using the `release_mode` option. Importantly, it is possible to set a release mode that depends on
mix environment.
using the `optimize` option. This option defaults to `:debug` if you are in `:dev` or `:test`
and `:safe` otherwise (or if the `Mix` module is not available). You may also specify `:env` which
reades the `ZIGLER_RELEASE_MODE` environment variable, or `{:env, default}` which lets you specify
a different default mode if `ZIGLER_RELEASE_MODE` is not set.

```elixir
defmodule ReleaseMode do
use ExUnit.Case, async: true
mode = case MyApp.env() do
:prod -> :safe
_ -> :debug
end

use Zig, otp_app: :zigler, release_mode: mode
use Zig, otp_app: :zigler, optimize: :fast

~Z"""
const beam = @import("beam");
Expand All @@ -126,7 +124,40 @@ defmodule ReleaseMode do
"""

test "release mode" do
assert :Debug == get_mode()
assert :ReleaseFast == get_mode()
end
end
```

## Error Traces

By default, zigler will provide error traces in Debug and ReleaseSafe modes. You may
override this in ReleaseSafe by supplying the `error_tracing` option

```elixir
defmodule ErrorTraces do
use ExUnit.Case, async: true

use Zig, otp_app: :zigler, error_tracing: false, optimize: :safe

~Z"""
pub fn add_one(x: u32) !u32 {
if (x == 42) return error.BadNumber;
return x + 1;
}
"""

test "error traces can be overridden" do
assert 48 == add_one(47)

stacktrace = try do
add_one(42)
rescue
_ ->
__STACKTRACE__
end

assert [{__MODULE__, :add_one, 1, _} | _] = stacktrace
end
end

Expand Down
Loading
Loading