Skip to content

Commit 3de1d4e

Browse files
committed
Remove #![start] attribute
The `#![start]` attribute has been removed in rust-lang/rust#134299.
1 parent d2c1d5c commit 3de1d4e

File tree

1 file changed

+2
-39
lines changed

1 file changed

+2
-39
lines changed

src/beneath-std.md

+2-39
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,9 @@ 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. Additionally, we use the `#![no_main]` attribute to override the compiler-inserted `main` shim.
4434

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:
35+
Additionally, it's required to define a [panic handler function](panic-handler.html).
7336

7437
```rust
7538
#![feature(lang_items, core_intrinsics, rustc_private)]

0 commit comments

Comments
 (0)