Skip to content

Upgrade from Zig 0.15 to 0.16.0 #63

Description

@Boomatang

Upgrade from Zig 0.15 to 0.16.0

Summary

The project is currently using Zig 0.15.1 (minimum version in build.zig.zon). Zig 0.16.0 has been released with several breaking changes that require migration.

Breaking Changes Requiring Migration

1. Environment Variables in Main Function Only (CRITICAL)

Status: ⚠️ Requires code restructuring

What changed:

  • Environment variables are now only available in the application's main function
  • std.process.getEnvVarOwned() is now only usable within main()
  • Error EnvironmentVariableNotFound renamed to EnvironmentVariableMissing

Current usage:

  • src/help.zig:7,8,11 - Uses std.process.getEnvVarOwned() for TEMP/TMP/TMPDIR
  • src/main.zig:114 - Uses std.process.getEnvVarOwned() for GRAB_PATH

Action required:

  • Move getTempDir() function into main() or wrap it to accept environment as parameter
  • Pass environment variables to functions that need them, instead of accessing globally
  • Update error handling from error.EnvironmentVariableNotFound to error.EnvironmentVariableMissing

2. @type Builtin Removal (LOW PRIORITY)

Status: Requires code change

What changed:

  • @Type builtin removed, replaced with individual type-creating functions
  • @Type(.enum_literal)@EnumLiteral()

Action required:

  • Replace @Type(.enum_literal) with @EnumLiteral() in src/main.zig:17

3. @cImport Deprecation (MEDIUM PRIORITY)

Status: Needs investigation

What changed:

  • @cImport is now deprecated and will be removed
  • C translation must now be handled via the Build System using addTranslateC()

Action required:

  • Review current C usage (using std.posix.* currently)
  • If @cImport is used elsewhere, migrate to build system translate-c

4. OS Version Requirements (INFORMATIONAL)

Status: ℹ️ Check compatibility

Zig 0.16.0 has minimum OS version requirements:

  • Linux: 5.10+
  • macOS: 13.0+
  • Windows: 10+
  • FreeBSD: 14.0+
  • NetBSD: 10.1+
  • OpenBSD: 7.8+

Action required:

  • Update documentation if needed
  • Consider minimum system requirements for users

5. Standard Library Changes (INFORMATIONAL)

Status: ℹ️ Review if using affected features

Removals:

  • heap.ThreadSafeAllocator removed
  • posix and os.windows removals in stdlib
  • fs.getAppDataDir() removed
  • GenericReader, AnyReader, FixedBufferStream removed
  • Thread.Pool removed
  • builtin.subsystem removed

Additions:

  • I/O as an Interface (Future, Group, Cancelation, Batch)
  • Deflate compression support
  • PriorityDequeue, PriorityQueue
  • New crypto algorithms (AES-SIV, AES-GCM-SIV, Ascon-AEAD)

6. Build System Enhancements (OPTIONAL)

Status: ℹ️ Consider using new features

New features available:

  • Ability to override packages locally
  • Fetch packages into project-local directory
  • Unit test timeouts (unit test_timeout)
  • --error-style and --multiline-errors flags
  • Temporary Files API

7. Compiler Changes (INFORMATIONAL)

Status: ℹ️ No code changes expected

  • LLVM backend upgraded to LLVM 21
  • Incremental compilation support
  • Improved C translation
  • Reworked byval syntax lowering

Migration Checklist

  • CRITICAL: Restructure code to use environment variables only in main()
    • Move getTempDir() from help.zig into main() or accept environ parameter
    • Pass GRAB_PATH environment to main() instead of using getEnvVarOwned()
    • Update error handling from error.EnvironmentVariableNotFound to error.EnvironmentVariableMissing
  • Replace @Type(.enum_literal) with @EnumLiteral() in src/main.zig:17
  • Review @cImport usage and migrate if needed
  • Update build.zig.zon minimum_zig_version to "0.16.0"
  • Test build on all target platforms
  • Verify OS compatibility requirements
  • Update documentation with new requirements
  • Run tests on all platforms

Files to Modify

  1. src/main.zig:17 - Replace @Type(.enum_literal) with @EnumLiteral()
  2. src/main.zig:114 - Restructure to use environment variables only in main()
  3. src/help.zig:7,8,11 - Move getTempDir() into main() or accept environ parameter
  4. build.zig.zon - Update minimum_zig_version from "0.15.1" to "0.16.0"

Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions