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

allow cargo --profile debug for simpler Makefiles #13495

Open
lolbinarycat opened this issue Feb 27, 2024 · 5 comments
Open

allow cargo --profile debug for simpler Makefiles #13495

lolbinarycat opened this issue Feb 27, 2024 · 5 comments
Labels
A-layout Area: target output directory layout, naming, and organization A-profiles Area: profiles C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

Comments

@lolbinarycat
Copy link

Problem

cargo is great for simple projects, but for more complex (eg. multi-language) projects, it is often desirable to use cargo in addition to a more general build system, such as make.

however, the way cargo outputs build directories is often difficult to configure via make, usually resulting in people writing their makefiles in a way that only works with --release

Proposed Solution

if this was implemented, configuring builds would be as simple as:

profile = debug
bin = target/$(profile)/myprogram

$(bin): src/main.rs Cargo.toml
	cargo build --profile $(profile)

and then you could call either make profile=release or make profile=debug

Notes

this already works fine for profile=release, but it throws an error when you try to build it with less optimizations:

cargo build --profile debug
error: profile name `debug` is reserved
To configure the default development profile, use the name `dev` as in [profile.dev]
See https://doc.rust-lang.org/cargo/reference/profiles.html for more on configuring profiles.
@lolbinarycat lolbinarycat 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 Feb 27, 2024
@epage epage added A-profiles Area: profiles A-layout Area: target output directory layout, naming, and organization labels Feb 27, 2024
@epage
Copy link
Contributor

epage commented Feb 27, 2024

If I understand, you are wanting debug to be an alias for dev so the profile name can be used for the directory name.

Likely another option is to define your own profile in a config and have it inherit dev.

#6790 would be another option for this.

@lolbinarycat
Copy link
Author

i just want an elegant way to use rust in makefiles, as far as i can tell, there really isn't one right now

@epage epage added S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Mar 7, 2024
@soloturn
Copy link
Contributor

soloturn commented Apr 21, 2024

custom profiles and out-flag is not good enough in case you do not like adapting rust flags?
https://stackoverflow.com/questions/38803760/how-to-get-a-release-build-with-debugging-information-when-using-cargo

cargo build --profile=myprofile --out myprofile

@epage how can one use this in a project repository? or is this a personal setting?

@epage epage added S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix and removed S-needs-team-input Status: Needs input from team on whether/how to proceed. labels Feb 4, 2025
@epage
Copy link
Contributor

epage commented Feb 4, 2025

@soloturn sorry for the delayed repsonse. April was busy and I've still not caught up to it.

I'm not entirely sure about the nature of your question. Your link doesn't seem too relevant to the conversation here. This is about being able to predict the location of final artifacts which gets more difficult for dev profile because it outputs to the debug directory.

@epage
Copy link
Contributor

epage commented Feb 4, 2025

As for this issue, we talked about it in the Cargo team meeting and are concerned that making them alias each other could get in the way of some other debug/dev profile work we are considering, see https://blog.rust-lang.org/inside-rust/2024/12/13/this-development-cycle-in-cargo-1.84.html#improving-the-built-in-profiles

As such, determining what to do with this issue is blocked until we know whether we want to do that and whether one blocks the other.

As I mentioned earlier, ways around this are

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Area: target output directory layout, naming, and organization A-profiles Area: profiles C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Projects
None yet
Development

No branches or pull requests

3 participants