From 783a1c7c0e6271aa3277ca3da15c6d675b3a2488 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Tue, 13 Oct 2026 22:52:39 -0600 Subject: [PATCH 1/3] Move `@as` for `SDL_DEFAULT_ASSERT_LEVEL` outside the `switch` `u2` was selected because it best represents the valid range of values. --- build.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 91f81c181..684fdf3db 100644 --- a/build.zig +++ b/build.zig @@ -119,10 +119,10 @@ pub fn build(b: *std.Build) !void { // safe added. // https://wiki.libsdl.org/SDL3/SDL_ASSERT_LEVEL .SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED = true, - .SDL_DEFAULT_ASSERT_LEVEL = switch (optimize) { - .Debug, .ReleaseSafe => @as(i64, 2), - .ReleaseSmall, .ReleaseFast => @as(i64, 1), - }, + .SDL_DEFAULT_ASSERT_LEVEL = @as(u2, switch (optimize) { + .Debug, .ReleaseSafe => 2, + .ReleaseSmall, .ReleaseFast => 1, + }), }); lib.root_module.addConfigHeader(build_config_h); From a7ea481e02984476deb4e50123736739b7532537 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Tue, 13 Oct 2026 22:56:31 -0600 Subject: [PATCH 2/3] Fix build for Zig 0.18.0-dev.252+86dc5ce25 Zig 0.18.0-dev changed `standardOptimizeOption` to return an optional. `optimize` will now be optional for older versions of Zig as well. See: https://codeberg.org/ziglang/zig/pulls/36108 --- build.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 684fdf3db..c09e8b83f 100644 --- a/build.zig +++ b/build.zig @@ -33,7 +33,9 @@ pub fn build(b: *std.Build) !void { // Get the upstream source and build options const upstream = b.dependency("sdl", .{}); const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); + // Coercing to an optional makes the value consistent across multiple versions of Zig. + // TODO: Remove explicit type annotation when Zig 0.18.0 is the minimum supported version. + const optimize: ?std.builtin.OptimizeMode = b.standardOptimizeOption(.{}); const default_target_config = b.option( bool, @@ -119,7 +121,7 @@ pub fn build(b: *std.Build) !void { // safe added. // https://wiki.libsdl.org/SDL3/SDL_ASSERT_LEVEL .SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED = true, - .SDL_DEFAULT_ASSERT_LEVEL = @as(u2, switch (optimize) { + .SDL_DEFAULT_ASSERT_LEVEL = @as(u2, switch (optimize orelse std.builtin.OptimizeMode.Debug) { .Debug, .ReleaseSafe => 2, .ReleaseSmall, .ReleaseFast => 1, }), @@ -146,7 +148,7 @@ pub fn build(b: *std.Build) !void { const translate_c = b.addTranslateC(.{ .root_source_file = b.path("src/sdl.h"), .target = target, - .optimize = optimize, + .optimize = optimize orelse std.builtin.OptimizeMode.Debug, }); translate_c.defineCMacro("USING_GENERATED_CONFIG_H", "1"); translate_c.addIncludePath(upstream.path("include")); From bb7c885b98e108c32206249fb6cf36cfe639d224 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Thu, 15 Oct 2026 19:41:27 -0700 Subject: [PATCH 3/3] Convert inline TODO into issue --- build.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.zig b/build.zig index c09e8b83f..e1633b2cd 100644 --- a/build.zig +++ b/build.zig @@ -33,8 +33,7 @@ pub fn build(b: *std.Build) !void { // Get the upstream source and build options const upstream = b.dependency("sdl", .{}); const target = b.standardTargetOptions(.{}); - // Coercing to an optional makes the value consistent across multiple versions of Zig. - // TODO: Remove explicit type annotation when Zig 0.18.0 is the minimum supported version. + // https://github.com/allyourcodebase/SDL/issues/42 const optimize: ?std.builtin.OptimizeMode = b.standardOptimizeOption(.{}); const default_target_config = b.option(