Skip to content

a lightweight standard library for rust with freestanding support (deprecated in favour of libcore upstream)

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

akiradeveloper/rust-core

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Configuration

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

Building

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

Macros

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

#[feature(phase)];
#[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

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

About

a lightweight standard library for rust with freestanding support (deprecated in favour of libcore upstream)

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published