Skip to content

Commit

Permalink
Pin to Zig 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Oct 21, 2024
1 parent 1547173 commit 15adb1b
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 76 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: mlugg/setup-zig@v1
with:
version: master
version: 0.13.0
- run: zig version
- run: zig fmt --check src
- run: zig build test -Dhas-static -Dhas-zig -Dhas-objc-msgsend-stubs
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v3
- uses: mlugg/setup-zig@v1
with:
version: master
version: 0.13.0
- uses: ilammy/msvc-dev-cmd@v1
- run: zig version
- run: zig fmt --check src
Expand All @@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v3
- uses: mlugg/setup-zig@v1
with:
version: master
version: 0.13.0
- run: sudo apt-get install -y musl-tools
- run: zig version
- run: CC=musl-gcc zig build test -Dhas-static -Dmusl
Expand All @@ -53,7 +53,7 @@ jobs:
- uses: actions/checkout@v3
- uses: mlugg/setup-zig@v1
with:
version: master
version: 0.13.0
- run: sudo apt-get install -y clang
- run: zig version
- run: CC=clang zig build test -Dhas-static -Dsystem-compiler=clang
3 changes: 1 addition & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ const CreateSymlinksStep = struct {
return self;
}

fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) anyerror!void {
const prog_node = options.progress_node;
fn make(step: *std.Build.Step, prog_node: std.Progress.Node) anyerror!void {
const self: *CreateSymlinksStep = @fieldParentPtr("step", step);
const install_path = self.install.artifact.getEmittedBin().getPath(self.builder);
const rel_source = fs.path.basename(install_path);
Expand Down
8 changes: 4 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

.dependencies = .{
.@"zig-yaml" = .{
.url = "https://github.com/kubkon/zig-yaml/archive/a551d00ab041f4799420ab224cdc3efdf978092c.tar.gz",
.hash = "12208398e1393f83a39d03f3ef4893607650b6227dc7f1eee3db4d163fbc2c0c37ca",
.url = "https://github.com/kubkon/zig-yaml/archive/325dbdd276604dccf184c32fef9600b0ac48343d.tar.gz",
.hash = "1220e8870ca83e47b98807e89b5b636072413f6c09f9b26037e4c98c55e4960ac55a",
},
.@"zig-dis-x86_64" = .{
.url = "https://github.com/kubkon/zig-dis-x86_64/archive/53b2e2dae9e824d7b4994e767c2cbb4f39e443a9.tar.gz",
.hash = "1220f2b9588352067d5b6f3b68d5461cea52f4425c9144f6757db775cf2f19cb5d26",
.url = "https://github.com/kubkon/zig-dis-x86_64/archive/5203b9affc5045e000ae7963d988e155e98e396d.tar.gz",
.hash = "12207252f0592e53e8794d5a41409791d5c8c70e0de67bfba48844406619847cc971",
},
},

Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
devShells.default = pkgs.stdenvNoCC.mkDerivation {
name = "emerald";
nativeBuildInputs = with pkgs; [
zigpkgs.master-2024-10-08
zigpkgs."0.13.0"
zlspkgs.default
];
};
Expand Down
14 changes: 7 additions & 7 deletions src/Coff.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1293,14 +1293,14 @@ fn writeHeader(self: *Coff) !void {

pub fn isCoffObj(buffer: *const [@sizeOf(coff.CoffHeader)]u8) bool {
const header = @as(*align(1) const coff.CoffHeader, @ptrCast(buffer)).*;
if (header.machine == .UNKNOWN and header.number_of_sections == 0xffff) return false;
if (header.machine == .Unknown and header.number_of_sections == 0xffff) return false;
if (header.size_of_optional_header != 0) return false;
return true;
}

pub fn isImportLib(buffer: *const [@sizeOf(coff.ImportHeader)]u8) bool {
const header = @as(*align(1) const coff.ImportHeader, @ptrCast(buffer)).*;
return header.sig1 == .UNKNOWN and header.sig2 == 0xffff;
return header.sig1 == .Unknown and header.sig2 == 0xffff;
}

pub fn isArchive(data: *const [Archive.magic.len]u8) bool {
Expand Down Expand Up @@ -1502,14 +1502,14 @@ pub fn getSymbol(self: *Coff, index: Symbol.Index) *Symbol {
}

pub fn addSymbolExtra(self: *Coff, extra: Symbol.Extra) !u32 {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
try self.symbols_extra.ensureUnusedCapacity(self.base.allocator, fields.len);
return self.addSymbolExtraAssumeCapacity(extra);
}

pub fn addSymbolExtraAssumeCapacity(self: *Coff, extra: Symbol.Extra) u32 {
const index = @as(u32, @intCast(self.symbols_extra.items.len));
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields) |field| {
self.symbols_extra.appendAssumeCapacity(switch (field.type) {
u32 => @field(extra, field.name),
Expand All @@ -1521,7 +1521,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *Coff, extra: Symbol.Extra) u32 {

pub fn getSymbolExtra(self: Coff, index: u32) ?Symbol.Extra {
if (index == 0) return null;
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
var i: usize = index;
var result: Symbol.Extra = undefined;
inline for (fields) |field| {
Expand All @@ -1536,7 +1536,7 @@ pub fn getSymbolExtra(self: Coff, index: u32) ?Symbol.Extra {

pub fn setSymbolExtra(self: *Coff, index: u32, extra: Symbol.Extra) void {
assert(index > 0);
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields, 0..) |field, i| {
self.symbols_extra.items[index + i] = switch (field.type) {
u32 => @field(extra, field.name),
Expand Down Expand Up @@ -1645,7 +1645,7 @@ fn formatSectionFlags(
) !void {
_ = options;
_ = unused_fmt_string;
inline for (@typeInfo(coff.SectionHeaderFlags).@"struct".fields) |field| {
inline for (@typeInfo(coff.SectionHeaderFlags).Struct.fields) |field| {
if (@field(flags, field.name) == 0b1) {
try writer.writeAll(field.name ++ " ");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Coff/Symbol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, coff_file: *Coff) !void {
symbol.extra = try coff_file.addSymbolExtra(.{});
}
var extra = symbol.getExtra(coff_file).?;
inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {
if (@field(opts, field.name)) |x| {
@field(extra, field.name) = x;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ resolver: SymbolResolver = .{},
undefs: std.AutoArrayHashMapUnmanaged(SymbolResolver.Index, std.ArrayListUnmanaged(Ref)) = .{},
dupes: std.AutoArrayHashMapUnmanaged(SymbolResolver.Index, std.ArrayListUnmanaged(File.Index)) = .{},

shstrtab: std.ArrayListUnmanaged(u8) = .empty,
shstrtab: std.ArrayListUnmanaged(u8) = .{},
symtab: std.ArrayListUnmanaged(elf.Elf64_Sym) = .{},
strtab: std.ArrayListUnmanaged(u8) = .empty,
strtab: std.ArrayListUnmanaged(u8) = .{},
dynsym: DynsymSection = .{},
dynstrtab: std.ArrayListUnmanaged(u8) = .empty,
dynstrtab: std.ArrayListUnmanaged(u8) = .{},
versym: std.ArrayListUnmanaged(elf.Elf64_Versym) = .{},
verneed: VerneedSection = .{},

Expand Down
2 changes: 1 addition & 1 deletion src/Elf/Atom.zig
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const AddExtraOpts = struct {
pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) void {
const object = atom.getObject(elf_file);
var extras = object.getAtomExtra(atom.extra);
inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {
if (@field(opts, field.name)) |x| {
@field(extras, field.name) = x;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Elf/InternalObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ fn addSymbolAssumeCapacity(self: *InternalObject) Symbol.Index {
}

pub fn addSymbolExtra(self: *InternalObject, allocator: Allocator, extra: Symbol.Extra) !u32 {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
return self.addSymbolExtraAssumeCapacity(extra);
}

pub fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32 {
const index = @as(u32, @intCast(self.symbols_extra.items.len));
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields) |field| {
self.symbols_extra.appendAssumeCapacity(switch (field.type) {
u32 => @field(extra, field.name),
Expand All @@ -417,7 +417,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra)
}

pub fn getSymbolExtra(self: *InternalObject, index: u32) Symbol.Extra {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
var i: usize = index;
var result: Symbol.Extra = undefined;
inline for (fields) |field| {
Expand All @@ -431,7 +431,7 @@ pub fn getSymbolExtra(self: *InternalObject, index: u32) Symbol.Extra {
}

pub fn setSymbolExtra(self: *InternalObject, index: u32, extra: Symbol.Extra) void {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields, 0..) |field, i| {
self.symbols_extra.items[index + i] = switch (field.type) {
u32 => @field(extra, field.name),
Expand Down
2 changes: 1 addition & 1 deletion src/Elf/LdScript.zig
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const Command = enum {
as_needed,

fn fromString(s: []const u8) ?Command {
inline for (@typeInfo(Command).@"enum".fields) |field| {
inline for (@typeInfo(Command).Enum.fields) |field| {
const upper_name = n: {
comptime var buf: [field.name.len]u8 = undefined;
inline for (field.name, 0..) |c, i| {
Expand Down
16 changes: 8 additions & 8 deletions src/Elf/Object.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,14 @@ fn addSymbolAssumeCapacity(self: *Object) Symbol.Index {
}

pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
return self.addSymbolExtraAssumeCapacity(extra);
}

pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {
const index = @as(u32, @intCast(self.symbols_extra.items.len));
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields) |field| {
self.symbols_extra.appendAssumeCapacity(switch (field.type) {
u32 => @field(extra, field.name),
Expand All @@ -1056,7 +1056,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {
}

pub fn getSymbolExtra(self: *Object, index: u32) Symbol.Extra {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
var i: usize = index;
var result: Symbol.Extra = undefined;
inline for (fields) |field| {
Expand All @@ -1070,7 +1070,7 @@ pub fn getSymbolExtra(self: *Object, index: u32) Symbol.Extra {
}

pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields, 0..) |field, i| {
self.symbols_extra.items[index + i] = switch (field.type) {
u32 => @field(extra, field.name),
Expand Down Expand Up @@ -1149,14 +1149,14 @@ pub fn getAtom(self: *Object, atom_index: Atom.Index) ?*Atom {
}

pub fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 {
const fields = @typeInfo(Atom.Extra).@"struct".fields;
const fields = @typeInfo(Atom.Extra).Struct.fields;
try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);
return self.addAtomExtraAssumeCapacity(extra);
}

pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {
const index = @as(u32, @intCast(self.atoms_extra.items.len));
const fields = @typeInfo(Atom.Extra).@"struct".fields;
const fields = @typeInfo(Atom.Extra).Struct.fields;
inline for (fields) |field| {
self.atoms_extra.appendAssumeCapacity(switch (field.type) {
u32 => @field(extra, field.name),
Expand All @@ -1167,7 +1167,7 @@ pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {
}

pub fn getAtomExtra(self: *Object, index: u32) Atom.Extra {
const fields = @typeInfo(Atom.Extra).@"struct".fields;
const fields = @typeInfo(Atom.Extra).Struct.fields;
var i: usize = index;
var result: Atom.Extra = undefined;
inline for (fields) |field| {
Expand All @@ -1181,7 +1181,7 @@ pub fn getAtomExtra(self: *Object, index: u32) Atom.Extra {
}

pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void {
const fields = @typeInfo(Atom.Extra).@"struct".fields;
const fields = @typeInfo(Atom.Extra).Struct.fields;
inline for (fields, 0..) |field, i| {
self.atoms_extra.items[index + i] = switch (field.type) {
u32 => @field(extra, field.name),
Expand Down
16 changes: 8 additions & 8 deletions src/Elf/SharedObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ strtab: std.ArrayListUnmanaged(u8) = .{},
versyms: std.ArrayListUnmanaged(elf.Elf64_Versym) = .{},
verstrings: std.ArrayListUnmanaged(u32) = .{},

symbols: std.ArrayListUnmanaged(Symbol) = .empty,
symbols_extra: std.ArrayListUnmanaged(u32) = .empty,
symbols_resolver: std.ArrayListUnmanaged(Elf.SymbolResolver.Index) = .empty,
symbols: std.ArrayListUnmanaged(Symbol) = .{},
symbols_extra: std.ArrayListUnmanaged(u32) = .{},
symbols_resolver: std.ArrayListUnmanaged(Elf.SymbolResolver.Index) = .{},

aliases: ?std.ArrayListUnmanaged(u32) = null,
dynamic_table: std.ArrayListUnmanaged(elf.Elf64_Dyn) = .empty,
dynamic_table: std.ArrayListUnmanaged(elf.Elf64_Dyn) = .{},

needed: bool,
alive: bool,
Expand Down Expand Up @@ -420,14 +420,14 @@ fn addSymbolAssumeCapacity(self: *SharedObject) Symbol.Index {
}

pub fn addSymbolExtra(self: *SharedObject, allocator: Allocator, extra: Symbol.Extra) !u32 {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
return self.addSymbolExtraAssumeCapacity(extra);
}

pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u32 {
const index = @as(u32, @intCast(self.symbols_extra.items.len));
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields) |field| {
self.symbols_extra.appendAssumeCapacity(switch (field.type) {
u32 => @field(extra, field.name),
Expand All @@ -438,7 +438,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u3
}

pub fn getSymbolExtra(self: *SharedObject, index: u32) Symbol.Extra {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
var i: usize = index;
var result: Symbol.Extra = undefined;
inline for (fields) |field| {
Expand All @@ -452,7 +452,7 @@ pub fn getSymbolExtra(self: *SharedObject, index: u32) Symbol.Extra {
}

pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void {
const fields = @typeInfo(Symbol.Extra).@"struct".fields;
const fields = @typeInfo(Symbol.Extra).Struct.fields;
inline for (fields, 0..) |field, i| {
self.symbols_extra.items[index + i] = switch (field.type) {
u32 => @field(extra, field.name),
Expand Down
2 changes: 1 addition & 1 deletion src/Elf/Symbol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const AddExtraOpts = struct {

pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, elf_file: *Elf) void {
var extra = symbol.getExtra(elf_file);
inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {
if (@field(opts, field.name)) |x| {
@field(extra, field.name) = x;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Elf/Thunk.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
value: i64 = 0,
out_shndx: u32 = 0,
symbols: std.AutoArrayHashMapUnmanaged(Elf.Ref, void) = .empty,
symbols: std.AutoArrayHashMapUnmanaged(Elf.Ref, void) = .{},
output_symtab_ctx: Elf.SymtabCtx = .{},

pub fn deinit(thunk: *Thunk, allocator: Allocator) void {
Expand Down
4 changes: 2 additions & 2 deletions src/Elf/merge_section.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub const MergeSection = struct {
IndexContext,
std.hash_map.default_max_load_percentage,
) = .{},
subsections: std.ArrayListUnmanaged(MergeSubsection) = .empty,
finalized_subsections: std.ArrayListUnmanaged(MergeSubsection.Index) = .empty,
subsections: std.ArrayListUnmanaged(MergeSubsection) = .{},
finalized_subsections: std.ArrayListUnmanaged(MergeSubsection.Index) = .{},

pub fn deinit(msec: *MergeSection, allocator: Allocator) void {
msec.bytes.deinit(allocator);
Expand Down
2 changes: 1 addition & 1 deletion src/MachO/Atom.zig
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const AddExtraOpts = struct {
pub fn addExtra(atom: *Atom, opts: AddExtraOpts, macho_file: *MachO) void {
const file = atom.getFile(macho_file);
var extra = file.getAtomExtra(atom.extra);
inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {
if (@field(opts, field.name)) |x| {
@field(extra, field.name) = x;
}
Expand Down
Loading

0 comments on commit 15adb1b

Please sign in to comment.