Expand description
§Interact with the compiler
If you consider ops::cargo_compile::compile as a rustc driver but on
Cargo side, this module is kinda the rustc_interface for that merits.
It contains all the interaction between Cargo and the rustc compiler,
from preparing the context for the entire build process, to scheduling
and executing each unit of work (e.g. running rustc), to managing and
caching the output artifact of a build.
However, it hasn’t yet exposed a clear definition of each phase or session, like what rustc has done1. Also, no one knows if Cargo really needs that. To be pragmatic, here we list a handful of items you may want to learn:
BuildContextis a static context containing all information you need before a build gets started.BuildRunneris the center of the world, coordinating a running build and collecting information from it.- [
custom_build] is the home of build script executions and output parsing. - [
fingerprint] not only defines but also executes a set of rules to determine if a re-compile is needed. - [
job_queue] is where the parallelism, job scheduling, and communication machinery happen between Cargo and the compiler. - [
layout] defines and manages output artifacts of a build in the filesystem. unit_dependenciesis for building a dependency graph for compilation from a result of dependency resolution.Unitcontains sufficient information to build something, usually turning into a compiler invocation in a later phase.
Maybe
-Zbuild-planwas designed to serve that purpose but still in flux. ↩
Modules§
- artifact
- Generate artifact information from unit dependencies for configuring the compiler environment.
- future_
incompat - Support for future-incompatible warning reporting.
- rustdoc
- Utilities for building with rustdoc.
- standard_
lib - Code for building the standard library.
- unit_
dependencies - Constructs the dependency graph for compilation.
- unit_
graph - Serialization of
UnitGraphfor unstable option--unit-graph.
Structs§
- Build
Config - Configuration information for a rustc build.
- Build
Context - The build context, containing complete information needed for a build task before it gets started.
- Build
Output - Contains the parsed output of a custom build script.
- Build
Runner - Collection of all the stuff that is needed to perform a build.
- Build
Script Outputs - Map of packages to build script output.
- Build
Scripts - Linking information for a
Unit. - Compilation
- A structure returning the result of a compilation.
- Compile
Target - Abstraction for the representation of a compilation target that Cargo has.
- Default
Executor - A
DefaultExecutorcalls rustc without doing anything else. It is Cargo’s default behaviour. - Doctest
- Structure with enough information to run
rustdoc --test. - File
Type - Type of each file generated by a Unit.
- Metadata
Metadatatracks severalUnitHashs, includingMetadata::unit_id,Metadata::c_metadata, andMetadata::c_extra_filename.- Rust
DocFingerprint - Structure used to deal with Rustdoc fingerprinting
- Rustc
Target Data - Collection of information about
rustcand the host and target. - Target
Info - Information about the platform target gleaned from querying rustc.
- Unit
- All information needed to define a unit.
- Unit
Hash - Uniquely identify a
Unitunder specific circumstances, seeMetadatafor more. - Unit
Interner - A small structure used to “intern”
Unitvalues. - Unit
Output - Information about the output of a unit.
Enums§
- Compile
Kind - Indicator for how a unit is being compiled.
- Compile
Kind Fallback - Fallback behavior in the
CompileKind::from_requested_targets_with_fallbackfunction when no targets are specified. - Compile
Mode - The specific action to be performed on each
Unitof work. - Crate
Type - Types of the output artifact that the compiler emits. Usually distributable or linkable either statically or dynamically.
- File
Flavor - Kind of each file generated by a Unit, part of
FileType. - Freshness
- Indication of the freshness of a package.
- Library
Path - Represents a path added to the library search path.
- Link
ArgTarget - Represents one of the instructions from
cargo::rustc-link-arg-*build script instruction family. - Lto
- Possible ways to run rustc and request various parts of LTO.
- Message
Format - Timing
Output - Kinds of build timings we can output.
- User
Intent - Represents the high-level operation requested by the user.
Traits§
- Executor
- A glorified callback for executing calls to rustc. Rather than calling rustc
directly, we’ll use an
Executor, giving clients an opportunity to intercept the build calls.
Functions§
- extern_
args - Generates a list of
--externarguments.