talira

Compile C, C++, assembly and CUDA from Cargo build scripts

open sourceMIT OR Apache-2.0free

cc (cc-rs) is a Rust library for Cargo build scripts that compiles a set of C, C++, assembly or CUDA files into a static archive, which Cargo then links into the crate being built. It doesn't compile code itself: it calls the platform's default compiler, and it detects cross compilation and the usual compiler environment variables so the same build script works across targets. It is maintained under the Rust project's GitHub organisation.

Problems it solves

  • compile some C code into my Rust crate from a build script
  • link a bundled C library into a Rust crate so it builds on every target
  • cross-compile the C parts of a Rust project without hand-written makefiles

Features

  • Compiles C, C++, assembly and CUDA files into a static archive from build.rs
  • Calls the platform's default compiler rather than bundling one
  • Detects cross compilation and compiler environment variables automatically
  • Optional jobserver support for parallel compilation

Alternatives

The same job

These do what cc does.

  1. cmake (Rust crate) Run CMake from a Rust build script to compile a native library

Compare cc with the top 3