Skip to content

Commit

Permalink
all: remove support for stage1
Browse files Browse the repository at this point in the history
With almost all tests/examples working on all platforms now with the new compiler,
#180, it's time to remove stage1 support.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
  • Loading branch information
slimsag committed Sep 10, 2022
1 parent 4c3a19f commit 8113ca3
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 1,907 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,16 @@ Mach is still early stages, so far we have support for building from the followi

## Supported Zig version

Zig has switched to the self-hosted compiler recently. This is a huge milestone, but currently means that Zig nightly versions are a little bit unstable. For now, we suggest using a slightly older Zig version before the switch to the self-hosted compiler.
Mach works with the new self-hosted Zig compiler only. This means you'll need to use the latest Zig nightly version.

Currently tested with: 0.10.0-dev.3952+9e070b653

You can download binary releases of this version at:
Currently we test using `0.10.0-dev.3952+9e070b653`. Newer is generally better, but you can download this version here:

* **linux-x86_64**: https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3952+9e070b653.tar.xz)
* **windows-x86_64**: https://ziglang.org/builds/zig-windows-x86_64-0.10.0-dev.3952+9e070b653.zip
* **macos-x86_64** (Intel): https://ziglang.org/builds/zig-macos-x86_64-0.10.0-dev.3952+9e070b653.tar.xz
* **macos-aarch64** (Apple Silicon): https://ziglang.org/builds/zig-macos-aarch64-0.10.0-dev.3952+9e070b653.tar.xz

