Skip to content

expose the root source file with @import("root") #2189

@andrewrk

Description

@andrewrk

We already rely on this behavior in bootstrap.zig but it is special magic:

const root = @import("@root");

This proposal would make it always available and so the above code would not be special magic anymore.

It's reasonable for userland libraries to have global configuration and use the root source file for that. For example this would be a necessary component of #1778.

This, along with #1439 would allow us to move some of the global panic function magic to userland, and potentially even the startup code. build-exe would unconditionally include the startup code, which would have a comptime block which examines the root source file for main, _start, etc, and determines what it should export.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions