Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zig workaround: don't use packed structs larger than 128 bits. #532

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions deps/zig/codegen/x86_64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,21 @@ pub const Encoder = struct {

/// Directly write a number to the code array with big endianness
pub fn writeIntBig(self: Self, comptime T: type, value: T) void {
mem.writeIntBig(
mem.writeInt(
T,
self.code.addManyAsArrayAssumeCapacity(@divExact(@typeInfo(T).Int.bits, 8)),
value,
.big,
);
}

/// Directly write a number to the code array with little endianness
pub fn writeIntLittle(self: Self, comptime T: type, value: T) void {
mem.writeIntLittle(
mem.writeInt(
T,
self.code.addManyAsArrayAssumeCapacity(@divExact(@typeInfo(T).Int.bits, 8)),
value,
.little,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ pub fn generateBuiltinMacros(comp: *Compilation) !Source {
\\#define __ORDER_PDP_ENDIAN__ 3412
\\
);
if (comp.target.cpu.arch.endian() == .Little) try w.writeAll(
if (comp.target.cpu.arch.endian() == .little) try w.writeAll(
\\#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
\\#define __LITTLE_ENDIAN__ 1
\\
Expand Down
5 changes: 2 additions & 3 deletions src/Diagnostics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ pub const Message = struct {

pub const Tag = std.meta.DeclEnum(messages);

// u4 to avoid any possible packed struct issues
pub const Kind = enum(u4) { @"fatal error", @"error", note, warning, off, default };
pub const Kind = enum { @"fatal error", @"error", note, warning, off, default };

pub const Options = packed struct {
pub const Options = struct {
// do not directly use these, instead add `const NAME = true;`
all: Kind = .default,
extra: Kind = .default,
Expand Down
2 changes: 1 addition & 1 deletion src/object/Elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Symbol = struct {
info: u8,
};

const Relocation = packed struct {
const Relocation = struct {
symbol: *Symbol,
addend: i64,
offset: u48,
Expand Down
4 changes: 2 additions & 2 deletions src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ pub fn ldEmulationOption(target: std.Target, arm_endianness: ?std.builtin.Endian
.thumb,
.thumbeb,
=> switch (arm_endianness orelse target.cpu.arch.endian()) {
.Little => "armelf_linux_eabi",
.Big => "armelfb_linux_eabi",
.little => "armelf_linux_eabi",
.big => "armelfb_linux_eabi",
},
.aarch64 => "aarch64linux",
.aarch64_be => "aarch64linuxb",
Expand Down
Loading