mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-31 12:49:03 +00:00
Update to Zig 0.16.0 (#12726)
Closes #12228 Supersedes #12388 **UPDATED** - Also check comments for additional details! This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. At this point, all tests pass under Linux, but more work may be necessary to get them to build and function on other platforms. There are some parts of this update that deserve commentary, so that follows below: ## Expanded use of global state (IO/environment related) Global state, once generally only used by the C library, has now been expanded to be used across the project at large. The static local variable that holds the state has been moved private in its source container with all attributes that need to be accessed globally gated behind accessors, most of which guard on testing and send test copies instead. Use of the global state in non-testing scenarios asserts that the state has been initialized through `init` naturally through the optional assertion process. The rationale for this change is to have a location to store a general-purpose I/O implementation and environment variables, both of which are now provided through [Juicy Main](https://ziglang.org/download/0.16.0/release-notes.html#Juicy-Main) and hence can no longer be accessed or mutated through stdlib without use of lower-level system calls and hacks (some of which are employed, but sparingly). As the code matures, dependence on global state should naturally slim down. We do not allow global state to be used in libghostty-vt. There are comptime guards that prevent this should compilation of libghostty-vt end up pulling `global.zig`. This means that as per the last paragraph, work has already begun to de-couple the codebase from global state where necessary. Additionally, in some places where environment needs to be updated and where it can be done in an isolated fashion, environment maps are used - system-level injection of environment through the use of `setenv` or `unsetenv` now only happens during early initialization (and hopefully we can remove these in the future too, especially since they require re-synchronization of the higher-level environment primitives after this is done). ## The `lib/compat` Tree Some stdlib features that have been removed but still either seem they would be valuable to us or outright complex to move away from (particularly `SegmentedList`) have been extracted from 0.15.2, updated as needed, and placed in `src/lib/compat`. The intention again is to allow for piecemeal migration to more modern implementations or possibly straight local versions. This paradigm has also allowed us to add `std.Io.Condition.waitTimeout`, which incidentally was missed in the 0.16.0 shuffle and has been re-added for 0.17.0. We can remove this in favor of the upstream when we eventually migrate to that, obviously. Note that there was a lot more of this extracted code when this work was started, but a lot of said code has been removed (namely environment or process/fd-related functionality). ## translate-c Issues (functional on Linux, Darwin WIP) There have been a number of C translation issues that we have been working through through submitted patches and the great help from folks on the Arocc and Zig side. This is ongoing, with the remaining work to getting things fixed mainly focused on the MacOS side. Stay tuned for further developments. As mentioned at the top, follow comments for more details!
This commit is contained in:
2
.github/workflows/release-tag.yml
vendored
2
.github/workflows/release-tag.yml
vendored
@@ -153,7 +153,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: XCode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
|
||||
8
.github/workflows/release-tip.yml
vendored
8
.github/workflows/release-tip.yml
vendored
@@ -362,7 +362,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Xcode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Build XCFramework
|
||||
run: nix develop -c zig build -Demit-lib-vt -Doptimize=ReleaseFast
|
||||
@@ -454,7 +454,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: XCode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
@@ -710,7 +710,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: XCode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
@@ -907,7 +907,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: XCode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
|
||||
34
.github/workflows/test.yml
vendored
34
.github/workflows/test.yml
vendored
@@ -335,7 +335,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Xcode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Build XCFramework
|
||||
run: nix develop -c zig build -Demit-lib-vt
|
||||
@@ -645,7 +645,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Xcode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@@ -1077,7 +1077,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Xcode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
@@ -1137,7 +1137,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Xcode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
@@ -1196,9 +1196,29 @@ jobs:
|
||||
- name: Test GTK Build
|
||||
run: nix develop -c zig build -Dapp-runtime=gtk -Demit-docs -Demit-webdata
|
||||
|
||||
# This relies on the cache being populated by the commands above.
|
||||
# NOTE: This used to point to the Zig global cache directory before
|
||||
# 0.16.0. Now, the cache directory exclusively stores "minified"
|
||||
# archives of each dependency (i.e., only the paths defined in
|
||||
# build.zig.zon), and an uncompressed, working copy is stored in
|
||||
# PROJECT_ROOT/zig-pkg. The zig-pkg directory is warmed up during the
|
||||
# regular fetching process from the global cache directory if
|
||||
# possible.
|
||||
#
|
||||
# Nothing else should change; zon2nix's store path mimics what a
|
||||
# zig-pkg directory should look like, so actual build steps should be
|
||||
# fine, it's just here where we assume that all dependencies have been
|
||||
# downloaded, and we want to test the validity of the package
|
||||
# directory, do we need to have it pointing to zig-pkg and not the
|
||||
# zon2nix store path.
|
||||
#
|
||||
# Note that this can also be attempted by running:
|
||||
# zig build --fetch=needed
|
||||
#
|
||||
# Note that --system PKGDIR should not be added to this invocation as
|
||||
# it disables fetching altogether (even, seemingly, from the local
|
||||
# cache).
|
||||
- name: Test System Build
|
||||
run: nix develop -c zig build --system ${ZIG_GLOBAL_CACHE_DIR}/p
|
||||
run: nix develop -c zig build --system "$(realpath zig-pkg)"
|
||||
|
||||
test-lib-vt:
|
||||
if: github.repository == 'ghostty-org/ghostty' && needs.skip.outputs.skip != 'true'
|
||||
@@ -1377,7 +1397,7 @@ jobs:
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Xcode Select
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.3.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.6.app
|
||||
|
||||
- name: Xcode Version
|
||||
run: xcodebuild -version
|
||||
|
||||
2
.github/workflows/vouch-check-issue.yml
vendored
2
.github/workflows/vouch-check-issue.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github/issue-unvouched-message
|
||||
|
||||
- uses: mitchellh/vouch/action/check-issue@d66fa29a64600490892131ad87597c30c91fcac4 # unreleased main
|
||||
- uses: mitchellh/vouch/action/check-issue@d66fa29a64600490892131ad87597c30c91fcac4 # v1.5.0
|
||||
with:
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
auto-close: true
|
||||
|
||||
Reference in New Issue
Block a user