-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsA-syntaxextArea: Syntax extensionsArea: Syntax extensionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
Right now the compiler writes main as a wrapper that magically obtains the pointer to the Rust main function and to the crate map, then calls the runtime start function. Imagine something like:
fn _rust_main(argc: int, argv: **i8) {
// note neither `get_main` or `get_crate_map` actually exist
rt::start(get_main(), argc, argv, get_crate_map());
}
There are several reasons why this is not the best arrangement. One impact of this is that our most basic entry point, start, takes a third crate_map argument that must be supplied before main.
We could turn this logic into a syntax extension, making the only real entry point start, taking argc and argv (types tbd).
- Make a way to retrieve the crate map at runtime, either an intrinsic (for now) or by some other mechanism once logging becomes a syntax extension.
- Add a syntax extension that looks for either
mainor#[main]and, if it finds it, add a wrapper function,#[start] __start. - Later passes look only for
#[start]. - Trans generates the minimal code to call
#[start].
Related #3309
Metadata
Metadata
Assignees
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsA-syntaxextArea: Syntax extensionsArea: Syntax extensionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.