Skip to content

V0.14.0 #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c29e61f
Update actions
ityonemo Mar 10, 2025
c95951f
adds environment variable for blas testing
ityonemo Mar 10, 2025
803cbda
and switch to 0.14
ityonemo Mar 13, 2025
3bfd50b
switches type reflection to new lower-case names
ityonemo Mar 13, 2025
f6148c3
with Fn -> @"fn"
ityonemo Mar 13, 2025
afc9a6c
rebuilds allocator interfaces
ityonemo Mar 14, 2025
acc6ccc
most 0.14.0 language changes now implemented
ityonemo Mar 16, 2025
d1eb103
Merge branch 'main' into v0.14.0
ityonemo Mar 16, 2025
aee7b99
fixes compiler error message
ityonemo Mar 17, 2025
2d61d8d
fix sentinel-terminated pointer get
ityonemo Mar 17, 2025
77c2f61
fixes cpointer spec to be binary | nil
ityonemo Mar 17, 2025
fa55aa6
local and private C abi library tests and guidance
ityonemo Mar 17, 2025
8338ced
implements debug allocator test and format
ityonemo Mar 20, 2025
5a1781b
adds windows ci script (#511)
ityonemo Apr 2, 2025
de16088
updates zig dependency obtaining instructions
ityonemo Apr 11, 2025
aa47557
unblocks openbsd experimentation
ityonemo Apr 11, 2025
e651bc7
adds freebsd github action (#510)
ityonemo Apr 14, 2025
3274b2a
Options parsing (#522)
ityonemo May 11, 2025
7d4369e
removes the typing error (#523)
ityonemo May 12, 2025
f7ae3b8
Normalize dot paths (#524)
ityonemo May 12, 2025
fa2e654
swaps out the call signature for term_type (#527)
ityonemo May 12, 2025
c3101bf
switches over to dynamic detection of :json module (#528)
ityonemo May 13, 2025
295d9eb
update version info
ityonemo May 13, 2025
91dd035
Fallback functions (#530)
ityonemo May 13, 2025
c7bea3f
eliminate jason dependency
ityonemo May 14, 2025
3c580d6
Merge branch 'v0.14.0' of https://github.com/e-xyza/zigler into v0.14.0
ityonemo May 14, 2025
c010e61
fix lockfile
ityonemo May 14, 2025
a2066c5
make sure jason is available at runtime in test environment
ityonemo May 14, 2025
69edab4
adds support for sentinel specification for [*c] parameters (#536)
ityonemo May 19, 2025
6b44cec
adds documentation on release modes
ityonemo May 19, 2025
00b02ad
Merge branch 'v0.14.0' of https://github.com/e-xyza/zigler into v0.14.0
ityonemo May 19, 2025
b2cf3f9
adds test on c compilation errors
ityonemo May 19, 2025
a168642
changes how we do 'struct' assignments
ityonemo May 19, 2025
f529e2e
adds warning on wide datatype slices
ityonemo May 19, 2025
8251b86
adds tests on raw function safety
ityonemo May 19, 2025
55e0d98
adds raw function tests
ityonemo May 19, 2025
f960f33
fixes basic error and adds transitive compiler errors
ityonemo May 20, 2025
74427a8
adds test against c_char allocation (#541)
ityonemo May 22, 2025
c84e9c7
Fix erroring and transitive erroring (#538)
ityonemo May 22, 2025
a9e492d
Merge branch 'v0.14.0' of https://github.com/e-xyza/zigler into v0.14.0
ityonemo May 22, 2025
9252afc
adds test on resources bearing unusable types
ityonemo May 22, 2025
ff9ea8e
adds struct_resource
ityonemo May 22, 2025
4b58cd6
docup
ityonemo May 22, 2025
3e6dccc
adds beam.send warning
ityonemo May 22, 2025
e1a93cc
don't error if build dir exists
ityonemo May 22, 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: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export ZIGLER_TEST_BLAS=true
72 changes: 72 additions & 0 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Elixir CI - FreeBSD

on: push

jobs:
freebsd:
runs-on: ubuntu-latest
name: FreeBSD / Elixir
steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
name: Setup Erlang
with:
otp-version: '27.3'
elixir-version: '1.18.3'

- uses: actions/cache@v3
id: deps-cache
with:
path: deps
key: mix-${{ hashFiles('/mix.lock') }}

- name: get deps
run: mix deps.get

- uses: actions/cache@v3
id: zig-cache
with:
path: zig
key: zig-freebsd

- name: get zig
run: |
if [ ! -d zig ]; then
git clone -b 0.14.0 https://github.com/ziglang/zig.git
fi

- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
mem: 8192
usesh: true
prepare: |
pkg install -y erlang-runtime27
pkg install -y elixir-devel
pkg install -y llvm19
pkg install -y ca_root_nss

pkg install -y cmake zstd libxml2 lzma ninja

ldconfig /usr/local/lib

run: |
cd zig
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

ninja -C .

export ZIG_EXECUTABLE_PATH="$(pwd)/stage3/bin/zig"
export PATH="/usr/local/lib/erlang27/bin:$PATH"
export SSL_CACERTFILE=/usr/local/etc/ssl/cert.pem

cd ../..

mix local.hex --force

mix test --exclude no_ci --exclude skip_freebsd
28 changes: 17 additions & 11 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,45 @@ on: push

jobs:
ubuntu:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
name: Linux OTP ${{matrix.pair.otp-version}} / Elixir ${{matrix.pair.elixir-version}}
strategy:
matrix:
pair:
- otp-version: '27.0'
elixir-version: '1.17.2'
- otp-version: '27.3'
elixir-version: '1.18.3'
- 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.2'
elixir-version: '1.15.8'
- otp-version: '24.3'
elixir-version: '1.14.5'
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.pair.otp-version}}
elixir-version: ${{matrix.pair.elixir-version}}

- uses: actions/cache@v1
- uses: actions/cache@v3
id: deps-cache
with:
path: deps
key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
key: ${{ runner.os }}-mix-${{ matrix.pair.otp-version }}-${{ matrix.pair.elixir-version }}-${{ hashFiles('/mix.lock') }}-${{ hashfiles('installer/**/*') }}

- name: Install ZIGLER_TEST_BLAS
run: sudo apt install -y libopenblas-dev

- name: Install dependencies
run: mix deps.get

- uses: actions/cache@v1
- uses: actions/cache@v3
id: build-cache
with:
path: _build
key: ${{ runner.os }}-build-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
key: ${{ runner.os }}-build-${{ matrix.pair.otp-version }}-${{ matrix.elixir-version }}-${{ hashFiles('/mix.lock') }}

- name: Compile base
run: mix compile
Expand All @@ -46,7 +51,7 @@ jobs:
id: zig-version
run: mix eval "IO.puts(Zig.version())"

- uses: actions/cache@v1
- uses: actions/cache@v3
id: zig-cache
with:
path: zig
Expand All @@ -57,5 +62,6 @@ jobs:

- name: Run Tests
env:
RUNNING_CI: "true"
RUNNING_CI: "TRUE"
ZIGLER_TEST_BLAS: "TRUE"
run: mix test --exclude no_ci
20 changes: 13 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: macos-latest
name: MacOS-latest-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: update-brew
run: brew update
Expand All @@ -23,33 +23,39 @@ jobs:
id: elixir-version
run: elixir --version | tail -n 1 | awk '{ print $2 }'

- uses: actions/cache@v1
- uses: actions/cache@v3
id: deps-cache
with:
path: deps
key: ${{ runner.os }}-mix-${{ steps.elixir-version.outputs.stdout }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
key: ${{ runner.os }}-mix-${{ steps.elixir-version.outputs.stdout }}-${{ hashFiles('/mix.lock') }}

- name: Install dependencies
run: mix deps.get

- uses: actions/cache@v1
- uses: actions/cache@v3
id: build-cache
with:
path: _build
key: ${{ runner.os }}-build-${{ steps.elixir-version.outputs.stdout }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
key: ${{ runner.os }}-build-${{ steps.elixir-version.outputs.stdout }}-${{ hashFiles('/mix.lock') }}

- name: Compile base
run: mix compile

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

- uses: actions/cache@v3
id: zig-cache
with:
path: zig
key: ${{ runner.os }}-zig-${{ steps.zig-version.outputs.stdout }}

- name: Get Zig
run: mix zig.get

- name: Run Tests
env:
RUNNING_CI: "true"
RUNNING_CI: "TRUE"
CI_LOG_LEVEL: warning
run: mix test --exclude no_ci
56 changes: 56 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Elixir CI - Windows

on: push

jobs:
test:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.18.3' # adjust as needed
otp-version: '27.3' # adjust as needed

- uses: actions/cache@v3
id: deps-cache
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('/mix.lock') }}-${{ hashfiles('/installer/**/*') }}

- name: Install dependencies
run: mix deps.get

- uses: actions/cache@v3
id: build-cache
with:
path: _build
key: ${{ runner.os }}-build-${{ hashFiles('/mix.lock') }}

- name: Compile base
run: mix compile

- name: Get Zig version
id: zig-version
shell: bash
run: |
VERSION=$(mix eval "IO.puts(Zig.version())" | tail -n 1)
echo "zig_version=$VERSION" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: zig-cache
with:
path: zig
key: ${{ runner.os }}-zig-${{ steps.zig-version.outputs.zig_version }}

- name: Get Zig
run: mix zig.get

- name: Run Tests
env:
RUNNING_CI: "TRUE"
run: mix test --exclude no_ci --exclude on_upgrade --exclude skip_windows
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ Library test status:

- ![](https://github.com/ityonemo/zigler/workflows/Elixir%20CI%20-%20Linux/badge.svg)
- ![](https://github.com/ityonemo/zigler/workflows/Elixir%20CI%20-%20MacOS/badge.svg)
- ![](https://github.com/ityonemo/zigler/workflows/Elixir%20CI%20-%20Windows/badge.svg)
- ![](https://github.com/ityonemo/zigler/workflows/Elixir%20CI%20-%20FreeBSD/badge.svg)

## Installation: Elixir

### Obtaining Zig dependency

Run `mix zig.get`
Run `mix zig.get` after `mix deps.get`. This will provide a zig installation
in the directory pointed to by `:filename.basedir(:user_cache, "zigler")`.

You may also use a local installation of zig by specifying the environment variable
`ZIG_ARCHIVE_PATH`.

### Main Installation

Expand All @@ -30,7 +36,7 @@ end

TBD.

`~/.cache/zigler/zig-linux-<arch>-0.13.0`
`~/.cache/zigler/zig-linux-<arch>-0.14.0`

### Main Installation

Expand Down
26 changes: 22 additions & 4 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,31 @@ Thanks to Dave Cottlehuber @dch for testing.

## 0.13.0
- updated to zig 0.13.0
- Breaking changes:
- threadlocal `context` in function calls, optional passing `beam.env` into your functions
- makes `beam.get/make` functions `context`-aware, with all context-dependent things overridable.

## 0.14.0
- Breaking changes:
- deprecation of General Purpose Allocator in favor of DebugAllocator
- beam.term_type now uses an options tuple with `env` field.
- struct module names are now assigned using the `struct` option instead of using `as`.
- Windows support:
- Experimental windows support added.
- Error return traces not supported.
- on_upgrade hooks not supported pending module .so versioning changes.
- Features:
- adds ZIG_EXECUTABLE_PATH environment variable
- path resolution from CWD when a path is specified as `./`
- adds the ability to override the default fallback function (elixir only)
- Outstanding issues:
- c_ulonglong doesn't work on windows; c_long doesn't work on other platforms.
- Etc:
- uses system `:json` module, if available.
- Experimental FreeBSD support added.

## Upcoming
- `precompiled` mode that will let you obtain packages with precompiled assets.
- Breaking changes:
- threadlocal `context` in function calls, elimination of passing `beam.env` into your functions
- makes `beam.get/make` functions `context`-aware, with all context-dependent things overridable.

## Possible
- `beam.call` which lets you call back a beam function.
- `struct` which lets you declare a struct inside your zig code as the module's struct
9 changes: 9 additions & 0 deletions guides/01-nifs.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ pub fn erroring() !void {
}
"""

@tag :erroring
test "erroring" do
assert_raise ErlangError, "Erlang error: :oops", fn -> erroring() end
end
Expand All @@ -225,3 +226,11 @@ end
documentation.
- zigler will translate the hoisted marshalling failures into detailed BEAM exceptions of type
`ArgumentError`.

## Overriding the default fallback function (elixir-only)

If the module's .so file fails to load, you might want to override the default fallback function
with a pure elixir function. To do so, simply write the function body in elixir elsewhere in the
module. This will be overwritten with the NIF only if the NIF successfully loads. You might use
this, for example, to detect CPU features in `on_load`, and fallback to a 'slower' elixir code if
CPU features required for performance are not present.
7 changes: 7 additions & 0 deletions guides/02-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ end
>
> Be careful about the endianness of packed and extern structs!

> #### Wide datatype slices .{: warning }
>
> Note: Currently if your serializable datatype requires an alignment greater than 1
> (if it's bigger than a byte), the system could segfault if you pass a binary that is
> a sub-binary. If this is a concern, always perform `:binary.copy/1` before passing
> into a function that accepts slices. This will be fixed in a future release.

### Pointers to structs.

Pointers to structs can also be used to marshal data in and out. This is enabled under the
Expand Down
Loading
Loading