Skip to content

print executable path for cargo build --bench #15275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cathaysia opened this issue Mar 7, 2025 · 2 comments
Closed

print executable path for cargo build --bench #15275

cathaysia opened this issue Mar 7, 2025 · 2 comments
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-build S-triage Status: This issue is waiting on initial triage.

Comments

@cathaysia
Copy link

Problem

If it's possible print executable path when build a benchmark? After building the benchmark, I will use perf to run it. But I find it very troublesome to find its path.

Proposed Solution

No response

Notes

No response

@cathaysia cathaysia added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Mar 7, 2025
@epage epage added Command-build A-console-output Area: Terminal output, colors, progress bar, etc. labels Mar 7, 2025
@epage
Copy link
Contributor

epage commented Mar 7, 2025

This can seem obvious to do but the problem it can run into is scale. A cargo build --release --bench foo is one thing. A cargo build --workspace --all-targets is another. Users are pretty sensitive to how much we output. For example, in #12859 we started reporting the paths to generated documentation but collapsed that down (#13557) based on feedback (#13336). In #8889, we are talking about reducing even further how much output we leave on the screen.

@weihanglo
Copy link
Member

The executable path is already available through the --no-run flag:

$ cargo bench --no-run
   Compiling foo v0.1.0 (/projects/foo)
    Finished `bench` profile [optimized] target(s) in 0.16s
  Executable benches/x.rs (target/release/deps/x-8870b9bf4b903a7f)

The target/release/deps/x-8870b9bf4b903a7f is the executable. Note that the Executable status message is not a programmable output. For programmable usage, check --message-format=json.

See also #1924, which looks for deterministic filenames for test targets (benchmarks are in the same category).

Going to close this, Cargo already provides executable paths for both human and machine. If there is anything wrong, add comments below!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-build S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants