Renaming target binary for a specific target (e.g: musl)

Hi all,

How to rename the target binary (usually in target/release) for a specific target. Compiling with both:

$ cargo build --release
$ cargo build --release --target x86_64-unknown-linux-musl

gives the same executable name.

The target-dir in the [build] section is only for changing the path, not the name, and is I guess valid for all builds.

Thanks for your help.

You can't. However, by default Cargo uses a different folder for cross-compilation: target/x86_64-unknown-linux-musl/release, so you still have two executables. You'll need a post-build step to copy and rename them.

Thanks for your answer.

I know target dirs are different, and renaming is already what I do. But I'm compiling for both native and musl targets, so the ability to have 2 different names would have been convenient.

Maybe I can file an issue ?

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.