Skip to content
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

Provide a way to generate hardlinks for binaries under different names #8213

Open
luser opened this issue May 6, 2020 · 1 comment
Open
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@luser
Copy link
Contributor

luser commented May 6, 2020

It's not uncommon for commandline tools to take different actions when invoked under different names. An extreme example of this is busybox which implements a slew of standard POSIX shell utilities. Its FAQ says:

If the Busybox executable is renamed to one of the commands it supports, it will act as that command automatically:
ln -s busybox pwd
./pwd

Given that Rust does not encourage dynamic linking if a project wants to create multiple binaries with a shared core of functionality there aren't many other good options. Even with dynamic linking on the table, being able to easily produce and distribute statically-linked binaries is a big selling point of writing commandline tools in Rust.

Describe the solution you'd like

Some way to specify an aliased name for bin targets that cargo would honor as part of the build would be helpful. As a strawman, perhaps:

[[bin]]
name = "mybin"
aliases = ["anothername"]

Would ask cargo to install this binary as both mybin and anothername. Ideally this would happen via hardlinks, but on platforms where they're not available copying the binary to the aliased names seems acceptable.

Notes

This came up while discussing feature additions to ripgrep. The rg command is not amenable to subcommands given how it handles commandline arguments so adding new functionality that isn't part of searching means adding awkward options.

@luser luser added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label May 6, 2020
@ehuss
Copy link
Contributor

ehuss commented May 23, 2020

cc #1706

@ehuss ehuss added the A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) label May 23, 2020
@epage epage added the S-needs-team-input Status: Needs input from team on whether/how to proceed. label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants