Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ impl StaleItem {
///
/// Information like file modification time is only calculated for path
/// dependencies.
#[tracing::instrument(skip_all)]
fn calculate(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResult<Arc<Fingerprint>> {
// This function is slammed quite a lot, so the result is memoized.
if let Some(s) = build_runner.fingerprints.get(unit) {
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ fn make_failed_scrape_diagnostic(
}

/// Creates a unit of work invoking `rustc` for building the `unit`.
#[tracing::instrument(skip_all)]
fn rustc(
build_runner: &mut BuildRunner<'_, '_>,
unit: &Unit,
Expand Down Expand Up @@ -818,6 +819,7 @@ where
/// This builds a static view of the invocation. Flags depending on the
/// completion of other units will be added later in runtime, such as flags
/// from build scripts.
#[tracing::instrument(skip_all)]
fn prepare_rustc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResult<ProcessBuilder> {
let gctx = build_runner.bcx.gctx;
let is_primary = build_runner.is_primary_package(unit);
Expand Down Expand Up @@ -894,6 +896,7 @@ fn prepare_rustc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResult
/// This builds a static view of the invocation. Flags depending on the
/// completion of other units will be added later in runtime, such as flags
/// from build scripts.
#[tracing::instrument(skip_all)]
fn prepare_rustdoc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResult<ProcessBuilder> {
let bcx = build_runner.bcx;
// script_metadata is not needed here, it is only for tests.
Expand Down Expand Up @@ -1035,6 +1038,7 @@ fn prepare_rustdoc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResu
}

/// Creates a unit of work invoking `rustdoc` for documenting the `unit`.
#[tracing::instrument(skip_all)]
fn rustdoc(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResult<Work> {
let mut rustdoc = prepare_rustdoc(build_runner, unit)?;

Expand Down Expand Up @@ -1803,6 +1807,7 @@ fn add_custom_flags(
}

/// Generate a list of `-L` arguments
#[tracing::instrument(skip_all)]
pub fn lib_search_paths(
build_runner: &BuildRunner<'_, '_>,
unit: &Unit,
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/output_sbom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub struct Sbom {
}

/// Build an [`Sbom`] for the given [`Unit`].
#[tracing::instrument(skip_all)]
pub fn build_sbom(build_runner: &BuildRunner<'_, '_>, root: &Unit) -> CargoResult<Sbom> {
let bcx = build_runner.bcx;
let rustc: SbomRustc = bcx.rustc().into();
Expand Down Expand Up @@ -139,6 +140,7 @@ pub fn build_sbom(build_runner: &BuildRunner<'_, '_>, root: &Unit) -> CargoResul
/// if it's using different settings, e.g. profile, features or crate versions.
///
/// Returns a graph of dependencies.
#[tracing::instrument(skip_all)]
fn build_sbom_graph<'a>(
build_runner: &'a BuildRunner<'_, '_>,
root: &'a Unit,
Expand All @@ -165,12 +167,6 @@ fn build_sbom_graph<'a>(
true => SbomDependencyType::Build,
};
dependencies.insert((dep, dep_type));
tracing::trace!(
"adding sbom edge {} -> {} ({:?})",
parent.pkg.package_id(),
dep.pkg.package_id(),
dep_type,
);
(dep, false)
};
if visited.insert(dep) {
Expand Down
20 changes: 19 additions & 1 deletion src/compiler/unit_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,29 @@ pub fn build_unit_dependencies<'a, 'gctx>(
list.sort();
}
}
trace!("ALL UNIT DEPENDENCIES {:#?}", state.unit_dependencies);

log_unit_deps_graph(ws.gctx(), &state.unit_dependencies);

Ok(state.unit_dependencies)
}

fn log_unit_deps_graph(gctx: &GlobalContext, graph: &UnitGraph) {
// For workspaces with large dependency graphs, the act of logging graph can actually take
// hundreds of milliseconds, skewing the profiling timings. By default, we do not dump the
// entire graph to avoid skewing the timings.
let graph_to_log = if gctx.get_env("__CARGO_DUMP_UNIT_DEP_GRAPH").unwrap_or("0") == "1" {
Some(graph)
} else {
None
};

trace!(
count = graph.len(),
graph = format!("{graph_to_log:#?}"),
"ALL UNIT DEPENDENCIES",
);
}

/// Compute all the dependencies for the standard library.
fn calc_deps_of_std(
state: &mut State<'_, '_>,
Expand Down