Skip to main content

Crate cargo_libc

Crate cargo_libc 

Source
Expand description

cargo-libc: build Rust programs for an older glibc.

cargo-libc is a Cargo subcommand, cargo libc. It builds x86_64 Linux programs on a current machine for a glibc release you choose, 2.17 through 2.44. It links against exactly what that release defines, checks the executables’ requirements, and runs tests under a simulation of the target’s kernel.

cargo libc build --target x86_64-unknown-linux-gnu.2.17 \
  --artifact target/x86_64-unknown-linux-gnu/release/myapp -- --release

Install it with cargo install cargo-libc --locked, and read how to use it in the user guide and the README.

§The library

This library is the implementation of cargo-libc’s five executables, and is not meant to be used directly. Its public items are their entry points:

ExecutableEntry pointRole
cargo-libccli::runThe cargo libc command
libc-linkertoolchain::run_linkerThe linker Cargo calls for target units
libc-runnersimulate::run_programCargo’s target runner for test and run
libc-cccc::run with cc::Language::CThe C compiler for the cc crate and CMake
libc-cxxcc::run with cc::Language::CxxThe C++ compiler: host units only

To use provider preparation or ELF scanning from your own code, depend on libc-abi-tools and linux-abi-scan.

Modules§

cc
Compiler wrappers for C dependencies (libc-cc, and libc-cxx to refuse C++).
cli
The cargo-libc command line: cargo libc <command>, parsed and run.
simulate
Tier 2: cargo libc test and cargo libc run execute each target binary through the libc-runner helper, which Cargo calls as its target runner.
toolchain
Toolchain selection and the Cargo commands that use it, and libc-linker, the linker Cargo calls for target units.