Skip to content

cargo rustc should accept multiple packages #12474

Open
@mkeeter

Description

@mkeeter

Problem

I've found myself in a situation where I want to

  • Build multiple packages in a single cargo invocation
  • Pass rustc flags on the command-line

The former works with cargo build, e.g. cargo build -p foo -p bar.

However, cargo build only lets you specify flags with RUSTFLAGS, which has different semantics than flags passed by cargo 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, matching cargo build, cargo check, etc.

Notes

Limiting cargo rustc to a single package was intentional in the original cargo 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustflagsArea: rustflagsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-rustcE-mediumExperience: MediumS-needs-rfcStatus: Needs an RFC to make progress.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions