a lightweight standard library for rust with freestanding support (deprecated in favour of libcore upstream)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A lightweight standard library for Rust with freestanding support. It provides a baseline level of functionality without any external dependencies, and an extended set of features in a traditional hosted environment.


  • --cfg libc to enable features depending on a C standard library implementation
  • --cfg debug to enable debugging features (assertions)


Currently, building to bytecode with --emit-llvm and then compiling/linking with clang is required because the Rust compiler cannot build code without the requirement for segmented stack support from the runtime. There is also no way to avoid position independent code and linking against the runtime without making use of clang.

rustc --cfg libc core/lib.rs --out-dir . -O -Z no-landing-pads
rustc --emit=bc example.rs -O -Z no-landing-pads -L .
clang -O2 -flto -o example example.bc


Importing macros from crates is currently feature gated. If you wish to load macros in addition to normal linkage, use the following attributes:

#[phase(syntax, link)]
extern crate core;

Freestanding usage

For freestanding use, simply omit the libc configuration switch.

LLVM will emit calls to memcpy, memmove and memset. The support.rs module provides these functions, and must be compiled with rustc --crate-type=lib --emit=bc -C passes=inline and then linked against the bytecode for the main module with clang -flto -O2 main.bc support.bc.

The inline pass must be run separately to due to issue #10116 or LLVM will generate infinitely recursive functions.

Stack safety

Ideally, stack safety is provided with one or more guard pages and compiler support for inserting checks based on awareness of the guard pages. GCC has this as -fcheck-stack but LLVM is missing the feature.

At the moment, core only has OS-provided guard pages without the necessary checks on frames larger than the guard size.

Rust's standard library provides stack safety via LLVM's segmented stack support, but this has a negative performance and code size impact. It's also unavailable without the Rust runtime.


Allocators are not yet included due to language deficiencies. See issue #31 for details.