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

Have a build script per binary #10293

Closed
piegamesde opened this issue Jan 14, 2022 · 3 comments
Closed

Have a build script per binary #10293

piegamesde opened this issue Jan 14, 2022 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@piegamesde
Copy link

piegamesde commented Jan 14, 2022

Problem

I have a Rust project with multiple embedded binaries. Those need different linker options, and thus different build scripts (the build script manages the linker script, which needs to be modified).

Proposed Solution

My preferred solution would be to have a build attribute in the [[bin]] section that I can set, as originally proposed here. Alternatively, it would be sufficient to simply expose the binary name to the build script, so that it may match on it and alter its behavior. As a third option, the ability to set rustflags per binary would probably help me out as well. But I think that per binary build scripts are the most general solution to this problem.

Notes

This is a similar, but more general request than #1430 and #1581.

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

ehuss commented Jan 14, 2022

The linker options can be set per-binary with cargo:rustc-link-arg-bin=BIN=FLAG from the build script. Does that work for you?

@piegamesde
Copy link
Author

This looks like a solution, although I cannot manage to pass it multiple times. (Setting rustc-link-arg multiple times works though, but obviously not per binary.) I think this may be a bug worthy of its own issue.

While my specific use case is sufficiently resolved, I'd still like to keep this issue open for the general feature. The number of references to the related issues shows that there is a lot of need for it.

@ehuss
Copy link
Contributor

ehuss commented Jan 17, 2022

I'm going to close in preference to #1430. They seem sufficiently similar that I don't think the solution would be developed independently. For now, I think cargo:rustc-link-arg-bin should help with linker arguments specifically.

@ehuss ehuss closed this as completed Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants