Compiling options for cargo install

Is there a way to pass compiling options to cargo install? For example, I'd like cargo to install a minimum sized binary. Is it possible to do this with cargo install or do I have to compile it manually? I read the doc at cargo install - The Cargo Book but it doesn't seem to have a way to pass compiling options.

When you say "minimum sized binary", what do you mean? Do you have certain rustc flags in mind?

You can use the RUSTFLAGS environment variable to pass arbitrary command-line arguments to rustc. For example:

RUSTFLAGS="-C target-cpu=native" cargo install ripgrep

For example, strip = True and opt-level = "z".

Thank you very much! This is very helpful!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.