about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-06-11 19:57:47 -0700
committerGitHub <noreply@github.com>2016-06-11 19:57:47 -0700
commit4c45d26a820570509193fcb317775a8e9ad5efb7 (patch)
treea88a47a47f8d50668e811dd64df9e80640b124c5
parent5c2a5d4499376ade0dd6bb30e8c5909abb42e574 (diff)
parent8844fd4e8a3b68aa6497a5a54bae0ad6a1a08ed6 (diff)
downloadrust-4c45d26a820570509193fcb317775a8e9ad5efb7.tar.gz
rust-4c45d26a820570509193fcb317775a8e9ad5efb7.zip
Auto merge of #34132 - AtheMathmo:no-stdlib, r=steveklabnik
Note warning of default features on libc

The default features of libc include libstd. This should be noted on this page.
-rw-r--r--src/doc/book/no-stdlib.md24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/doc/book/no-stdlib.md b/src/doc/book/no-stdlib.md
index 9823a0b6d63..c5c139e6580 100644
--- a/src/doc/book/no-stdlib.md
+++ b/src/doc/book/no-stdlib.md
@@ -12,9 +12,26 @@ don’t want to use the standard library via an attribute: `#![no_std]`.
 > `#![no_std]`](using-rust-without-the-standard-library.html)
 
 Obviously there's more to life than just libraries: one can use
-`#[no_std]` with an executable, controlling the entry point is
-possible in two ways: the `#[start]` attribute, or overriding the
-default shim for the C `main` function with your own.
+`#[no_std]` with an executable.
+
+### 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.11", default-features = false }
+```
+
+Note that the default features have been disabled. This is a critical step -
+**the default features of libc include the standard library and so must be
+disabled.**
+
+### Writing an executable without stdlib
+
+Controlling the entry point is possible in two ways: the `#[start]` attribute,
+or overriding the default shim for the C `main` function with your own.
 
 The function marked `#[start]` is passed the command line parameters
 in the same format as C:
@@ -72,7 +89,6 @@ pub extern fn main(argc: i32, argv: *const *const u8) -> i32 {
 # // fn main() {} tricked you, rustdoc!
 ```
 
-
 The compiler currently makes a few assumptions about symbols which are available
 in the executable to call. Normally these functions are provided by the standard
 library, but without it you must define your own.