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

Allow passing a custom os package to std #10392

Open
MasterQ32 opened this issue Dec 22, 2021 · 3 comments
Open

Allow passing a custom os package to std #10392

MasterQ32 opened this issue Dec 22, 2021 · 3 comments
Labels
os-bring-your-own The "Bring Your Own Operating System" abstraction layer proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@MasterQ32
Copy link
Contributor

MasterQ32 commented Dec 22, 2021

While working on microzig, we got the following question:

How do we solve the startup problem? std/start.zig isn't made for custom OSes and forcing the user to type a pub const panic = microzig.panic; in each project is just boilerplate.

Therefore, i propose that zig can take a new command line argument --other-os-implementation which will provide a package definition os to std that can supplement the OS functions and startup code for any target that compiles for .os_tag = .other. This package should be able to have other packages as dependencies.

This allows us to write code with microzig that just looks like any other zig project:

const std = @import("std");

pub fn main() !void {
  std.log.info("Hello, World!\n", .{});
}

Related issues:

@MasterQ32 MasterQ32 added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Dec 22, 2021
@andrewrk andrewrk added this to the 0.11.0 milestone Dec 22, 2021
@andrewrk andrewrk added standard library This issue involves writing Zig code for the standard library. os-bring-your-own The "Bring Your Own Operating System" abstraction layer labels Dec 22, 2021
@sengir
Copy link
Contributor

sengir commented Dec 23, 2021

What about the semi-existing mechanism of root.os? Should this be deprecated in favor of your proposal or should root.os be expanded upon and standardized instead?

@marler8997
Copy link
Contributor

Also related, made this issue when I was exploring GameboyAdvance development: #8508

@MasterQ32
Copy link
Contributor Author

What about the semi-existing mechanism of root.os? Should this be deprecated in favor of your proposal or should root.os be expanded upon and standardized instead?

This behaviour would be deprecated, as root.os is a workaround for adding a posixy replacement layer. The problem is that not every OS works like this and i think we should go to some higher abstraction than POSIX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os-bring-your-own The "Bring Your Own Operating System" abstraction layer proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

4 participants