You can subscribe to [issue #180](https://github.com/hexops/mach/issues/180) for how we're tracking towards support for the latest nightly version of Zig.
`mach/ecs` and WebAssembly examples have known issues unless using `-fstage1`, see [issue #180](https://github.com/hexops/mach/issues/180) for details.

## Contributing

Expand Down
4 changes: 0 additions & 4 deletions libs/ecs/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ pub fn build(b: *std.build.Builder) void {

pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget) *std.build.RunStep {
const main_tests = b.addTestExe("ecs-tests", (comptime thisDir()) ++ "/src/main.zig");

// TODO(self-hosted): remove this when tests passed with self-hosted compiler
main_tests.use_stage1 = true;

main_tests.setBuildMode(mode);
main_tests.setTarget(target);
main_tests.install();
Expand Down
1 change: 1 addition & 0 deletions libs/ecs/src/systems.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn Messages(comptime messages: anytype) type {
}};
}

// TODO(self-hosted): check if we can remove this now
// Hack to workaround stage1 compiler bug. https://github.com/ziglang/zig/issues/8114
//
// return @Type(.{
Expand Down
48 changes: 12 additions & 36 deletions libs/freetype/src/image.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ const BBox = @import("types.zig").BBox;
pub const Vector = c.FT_Vector;
pub const GlyphMetrics = c.FT_Glyph_Metrics;
pub const Span = c.FT_Span;
pub const SpanFunc = if (builtin.zig_backend == .stage1)
fn (y: c_int, count: c_int, spans: [*]const Span, user: *anyopaque) callconv(.C) void
else
*const fn (y: c_int, count: c_int, spans: [*]const Span, user: *anyopaque) callconv(.C) void;
pub const SpanFunc = *const fn (y: c_int, count: c_int, spans: [*]const Span, user: *anyopaque) callconv(.C) void;

pub const PixelMode = enum(u3) {
none = c.FT_PIXEL_MODE_NONE,
Expand Down Expand Up @@ -204,10 +201,10 @@ pub const Outline = struct {

pub fn Funcs(comptime Context: type) type {
return struct {
move_to: if (builtin.zig_backend == .stage1 or builtin.zig_backend == .other) fn (ctx: Context, to: Vector) Error!void else *const fn (ctx: Context, to: Vector) Error!void,
line_to: if (builtin.zig_backend == .stage1 or builtin.zig_backend == .other) fn (ctx: Context, to: Vector) Error!void else *const fn (ctx: Context, to: Vector) Error!void,
conic_to: if (builtin.zig_backend == .stage1 or builtin.zig_backend == .other) fn (ctx: Context, control: Vector, to: Vector) Error!void else *const fn (ctx: Context, control: Vector, to: Vector) Error!void,
cubic_to: if (builtin.zig_backend == .stage1 or builtin.zig_backend == .other) fn (ctx: Context, control_0: Vector, control_1: Vector, to: Vector) Error!void else *const fn (ctx: Context, control_0: Vector, control_1: Vector, to: Vector) Error!void,
move_to: *const fn (ctx: Context, to: Vector) Error!void,
line_to: *const fn (ctx: Context, to: Vector) Error!void,
conic_to: *const fn (ctx: Context, control: Vector, to: Vector) Error!void,
cubic_to: *const fn (ctx: Context, control_0: Vector, control_1: Vector, to: Vector) Error!void,
shift: i32,
delta: i32,
};
Expand Down Expand Up @@ -295,34 +292,13 @@ pub const Outline = struct {
pub const Raster = struct {
handle: c.FT_Raster,

pub const NewFunc = if (builtin.zig_backend == .stage1)
fn (memory: ?*anyopaque, raster: [*c]c.FT_Raster) callconv(.C) c_int
else
*const fn (memory: ?*anyopaque, raster: [*c]c.FT_Raster) callconv(.C) c_int;
pub const DoneFunc = if (builtin.zig_backend == .stage1)
fn (raster: [*c]c.FT_Raster) callconv(.C) void
else
*const fn (raster: [*c]c.FT_Raster) callconv(.C) void;
pub const ResetFunc = if (builtin.zig_backend == .stage1)
fn (raster: c.FT_Raster, pool_base: [*c]u8, pool_size: c_ulong) callconv(.C) void
else
*const fn (raster: c.FT_Raster, pool_base: [*c]u8, pool_size: c_ulong) callconv(.C) void;
pub const SetModeFunc = if (builtin.zig_backend == .stage1)
fn (raster: c.FT_Raster, mode: c_ulong, args: ?*anyopaque) callconv(.C) c_int
else
*const fn (raster: c.FT_Raster, mode: c_ulong, args: ?*anyopaque) callconv(.C) c_int;
pub const RenderFunc = if (builtin.zig_backend == .stage1)
fn (raster: c.FT_Raster, params: Params) callconv(.C) c_int
else
*const fn (raster: c.FT_Raster, params: Params) callconv(.C) c_int;
pub const BitTestFunc = if (builtin.zig_backend == .stage1)
fn (y: c_int, x: c_int, user: ?*anyopaque) callconv(.C) c_int
else
*const fn (y: c_int, x: c_int, user: ?*anyopaque) callconv(.C) c_int;
pub const BitSetFunc = if (builtin.zig_backend == .stage1)
fn (y: c_int, x: c_int, user: ?*anyopaque) callconv(.C) void
else
*const fn (y: c_int, x: c_int, user: ?*anyopaque) callconv(.C) void;
pub const NewFunc = *const fn (memory: ?*anyopaque, raster: [*c]c.FT_Raster) callconv(.C) c_int;
pub const DoneFunc = *const fn (raster: [*c]c.FT_Raster) callconv(.C) void;
pub const ResetFunc = *const fn (raster: c.FT_Raster, pool_base: [*c]u8, pool_size: c_ulong) callconv(.C) void;
pub const SetModeFunc = *const fn (raster: c.FT_Raster, mode: c_ulong, args: ?*anyopaque) callconv(.C) c_int;
pub const RenderFunc = *const fn (raster: c.FT_Raster, params: Params) callconv(.C) c_int;
pub const BitTestFunc = *const fn (y: c_int, x: c_int, user: ?*anyopaque) callconv(.C) c_int;
pub const BitSetFunc = *const fn (y: c_int, x: c_int, user: ?*anyopaque) callconv(.C) void;

pub const Params = extern struct {
target: [*c]const c.FT_Bitmap,
Expand Down
5 changes: 1 addition & 4 deletions libs/gamemode/gamemode.zig
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Note: All the above requests can be blocking - dbus requests can and will block while the daemon
//! handles the request. It is not recommended to make these calls in performance critical code
const builtin = @import("builtin");
pub const c = if (builtin.zig_backend == .stage1)
@import("gamemode_client_stage1.zig")
else
@import("gamemode_client.zig");
pub const c = @import("gamemode_client.zig");

pub const GamemodeError = error{
RequestFailed,
Expand Down

0 comments on commit 8113ca3

Please sign in to comment.