-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Attribute to allow naming the entry point something other than main
#4207
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
Comments
How about a function attribute instead:
|
Yeah, that also would be a good option. |
This will require some refactoring to clean up the way rustc deals with main, but should otherwise be straightforward. There are primarily two passes that deal with Resolve is currently responsible for locating the main function and putting a reference to it into the compilation session, so other passes may know the main function. This is used, for example, by the type checker to verify that main has the correct signature. Trans is currently responsible for generating some wrappers around the main function necessary to start up the runtime. Trans also is (incorrectly) responsible for the check that there is only a single main function (test here). Notably, trans does not use the information about main that is generated by resolve - it duplicates the search for the main function. Here's how I suggest this be fixed:
It's not clear to me whether the presence of a The 'test' pass, that generates a binary for running |
@graydon Pinging you to see if you agree. |
@ILyoan do you need to be able to compile the same codebase using different main functions, or do you simply need |
@brson |
Attribute is best, I agree. Goal is to keep anything required for a build expressed in-code, command line options only for adjusting build flavours. |
Changed the title to reflect the preferred solution. |
Guess this issue should be closed now since it's fixed in incoming. |
How about we add a new command line option to change the entry point from "fn main()" to another?
for example
$ rustc a.rs --entry=myEntry
The text was updated successfully, but these errors were encountered: