Skip to content

Commit e031105

Browse files
authored
Merge pull request #478 from ehuss/fix-start
Remove `#![start]` attribute
2 parents d2c1d5c + 3253190 commit e031105

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

src/beneath-std.md

+3-39
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,10 @@ We will probably need a nightly version of the compiler to produce
3030
a `#![no_std]` executable because on many platforms, we have to provide the
3131
`eh_personality` [lang item], which is unstable.
3232

33-
Controlling the entry point is possible in two ways: the `#[start]` attribute,
34-
or overriding the default shim for the C `main` function with your own.
35-
Additionally, it's required to define a [panic handler function](panic-handler.html).
36-
37-
The function marked `#[start]` is passed the command line parameters
38-
in the same format as C (aside from the exact integer types being used):
39-
40-
```rust
41-
#![feature(start, lang_items, core_intrinsics, rustc_private)]
42-
#![allow(internal_features)]
43-
#![no_std]
33+
You will need to define a symbol for the entry point that is suitable for your target. For example, `main`, `_start`, `WinMain`, or whatever starting point is relevant for your target.
34+
Additionally, you need to use the `#![no_main]` attribute to prevent the compiler from attempting to generate an entry point itself.
4435

45-
// Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
46-
#![feature(panic_unwind)]
47-
extern crate unwind;
48-
49-
// Pull in the system libc library for what crt0.o likely requires.
50-
#[cfg(not(windows))]
51-
extern crate libc;
52-
53-
use core::panic::PanicInfo;
54-
55-
// Entry point for this program.
56-
#[start]
57-
fn main(_argc: isize, _argv: *const *const u8) -> isize {
58-
0
59-
}
60-
61-
// These functions are used by the compiler, but not for an empty program like this.
62-
// They are normally provided by `std`.
63-
#[lang = "eh_personality"]
64-
fn rust_eh_personality() {}
65-
#[panic_handler]
66-
fn panic_handler(_info: &PanicInfo) -> ! { core::intrinsics::abort() }
67-
```
68-
69-
To override the compiler-inserted `main` shim, we have to disable it
70-
with `#![no_main]` and then create the appropriate symbol with the
71-
correct ABI and the correct name, which requires overriding the
72-
compiler's name mangling too:
36+
Additionally, it's required to define a [panic handler function](panic-handler.html).
7337

7438
```rust
7539
#![feature(lang_items, core_intrinsics, rustc_private)]

0 commit comments

Comments
 (0)