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

librustc_codegen_ssa: exported entry function symbol is hardcoded as "main" #57591

Open
Xanewok opened this issue Jan 14, 2019 · 5 comments
Open
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.

Comments

@Xanewok
Copy link
Member

Xanewok commented Jan 14, 2019

Seems suspicious as observed by @Zoxc here.

Could we have in theory something like (or anything else):

#[no_mangle]
#[main]
fn awesome_main() { ... }

which would make this logic wrong?

@michaelwoerister
Copy link
Member

Yes, seems like an oversight.

@Centril Centril added A-codegen Area: Code generation C-bug Category: This is a bug. labels Jan 14, 2019
@steveklabnik
Copy link
Member

Triage; the "here" doesn't link to anything. It's not clear to me what this ticket is about, to be honest.

@Mark-Simulacrum Mark-Simulacrum added the requires-nightly This issue requires a nightly compiler in some way. label May 2, 2020
@Mark-Simulacrum
Copy link
Member

This is about

if tcx.entry_fn(LOCAL_CRATE).is_some() {
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new("main"));
symbols.push((exported_symbol, SymbolExportLevel::C));
}
-- specifically, we presume that if the crate we're compiling has a entry function then we should export the "main" symbol (which might not be what main is actually called).

But I think this is requires-nightly, since you can't rename main on stable AFAIK.

@jonas-schievink
Copy link
Contributor

I wonder if #[main] should be removed in favor of using the export system for this. Then users could use my_custom_main as main; instead.

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented May 2, 2020

I don't really know why you'd want main to not be called main, seems like an odd thing to allow -- and we don't on stable, so there's probably approximately zero users anyway?

Edit: basically I'd be up for removing #[main] entirely personally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests

6 participants