Skip to content

Commit

Permalink
Upgraded to latest zig version (0.12.0-dev.2036+fc79b22a9) but wasm i…
Browse files Browse the repository at this point in the history
…s now broken. One thing of note is lib.stack_protector in build.zig is not available anymore.
  • Loading branch information
jdmichaud committed Jan 5, 2024
1 parent 8deeaad commit 03270a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const std = @import("std");

pub fn setup_wasm(b: *std.build, optimize: std.builtin.Mode) void {
const lib = b.addSharedLibrary(.{
pub fn setup_wasm(b: *std.Build, optimize: std.builtin.Mode) void {
const lib = b.addExecutable(.{
.name = "zpz6128",
.version = .{ .major = 1, .minor = 0, .patch = 0 },
.optimize = optimize,
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.root_source_file = .{ .path = "src/zpz-wasm.zig" },
});
lib.entry = .disabled;
lib.addIncludePath(.{ .path = "./chips/" });
lib.addCSourceFiles(.{ .files = &.{"src/chips-impl.c"} });
// We need the libc because of the use of #include <string> memset in `chips`
Expand All @@ -21,7 +25,7 @@ pub fn setup_wasm(b: *std.build, optimize: std.builtin.Mode) void {
// lib.export_symbol_names = &[_][]const u8{ "add" };
lib.rdynamic = true;
// So we don't need to define like __stack_chk_guard and __stack_chk_fail
lib.stack_protector = false;
// lib.stack_protector = false;

const wasm_step = b.step("wasm", "Compile the wasm library");
wasm_step.dependOn(&b.addInstallArtifact(lib, .{}).step);
Expand Down
4 changes: 2 additions & 2 deletions src/sdl-adapter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub const SDLAdapter = struct {
}

pub fn display(adapter: *IOAdapter, pixel_buffer: [*]c_uint, width: usize, height: usize) anyerror!void {
var self = @fieldParentPtr(SDLAdapter, "interface", adapter);
const self = @fieldParentPtr(SDLAdapter, "interface", adapter);

try prepareScene(self, pixel_buffer, width, height);
try renderScene(self);
Expand All @@ -148,7 +148,7 @@ pub const SDLAdapter = struct {
}

fn prepareScene(self: *Self, pixel_buffer: [*]c_uint, width: usize, height: usize) anyerror!void {
var texture = self.texture;
const texture = self.texture;

var buffer: [*c]u32 = undefined;
var pitch: i32 = undefined;
Expand Down
2 changes: 1 addition & 1 deletion web/zpz6128.wasm

0 comments on commit 03270a3

Please sign in to comment.