all: nominate Zig 2024.1.0-mach #1135

Closed
opened 2024-01-07 06:21:04 +00:00 by emidoots · 5 comments
emidoots commented 2024-01-07 06:21:04 +00:00 (Migrated from github.com)

Periodically we nominate a new Zig nightly version to be the version that Mach targets, and begin the meticulous process of updating every Mach project to use that new version.

This is the tracking issue to do that for the next scheduled nomination (see the date in the issue title.)

You may have been linked to this issue because you sent a pull request to update a Mach project to use a new Zig API - if that is the case we do appreciate the PR and will look at merging it once this process begins. In the meantime, your PR may stay open for a while. You can either use a fork of the project, or use the version of Zig that Mach currently supports.

Update process

  • It is time to begin (see date in issue title, we aim to begin this checklist between the 1st-4th of that month.)
  • In machengine.org repository static/zig folder, wrench script nominate-zig-index-update nominate 2024.1.0-mach-wip has been ran and the index.json has been updated.
  • #wrench automation (!wrench schedule-now update-zig-version) has created new pull requests to update the Zig version used in CI of all our projects, and it matches index.json.
  • The Nomination history has a new section for the latest nightly Zig version which Wrench used in its PRs, with a warning at the top **IN-PROGRESS:** This version is currently being nominated, see [the tracking issue](https://github.com/hexops/mach/issues/1135) for details. Once everything looks good, the new Zig version is confirmed to be working with Mach, we will declare success, close the issue, and remove this in-progress warning..
  • #general Discord message: Beginning the process of nominating a new Zig version! (you should wait to upgrade until we've updated everything to confirm it works) $GITHUB_ISSUE
  • #wrench automation (!wrench script-all install-zig) has updated the Zig version used by self-hosted GitHub actions runners. TODO this needs some work.
  • "First-order projects" below (which have zero build.zig.zon dependencies) have been updated, their CI is passing/green using the new version.
  • "Second-order projects" below (which have build.zig.zon dependencies) have been updated, their CI is passing/green using the new version.
  • The mach-glfw build.zig version check has been updated: https://github.com/hexops/mach-glfw/blob/main/build.zig
  • The mach-core build.zig version check has been updated: https://github.com/hexops/mach-core/blob/main/build.zig#L222-L227
  • https://machengine.org/core/migrations/ has a new entry for Core users looking to update, or changes are not needed.
  • The .zigversion file https://github.com/hexops/mach/blob/main/.zigversion has been updated.
  • The mach build.zig version check has been updated: https://github.com/hexops/mach/blob/main/build.zig#L187-L192
  • https://machengine.org/about/zig-version has been updated
  • In machengine.org repository static/zig folder, wrench script nominate-zig-index-update finalize 2024.1.0-mach-wip has been ran and the index.json has had -wip removed and the mach-latest entry has been updated.
  • The **IN-PROGRESS** warning in the Nomination history has been removed.
  • A new issue has been filed for the next nomination.
  • A #progress announcement has been made:

We've just finalized nominating and updating to Zig 2024.1.0-mach. We encourage you to update your projects to that Zig version now. :)

First-order projects

These projects have zero build.zig.zon dependencies, we update them first - and in any order.

  • mach-ecs
  • mach-gamemode
  • mach-model3d
  • mach-sysjs
  • mach-objc-generator
  • fastfilter
  • spirv-cross
  • brotli
  • wayland-headers
  • x11-headers
  • vulkan-headers
  • opengl-headers
  • linux-audio-headers
  • xcode-frameworks
  • basisu
  • vulkan-zig-generated
  • directx-headers
  • direct3d-headers
  • opus
  • flac
  • ogg
  • mach-core-example-assets
  • font-assets

Second-order projects

These projects have dependencies on other projects. We update them in the exact order below, top-to-bottom.

  • spirv-tools, which depends on:
  • opusenc, which depends on:
    • opus
  • freetype, which depends on:
    • brotli
  • opusfile, which depends on:
    • opus
    • ogg
  • harfbuzz, which depends on:
    • freetype
    • brotli
  • glfw, which depends on:
    • xcode-frameworks
    • vulkan-headers
    • wayland-headers
    • x11-headers
  • mach-glfw, which depends on:
    • glfw
  • mach-dxcompiler, which depends on:
  • mach-basisu, which depends on:
    • basisu
  • mach-objc, which depends on:
    • xcode-frameworks
  • mach-freetype, which depends on:
    • freetype
    • harfbuzz
    • font-assets
  • mach-sysaudio, which depends on:
    • mach-sysjs
    • linux-audio-headers
    • xcode-frameworks
  • mach-flac, which depends on:
    • flac
    • mach-sysaudio
    • linux-audio-headers
  • mach-opus, which depends on:
    • opusfile
    • opusenc
    • mach-sysaudio
    • linux-audio-headers
  • mach-gpu-dawn, which depends on:
    • xcode-frameworks
    • direct3d-headers
    • vulkan-headers
    • x11-headers
  • mach-gpu, which depends on:
    • mach-glfw
    • mach-gpu-dawn
  • mach-sysgpu, which depends on:
    • vulkan-zig-generated
    • mach-gpu
    • mach-objc
    • direct3d-headers
    • opengl-headers
    • xcode-frameworks
  • mach-core, which depends on:
    • build.zig version check
    • mach-core-example-assets
    • mach-gamemode
    • mach-sysgpu
    • mach-gpu
    • mach-glfw
  • mach-core-starter-project, which depends on:
    • mach-core
  • mach, which depends on:
    • .zigversion
    • build.zig version check
    • mach-ecs
    • mach-core
    • mach-basisu
    • mach-sysaudio
    • mach-freetype
    • mach-sysjs
    • font-assets
  • mach-examples, which depends on:
    • zigimg
    • mach
    • mach-freetype
  • mach-editor, which depends on:
    • mach
    • mach-sysgpu
    • spirv-cross
    • spirv-tools
Periodically we [nominate a new Zig nightly version](https://machengine.org/about/nominated-zig) to be the version that Mach targets, and begin the meticulous process of updating every Mach project to use that new version. This is the tracking issue to do that for the next scheduled nomination (see the date in the issue title.) You may have been linked to this issue because you sent a pull request to update a Mach project to use a new Zig API - if that is the case we do appreciate the PR and will look at merging it once this process begins. In the meantime, your PR may stay open for a while. You can either use a fork of the project, or [use the version of Zig that Mach currently supports.](https://machengine.org/about/zig-version) ## Update process * [x] It is time to begin (see date in issue title, we aim to begin this checklist between the 1st-4th of that month.) * [x] In `machengine.org` repository `static/zig` folder, `wrench script nominate-zig-index-update nominate 2024.1.0-mach-wip` has been ran and the [`index.json`](https://machengine.org/zig/index.json) has been updated. * [x] #wrench automation (`!wrench schedule-now update-zig-version`) has created new pull requests to update the Zig version used in CI of all our projects, and it matches index.json. * [x] The [_Nomination history_](https://machengine.org/about/nominated-zig/#nomination-history) has a new section for the latest nightly Zig version which Wrench used in its PRs, with a warning at the top `**IN-PROGRESS:** This version is currently being nominated, see [the tracking issue](https://github.com/hexops/mach/issues/1135) for details. Once everything looks good, the new Zig version is confirmed to be working with Mach, we will declare success, close the issue, and remove this in-progress warning.`. * [x] #general Discord message: `Beginning the process of nominating a new Zig version! (you should wait to upgrade until we've updated everything to confirm it works) $GITHUB_ISSUE` * [x] #wrench automation (`!wrench script-all install-zig`) has updated the Zig version used by self-hosted GitHub actions runners. TODO this needs some work. * [x] "First-order projects" below (which have zero build.zig.zon dependencies) have been updated, their CI is passing/green using the new version. * [x] "Second-order projects" below (which have build.zig.zon dependencies) have been updated, their CI is passing/green using the new version. * [x] The mach-glfw build.zig version check has been updated: https://github.com/hexops/mach-glfw/blob/main/build.zig * [x] The mach-core build.zig version check has been updated: https://github.com/hexops/mach-core/blob/main/build.zig#L222-L227 * [x] https://machengine.org/core/migrations/ has a new entry for Core users looking to update, or changes are not needed. * [x] The `.zigversion` file https://github.com/hexops/mach/blob/main/.zigversion has been updated. * [x] The mach build.zig version check has been updated: https://github.com/hexops/mach/blob/main/build.zig#L187-L192 * [x] https://machengine.org/about/zig-version has been updated * [x] In `machengine.org` repository `static/zig` folder, `wrench script nominate-zig-index-update finalize 2024.1.0-mach-wip` has been ran and the [`index.json`](https://machengine.org/zig/index.json) has had `-wip` removed and the `mach-latest` entry has been updated. * [x] The `**IN-PROGRESS**` warning in the _Nomination history_ has been removed. * [x] A [new issue](https://github.com/hexops/mach/issues/new?assignees=slimsag&labels=all%2C+zig-update&projects=&template=dev_zig_nomination.md&title=all%3A+nominate+Zig+YYYY.MM) has been filed for the next nomination. * [x] A #progress announcement has been made: > We've just finalized nominating and updating to Zig 2024.1.0-mach. We encourage you to update your projects to that Zig version now. :) > > * Get the new Zig version: https://machengine.org/about/nominated-zig/#202410-mach > * Update your mach-core project: https://machengine.org/core/migrations/#mach-core-updated-to-zig-202410-mach-2024-01-14 > * Tips on upgrading your own Zig code: https://github.com/hexops/mach/issues/1135#issuecomment-1891175749 > * Nomination tracking issue: $GITHUB_ISSUE ## First-order projects These projects have zero `build.zig.zon` dependencies, we update them first - and in any order. * [x] mach-ecs * [x] mach-gamemode * [x] mach-model3d * [x] mach-sysjs * [x] mach-objc-generator * [x] fastfilter * [x] spirv-cross * [x] brotli * [x] wayland-headers * [x] x11-headers * [x] vulkan-headers * [x] opengl-headers * [x] linux-audio-headers * [x] xcode-frameworks * [x] basisu * [x] vulkan-zig-generated * [x] directx-headers * [x] direct3d-headers * [x] opus * [x] flac * [x] ogg * [x] mach-core-example-assets * [x] font-assets ## Second-order projects These projects have dependencies on other projects. We update them in the exact order below, top-to-bottom. * [x] spirv-tools, which depends on: * External package https://github.com/KhronosGroup/SPIRV-Headers * [x] opusenc, which depends on: * opus * [x] freetype, which depends on: * brotli * [x] opusfile, which depends on: * opus * ogg * [x] harfbuzz, which depends on: * freetype * brotli * [x] glfw, which depends on: * xcode-frameworks * vulkan-headers * wayland-headers * x11-headers * [x] mach-glfw, which depends on: * glfw * [x] mach-dxcompiler, which depends on: * [x] mach-basisu, which depends on: * basisu * [x] mach-objc, which depends on: * xcode-frameworks * [x] mach-freetype, which depends on: * freetype * harfbuzz * font-assets * [x] mach-sysaudio, which depends on: * mach-sysjs * linux-audio-headers * xcode-frameworks * [x] mach-flac, which depends on: * flac * mach-sysaudio * linux-audio-headers * [x] mach-opus, which depends on: * opusfile * opusenc * mach-sysaudio * linux-audio-headers * [x] mach-gpu-dawn, which depends on: * xcode-frameworks * direct3d-headers * vulkan-headers * x11-headers * [x] mach-gpu, which depends on: * mach-glfw * mach-gpu-dawn * [x] mach-sysgpu, which depends on: * vulkan-zig-generated * mach-gpu * mach-objc * direct3d-headers * opengl-headers * xcode-frameworks * [x] mach-core, which depends on: * build.zig version check * mach-core-example-assets * mach-gamemode * mach-sysgpu * mach-gpu * mach-glfw * [x] mach-core-starter-project, which depends on: * mach-core * [x] mach, which depends on: * .zigversion * build.zig version check * mach-ecs * mach-core * mach-basisu * mach-sysaudio * mach-freetype * mach-sysjs * font-assets * [x] mach-examples, which depends on: * zigimg * mach * mach-freetype * [x] mach-editor, which depends on: * mach * mach-sysgpu * spirv-cross * spirv-tools
emidoots commented 2024-01-09 03:23:59 +00:00 (Migrated from github.com)

First-order dependencies are almost finished, awesome! Remaining blockers:

  • xcode-frameworks may need a change like as in this PR - but I'd like to see an explanation for why it is needed and why we need it and addPaths, instead of a single function? We'll have to try updating a package with xcode-frameworks to learn why. wasn't needed.
  • directx-headers needs updating.
  • Wrench didn't update spirv-cross, directx-headers, why?
  • I will look at integrating some changes from https://github.com/mitchellh/zig-build-macos-sdk into our xcode-frameworks package.
    • This will be done at a later date, since Ghostty doesn't need it.

Additionally, let's try eliminating direct3d-headers in favor of directx-headers during this update process.

First-order dependencies are almost finished, awesome! Remaining blockers: * [x] ~~xcode-frameworks may need a change like [as in this PR](https://github.com/hexops/xcode-frameworks/pull/15/files#diff-f87bb3596894756629bc39d595fb18d479dc4edf168d93a911cadcb060f10fccR25) - but I'd like to see an explanation for why it is needed and why we need it and `addPaths`, instead of a single function? We'll have to try updating a package with xcode-frameworks to learn why.~~ wasn't needed. * [x] directx-headers needs updating. * [x] Wrench didn't update `spirv-cross`, `directx-headers`, why? * [x] ~~I will look at integrating some changes from https://github.com/mitchellh/zig-build-macos-sdk into our xcode-frameworks package.~~ * This will be done at a later date, since Ghostty doesn't need it. Additionally, let's try eliminating direct3d-headers in favor of directx-headers during this update process.
emidoots commented 2024-01-15 01:45:47 +00:00 (Migrated from github.com)

Tips for updating code to Zig 2024.1.0-mach

Renamed:

  • unnecessary var -> const changes must be made, if you have ZLS installed and open each Zig file and save, it will do it automatically for you.
  • std.build.Builder -> std.Build
  • std.build.RunStep -> std.Build.Step.Run
  • std.build.CompileStep -> std.Build.Step.Compile
  • std.build.ModuleDependency -> std.Build.Module.Import
  • std.zig.CrossTarget -> std.Build.ResolvedTarget
  • std.mem.copy(T, dst, src) -> @memcpy(dst, src)
  • std.fs.openIterableDirAbsolute -> std.fs.openDirAbsolute(dir, .{.iterate = true})
  • target.toTarget().os.tag -> target.result.os.tag
  • step.target_info -> step.rootModuleTarget()
  • target.getOsTag() -> target.os.tag
  • target.getAbi() -> target.abi
  • target.getCpuArch() -> target.cpu.arch
  • target.isWindows() -> target.os.tag == .windows
  • std.atomic.Atomic(T) -> std.atomic.Value(T)
  • step.addModule("foo", bar) -> step.root_module.addImport("foo", bar)
  • .dependencies = &.{} -> .imports = &.{}
  • comptime const foo -> const foo

Error resolutions:

error: no field named 'source_file' in struct 'Build.Module.CreateOptions'

Change .source_file -> .root_source_file

error: expected type expression, found 'invalid bytes'

error: expected type expression, found 'invalid bytes'
#include "hb-aat-layout.cc"
^
src/harfbuzz.cc:1:1: note: invalid byte: '#'

.root_source_file can no longer be C/C++ files, only .zig. Remove .root_source_file entirely and add the C/C++ file to the module using e.g. this instead:

    lib.addCSourceFile(.{ .file = .{ .path = "src/harfbuzz.cc" } });

panic: @memcpy arguments have non-equal lengths

Ensure both arguments to memcpy have the same lengths. For example a previously valid copy can be updated like this:

-@memcpy(title[0..], opt.title);
+@memcpy(title[0..opt.title.len], opt.title);
# Tips for updating code to Zig 2024.1.0-mach Renamed: * unnecessary `var -> const` changes must be made, if you have ZLS installed and open each Zig file and save, it will do it automatically for you. * `std.build.Builder` -> `std.Build` * `std.build.RunStep` -> `std.Build.Step.Run` * `std.build.CompileStep` -> `std.Build.Step.Compile` * `std.build.ModuleDependency` -> `std.Build.Module.Import` * `std.zig.CrossTarget` -> `std.Build.ResolvedTarget` * `std.mem.copy(T, dst, src)` -> `@memcpy(dst, src)` * `std.fs.openIterableDirAbsolute` -> `std.fs.openDirAbsolute(dir, .{.iterate = true})` * `target.toTarget().os.tag` -> `target.result.os.tag` * `step.target_info` -> `step.rootModuleTarget()` * `target.getOsTag()` -> `target.os.tag` * `target.getAbi()` -> `target.abi` * `target.getCpuArch()` -> `target.cpu.arch` * `target.isWindows()` -> `target.os.tag == .windows` * `std.atomic.Atomic(T)` -> `std.atomic.Value(T)` * `step.addModule("foo", bar)` -> `step.root_module.addImport("foo", bar)` * `.dependencies = &.{}` -> `.imports = &.{}` * `comptime const foo` -> `const foo` Error resolutions: ### `error: no field named 'source_file' in struct 'Build.Module.CreateOptions'` Change `.source_file` -> `.root_source_file` ### `error: expected type expression, found 'invalid bytes'` ``` error: expected type expression, found 'invalid bytes' #include "hb-aat-layout.cc" ^ src/harfbuzz.cc:1:1: note: invalid byte: '#' ``` `.root_source_file` can no longer be C/C++ files, only `.zig`. Remove `.root_source_file` entirely and add the C/C++ file to the module using e.g. this instead: ``` lib.addCSourceFile(.{ .file = .{ .path = "src/harfbuzz.cc" } }); ``` ### `panic: @memcpy arguments have non-equal lengths` Ensure both arguments to memcpy have the same lengths. For example a previously valid copy can be updated like this: ```diff -@memcpy(title[0..], opt.title); +@memcpy(title[0..opt.title.len], opt.title); ```
Techatrix commented 2024-01-15 22:35:23 +00:00 (Migrated from github.com)
  • unnecessary var -> const changes must be made, if you have ZLS installed and open each Zig file and save, it will do it automatically for you.

That feature has been removed from autofix in https://github.com/zigtools/zls/pull/1652 so it is only an ordinary code action.
The autofix feature has also been disabled by default in https://github.com/zigtools/zls/pull/1657 😭.

> * unnecessary `var -> const` changes must be made, if you have ZLS installed and open each Zig file and save, it will do it automatically for you. That feature has been removed from autofix in https://github.com/zigtools/zls/pull/1652 so it is only an ordinary code action. The autofix feature has also been disabled by default in https://github.com/zigtools/zls/pull/1657 😭.
Cloudef commented 2024-01-17 03:16:03 +00:00 (Migrated from github.com)

gnused, bash alternative

if [[ ! -d "$1" ]]; then
  printf 'error: no such directory: %s\n' "$1"
  exit 1
fi

cd "$1"
has_wontfix=0

while {
    IFS=$':' read -r file line col msg;
} do
  if [[ "$msg" ]]; then
    case "$msg" in
      *"local variable is never mutated")
        printf 'autofix: %s\n' "$file:$line:$col:$msg" 1>&2
        sed -i "''${line}s/var/const/" "$file"
        ;;
      *)
        printf 'wontfix: %s\n' "$file:$line:$col:$msg" 1>&2
        has_wontfix=1
        ;;
    esac
  fi
done < <(zig build 2>&1 | grep "error:")

exit $has_wontfix
gnused, bash alternative ```bash if [[ ! -d "$1" ]]; then printf 'error: no such directory: %s\n' "$1" exit 1 fi cd "$1" has_wontfix=0 while { IFS=$':' read -r file line col msg; } do if [[ "$msg" ]]; then case "$msg" in *"local variable is never mutated") printf 'autofix: %s\n' "$file:$line:$col:$msg" 1>&2 sed -i "''${line}s/var/const/" "$file" ;; *) printf 'wontfix: %s\n' "$file:$line:$col:$msg" 1>&2 has_wontfix=1 ;; esac fi done < <(zig build 2>&1 | grep "error:") exit $has_wontfix ```
Srekel commented 2024-02-16 15:03:20 +00:00 (Migrated from github.com)

Super useful!!

A couple extra things I had to do when updating Tides (from a pretty old Zig build):

std.builtin.Endian.Little -> little

Actually not sure if this one is correct but I guess so?
comptime var arg_count = ecsu.meta.argCount(function); -> const arg_count = comptime ecsu.meta.argCount(function);

std.zig.system.NativeTargetInfo.detect(target) -> std.zig.system.resolveTargetQuery(target.query)

exe.linkSystemLibraryName("imm32"); -> exe.linkSystemLibrary("imm32");

Super useful!! A couple extra things I had to do when updating Tides (from a pretty old Zig build): `std.builtin.Endian.Little` -> `little` Actually not sure if this one is correct but I guess so? `comptime var arg_count = ecsu.meta.argCount(function);` -> `const arg_count = comptime ecsu.meta.argCount(function);` `std.zig.system.NativeTargetInfo.detect(target)` -> `std.zig.system.resolveTargetQuery(target.query)` `exe.linkSystemLibraryName("imm32");` -> `exe.linkSystemLibrary("imm32");`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1135
No description provided.