Skip to content

Report time spent in the linker for binary targets separatelyΒ #10643

@petr-tik

Description

@petr-tik

Problem

As a a developer working on large executables,
I would like cargo to report the time spent linking executables
so that I can make use the linker that gives me the shortest edit-build-run-tests feedback loop

Currently, i can synthetically achieve that with a hyperfine command that deletes the executable and re-runs cargo build using the total wall-time as an approximation of build time. However, I cannot know how much time it takes cargo to analyse the target/ dir and realise that only the link-step needs to be re-run.

For clean builds I have even less information about link-time alone.

Proposed Solution

  1. Start measuring the duration of the linker step for TargetKind::Bin

Add an optional field to TimingInfo in src/cargo/util/machine_message.rs similar to rmeta_time

    #[serde(skip_serializing_if = "Option::is_none")]
    pub link_time: Option<f64>,

Which is only populated for targets that required linking.

  1. In the timings report, separate linking from other build steps

Choose a colour for html and a field for JSON and make it visually obvious to people

Notes

Implementing this enables generating the "Use a different linker" actionable suggestion proposed here
#10542

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-timingsArea: timingsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-waiting-on-feedbackStatus: An implemented feature is waiting on community feedback for bugs or design concerns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions