diff --git a/src/beneath-std.md b/src/beneath-std.md index 02a02bd7..dd7e56d9 100644 --- a/src/beneath-std.md +++ b/src/beneath-std.md @@ -4,23 +4,6 @@ This section documents features that are normally provided by the `std` crate an that `#![no_std]` developers have to deal with (i.e. provide) to build `#![no_std]` binary crates. -## Using `libc` - -In order to build a `#[no_std]` executable we will need `libc` as a dependency. -We can specify this using our `Cargo.toml` file: - -```toml -[dependencies] -libc = { version = "0.2.146", default-features = false } -``` - -Note that the default features have been disabled. This is a critical step - -**the default features of `libc` include the `std` crate and so must be -disabled.** - -Alternatively, we can use the unstable `rustc_private` private feature together -with an `extern crate libc;` declaration as shown in the examples below. - ## Writing an executable without `std` We will probably need a nightly version of the compiler to produce @@ -35,7 +18,7 @@ The function marked `#[start]` is passed the command line parameters in the same format as C (aside from the exact integer types being used): ```rust -#![feature(start, lang_items, core_intrinsics, rustc_private)] +#![feature(start, lang_items, core_intrinsics)] #![allow(internal_features)] #![no_std] @@ -43,9 +26,6 @@ in the same format as C (aside from the exact integer types being used): #![feature(panic_unwind)] extern crate unwind; -// Pull in the system libc library for what crt0.o likely requires. -extern crate libc; - use core::panic::PanicInfo; // Entry point for this program. @@ -68,7 +48,7 @@ correct ABI and the correct name, which requires overriding the compiler's name mangling too: ```rust -#![feature(lang_items, core_intrinsics, rustc_private)] +#![feature(lang_items, core_intrinsics)] #![allow(internal_features)] #![no_std] #![no_main] @@ -77,9 +57,6 @@ compiler's name mangling too: #![feature(panic_unwind)] extern crate unwind; -// Pull in the system libc library for what crt0.o likely requires. -extern crate libc; - use core::ffi::{c_char, c_int}; use core::panic::PanicInfo;