Skip to content

Tracking Issue for RFC 3028: Allow "artifact dependencies" on bin, cdylib, and staticlib crates #9096

Open

Description

@ehuss

View all comments

Summary

RFC: #3028
Related Issues: #4316, #8311
Implementation: #9992
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies
Issues: Z-bindeps Nightly: binary artifact dependencies

Allow Cargo packages to depend on bin, cdylib, and staticlib crates, and use the artifacts built by those crates.

Unresolved issues

  • Make a list of any known implementation or design issues.
  • Add support for inheriting the source of an artifact dependency
  • Ensure we have a test for an artifact dep on a bin with required-features without specifying the features; ensure the behavior is reasonable
  • cargo tree support: Display artifact dependency information in cargo tree #14804
  • Should cargo check just check artifact deps, rather than build them?
  • Integrate with profile trim-paths

Notes

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Activity

  1. retep998 commented on Mar 2, 2021

    @retep998
    Contributor

    Please note that a cargo package only being able to provide a single cdylib or staticlib is a limitation imposed by cargo which technically could be lifted in the future. I'd prefer for this feature to be able to accommodate multiple cdylib or staticlib artifacts from a single package.

  2. npmccallum commented on Aug 13, 2021

    @npmccallum
    Contributor

    @joshtriplett @jyn514 I found a problem in the original RFC that makes it unfit for our use case. Specifically, it is presumed that a given dependency crate will be built for one and only one architecture producing one binary artifact. We have need to build a given crate for multiple architectures producing one artifact per architecture.

  3. bjorn3 commented on Aug 13, 2021

    @bjorn3
    Member

    Are package renames allowed? That is something like:

    [dependencies]
    foo-x86 = { package = "foo", artifact = "bin", target = "x86_64-unknown-linux-gnu" }
    foo-aarch64 = { package = "foo", artifact = "bin", target = "aarch64-unknown-linux-gnu" }
  4. joshtriplett commented on Aug 13, 2021

    @joshtriplett
    Member
  5. DrChat commented on Oct 16, 2021

    @DrChat

    Is there anyone actively working on this RFC?
    Could a cargo maintainer post a brief write-up of how they'd implement this? E.g. relevant files in this repository, gotchas, etc.

  6. bjorn3 commented on Oct 17, 2021

    @bjorn3
    Member

    The followup RFC is rust-lang/rfcs#3176.

  7. npmccallum commented on Oct 17, 2021

    @npmccallum
    Contributor

    Is there anyone actively working on this RFC?

    @Byron plans to start work on this tomorrow.

  8. DrChat commented on Oct 17, 2021

    @DrChat

    👍 Thanks for the updates!

  9. Byron commented on Oct 18, 2021

    @Byron
    Member

    Thank you @npmccallum for the introduction. Even though I am delayed, I believe a draft PR should be submitted in the next couple of days as I am ramping up.

  10. moved this to In Progress in Open-Source Workon Oct 28, 2021
  11. Person-93 commented on Nov 29, 2021

    @Person-93

    Another thing to consider is a binary crate that depends on other binary crates and expects its dependencies to be available in PATH.

  12. added a commit that references this issue on Feb 22, 2022
  13. 27 remaining items

  14. moved this to In Progress in Cargo Roadmapon Sep 5, 2023
  15. epage commented on Mar 1, 2025

    @epage
  16. weihanglo commented on Mar 1, 2025

    @weihanglo
  17. peppergrayxyz commented on Oct 31, 2025

    @peppergrayxyz

    Please also expose the feature via cargo add --artifact

  18. sylveon commented on Jun 1, 2026

    @sylveon

    I just spent an embarrassing amount of time debugging a failure because cargo build --bin foo will not rebuild any cdylib dependencies that the foo crate depends on. I need this cdylib dependency to be rebuilt as well so that I can change things in tandem.

    What's the status on this?

  19. epage commented on Jul 27, 2026

    @epage
    Contributor

    Looking at the docs: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html

    zoo = { version = "1.0", artifact = ["bin:cat", "bin:dog"]}

    can be the same as

    zoo = { version = "1.0", artifact = ["bin"]}

    but I think a person would read "bin" as selecting the one and only bin in the package. I think it should instead be "bins" or "bin:*".

    I could see us supporting "bin" for what I think users would read it as. The problem is adding a second bin could be a breaking change. We could (ab)use package.default-run to have "bin" resolve to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: A tracking issue for something unstable.S-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.S-waiting-on-feedbackStatus: An implemented feature is waiting on community feedback for bugs or design concerns.Z-bindepsNightly: binary artifact dependencies

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions