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

When #![no_main] is set, #[start] is silently ignored #124581

Open
RalfJung opened this issue May 1, 2024 · 2 comments
Open

When #![no_main] is set, #[start] is silently ignored #124581

RalfJung opened this issue May 1, 2024 · 2 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

RalfJung commented May 1, 2024

This came up in rust-lang/miri#3498: a user wrote code roughly like this

#![no_main]
#![feature(start)]

#[start]
fn main() {}

and then was surprised that the resulting program didn't have a start function.

The start attribute seems to be entirely ignored, because usually there would be an error that the signature is wrong.

The combination of no_main and the start attribute should probably emit a suitable diagnostic, instead of silently ignoring the attribute.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 1, 2024
@Nilstrieb
Copy link
Member

Nilstrieb commented May 1, 2024

The #[start] attribute should be deleted from the compiler with the tracking issue closed, its existence does not make any sense. So I don't think anyone should put effort into trying to fix this. Deleting #[start] has been something I've wanted to do for a bit now, but haven't gotten to it.

@RalfJung
Copy link
Member Author

RalfJung commented May 1, 2024

Ah, I see. In that case Miri probably needs to gain some other mechanism to be able to run no_std binaries. Something like what I sketched here.

@Nilstrieb Nilstrieb added C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants