-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
errors when targeting uefi #12993
Comments
stage1 code: const LoadedImageProtocol = zig.std.os.uefi.protocols.LoadedImageProtocol;
var this_image: ?*LoadedImageProtocol align(8) = null;
var uefi_status = zig.uefi.system_table.boot_services.?.openProtocol(zig.uefi.handle, &LoadedImageProtocol.guid, @ptrCast(*?*anyopaque, &this_image), zig.uefi.handle, null, zig.uefi.tables.OpenProtocolAttributes{ .by_handle_protocol = true });
if (uefi_status == .Success) {
print("image base: {*}, image size: {}\r\n", .{ this_image.?.image_base, this_image.?.image_size });
} else {
print("Could not obtain current image's info (base, size, etc..): {}", .{uefi_status});
}
if uefi_status is ommited in print("Could not obtain current image's info (base, size, etc..): {}", .{uefi_status}); it compiles fine |
This is due to the change of function pointers in stage2. Solved by #12761 |
that still leaves stage1, it's how i last compiled it successfully ~Aug 15 with a compiler that couldn't have been older than mid June (kicking myself for not being able to provide more specifics) i'll just wait for 12761, feel free to close this one PS, any way to pass -fno-stack-protector to stage1 ? |
No, that PR uses |
i hear you both on stage2, but can you state with certainty that the lack of std.meta.FnPtr is the reason for
|
Apologies, I missed your second post containing that linker error. That needs to be fixed also, meaning the lack of std.meta.FnPtr does not fix this issue. |
edit: zig/lib/std/os/uefi/tables/boot_services.zig Line 194 in 34835bb
and after a simple edit pub const EfiEventNotify = std.meta.FnPtr(fn (event: Event, ctx: *anyopaque) callconv(.C) void); it runs ! ❤️ original comment:
stage2, verbatim> zig build
error: sub-compilation of zig_libc failed
c:\opt\local\lib\zig\std\os\uefi.zig:21:23: error: variable of type '*os.uefi.tables.system_table.SystemTable' must be const or comptime
pub var system_table: *tables.SystemTable = undefined;
^~~~~~~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi\tables\system_table.zig:31:20: note: struct requires comptime because of this field
boot_services: ?*BootServices,
^~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi\tables\boot_services.zig:156:34: note: struct requires comptime because of this field
createEventEx: std.meta.FnPtr(fn (type: u32, notify_tpl: usize, notify_func: EfiEventNotify, notify_ctx: *const anyopaque, event_group: *align(8) const Guid, event: *Event) callconv(.C) Status),
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi\tables\boot_services.zig:156:34: note: function is generic
createEventEx: std.meta.FnPtr(fn (type: u32, notify_tpl: usize, notify_func: EfiEventNotify, notify_ctx: *const anyopaque, event_ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\start.zig:245:33: error: parameter of type '*os.uefi.tables.system_table.SystemTable' must be declared comptime
fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.C) usize {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi.zig:21:23: error: variable of type '*os.uefi.tables.system_table.SystemTable' must be const or comptime
pub var system_table: *tables.SystemTable = undefined;
^~~~~~~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi\tables\system_table.zig:31:20: note: struct requires comptime because of this field
boot_services: ?*BootServices,
^~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi\tables\boot_services.zig:156:34: note: struct requires comptime because of this field
createEventEx: std.meta.FnPtr(fn (type: u32, notify_tpl: usize, notify_func: EfiEventNotify, notify_ctx: *const anyopaque, event_group: *align(8) const Guid, event: *Event) callconv(.C) Status),
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\opt\local\lib\zig\std\os\uefi\tables\boot_services.zig:156:34: note: function is generic
createEventEx: std.meta.FnPtr(fn (type: u32, notify_tpl: usize, notify_func: EfiEventNotify, notify_ctx: *const anyopaque, event_group: *align(8) const Guid, event: *Event) callconv(.C) Status),
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: BOOTX64... stage1> zig build -fstage1
C:\opt\local\lib\zig\std\os\uefi\protocols\simple_text_input_protocol.zig:9:37: error: struct 'std.os.uefi.protocols.simple_text_input_protocol.SimpleTextInputProtocol' depends on itself
pub const SimpleTextInputProtocol = extern struct {
^
C:\opt\local\lib\zig\std\os\uefi\tables\system_table.zig:25:5: note: while checking this field
con_in: ?*SimpleTextInputProtocol,
^
error: BOOTX64... Regards |
It looks like that was mistakenly not part of #12761; my PR covers it though: https://github.com/ziglang/zig/pull/12897/files#diff-a9ae709e3361cc62811e553b8ab0bfa1f58d03ad513de4316a65a3ea46141056R194. |
Given that r00sters91's PR 👍 just landed the fixes to stage2, Thank Yous |
I believe targeting the UEFI is still largely broken because all the structs are still based on old packed struct semantics. Fixing this was originally part of #12897 but it turned out we are more or less missing a language feature now to really fix the UEFI libs, which is what #13009 is for. You can reopen this issue if you want but otherwise I think people will still be aware of the UEFI libs being broken. |
zig version
0.10.0-dev.4192+c75e8f361
target
stage2
The text was updated successfully, but these errors were encountered: