-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking issue for the start
feature
#29633
Comments
I believe the semantics of this today are that the compiler will generate a function with the symbol The signature for this function is also |
On Windows the executable entry point does not take any arguments. Currently we let the CRT act as the executable entry point which then calls our Rust entry wrapper which invokes the start function which is either |
html5ever uses in an ugly hack that overrides the This would be better solved by some way to override the test harness used by |
@SimonSapin the use case for that with Cargo should in theory be |
The Is there a tracking issue for |
Oh that's already implemented today, if a test target is listed as (this may be a bit off-topic from |
The current signature for the lang item is fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize { which is called by a generated main function. Instead, the signatures of both should be arbitrary and the symbols translate to |
Note that on windows it really shouldn't always be |
#20064 suggests that the signature here is wrong, we should consider this before making this feature stable. |
Just to clarify, it's not just a question of what signature
Of course this would be an easy fix. |
Just don't stabilize this until consideration is taken for subsystems, which change the entry point completely from |
Entry point name is irrelevant for windows apps actually. Ability to specify subsystem is one of important things to create application, because most of them are gui with "windows" subsystem. |
Fix native main() signature on 64bit Hello, in LLVM-IR produced by rustc on x86_64-linux-gnu, the native main() function had incorrect types for the function result and argc parameter: i64, while it should be i32 (really c_int). See also #20064, #29633. So I've attempted a fix here. I tested it by checking the LLVM IR produced with --target x86_64-unknown-linux-gnu and i686-unknown-linux-gnu. Also I tried running the tests (`./x.py test`), however I'm getting two failures with and without the patch, which I'm guessing is unrelated.
Pinging this thread since it seems inactive. I wanted to express interest in this feature being stabilized. I was really excited when I discovered that you could replace the entry point in Rust, and then real bummed when I found out that you could only do it on nightly. |
It's also necessary to write #![no_std] programs. |
I would expect |
Speaking of which… is there any reason for this? We could make a version of Personally, instead of offering |
@glandium The binary entry point is completely different from @clarcharr Adding some form of |
I've just been using I just define my main function with |
@retep998 Oh, I didn't know that. I think that in that case, it makes sense to simply have a That was initially the idea but I didn't realise how windows did things. |
Indeed, it surprisingly works on linux, mac and even windows, with a |
#![no_main]
#[no_mangle]
pub fn main(args: Vec<String>) {
for arg in args {
println!("{}", arg);
}
} |
The current signature for |
10066: ANN: Add support for E0131, E0197, E0203 r=vlad20012 a=kuksag <!-- Hello and thank you for the pull request! We don't have any strict rules about pull requests, but you might check https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md for some hints! Also, please write a short description explaining your change in the following format: `changelog: %description%` This description will help a lot to create release changelog. Drop these lines for internal only changes :) --> changelog: * Add support for E0131 Error code reference: https://doc.rust-lang.org/error_codes/E0131.html There's a feature that might be connected to this error code: rust-lang/rust#29633 * Add support for E0197 Error code reference: https://doc.rust-lang.org/error_codes/E0197.html * Add support for E0203 Error code reference: https://doc.rust-lang.org/error_codes/E0203.html Compiler implementation: https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_analysis/src/astconv/mod.rs#L877 Co-authored-by: kuksag <georgiy.kuksa@gmail.com>
From the original post:
Has anyone actually used this successfully for the purpose stated above? From my testing (using bare-metal targets), it doesn't seem to define the entry point at all. It silences the following error: "error: requires What advantage does this (as currently implemented) even provide over using |
It defines the |
So, if I understand you correctly, you're saying that the description of this feature is wrong — that it was never intended to override the entry point at all, but to override the Also, if it's meant to be called from the CRT, shouldn't it require an |
Rustc actually won't rename the function annotated with |
That still makes wording like "indicates a function should be used as the entry point" ambiguous at best, and very confusing (as can be seen in previous discussions in this tracking issue). My suggestion, now that I understand what this feature is really intended for, is simply that the description of this feature needs to be clarified.
As far as I understand, Windows still has an entry point equivalent to
Ah, I see. |
I think this issue should be closed and I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple:
Note that this feature has not been RFCed in the first place. |
Miri currently relies on |
Lang-nominated for the proposal in #29633 (comment) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
With rust-lang/miri#3769, Miri now has a way to run no_std binaries that does not rely on this feature. So from our perspective it would be fine to remove this. :) |
Ralf posted #134299 to remove it and nominated it, so removing the nomination here. |
Tracking issue for
#[start]
, which indicates that a function should be used as the entry point, overriding the "start" language item. In general this forgoes a bit of runtime setup that's normally run before and after main.Open questions
The text was updated successfully, but these errors were encountered: