-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo rustc
should accept multiple packages
#12474
Comments
Would a more accurate title for this issue be "Allow passing rustc flags to specified packages"? That leaves the door more open for us to explore alternatives. Also, what is your use case for wanting to pass flags only to specific packages? Knowing that can help us better evaluate what solution best fits within cargo. |
For what I'm doing, I need the same (the obvious downside is
For my use case, controlling I need to control Aside on why using
|
Ok. I think I misunderstood
to mean that you wanted to control which packages the flags were passed to though I think that can serve as a potential solution. Instead, the root causes of your build performance issues includes:
Does that summarize it? |
FWIW, looks like the use case here could be covered by rust-lang/rfcs#3310. |
Yup, that seems like an accurate summary! One more possible detail: there could be esoteric cases where flags should be set for the target package but should not be set for dependencies. I don't have a concrete example of this; the linker flags are unused-but-innocuous when passed to dependencies, but that may not always be the case...
Yes, I agree that would also be a potential solution (by letting us use It seems like there are a bunch of different approaches that we could take here, so I appreciate all the clarifying questions. |
I'll mark this as needing RFC while we're waiting for rust-lang/rfcs#3310. extending Also marked as medium level as it is not way too hard to get it done, but I expected it to take time to have a conclusion. @rustbot label -S-triage +S-needs-rfc +E-medium +A-rustflags +Command-rustc |
I'd be happy to do the "extending Does that seem reasonable, or would the team prefer one of the alternate solutions (e.g. waiting until that RFC is merged + implemented)? For what it's worth, the changes to $ git diff --stat
src/bin/cargo/commands/rustc.rs | 14 +++++++-------
src/cargo/ops/cargo_compile/mod.rs | 25 ++++++-------------------
2 files changed, 13 insertions(+), 26 deletions(-) |
For me, the bigger question that I'd want from others on the cargo team is what the role of |
I'm also finding myself wanting to be able to pass multiple package to In this case the modules all have We're intentionally avoiding putting Our build workflow / tooling is currently based on In this case it seems like it would be convenient if |
Problem
I've found myself in a situation where I want to
cargo
invocationrustc
flags on the command-lineThe former works with
cargo build
, e.g.cargo build -p foo -p bar
.However,
cargo build
only lets you specify flags withRUSTFLAGS
, which has different semantics than flags passed bycargo rustc
:RUSTFLAGS
are applied to all dependencies, not just the top-level package being built.Proposed Solution
Change
cargo rustc
to accept multiple packages using the-p
flag, matchingcargo build
,cargo check
, etc.Notes
Limiting
cargo rustc
to a single package was intentional in the originalcargo rustc
PR. This may be because no one was asking for multi-package support at the time?I've implemented multi-package support in a local checkout and it seems to work fine. I'd be happy to work with the team on a PR (with updated tests, etc) if you're open to it!
The text was updated successfully, but these errors were encountered: