rust-lang / rust-lang/cargo

Allow defining crate-type for dependencies?

Open
#629 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-configuration A-crate-dependencies A-crate-types A-linkage S-triage Z-bindeps
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

I'd like to easily manage a common collection of functionality for application plugins. I've tried doing this by linking all plugins to functionality in Cargo's target/deps folder, but as Cargo compiles all dependencies to rlibs, and Rust has issues linking plugins (dylibs) that are statically linked to common libraries, terrible thing happen. However, terrible things don't happen if plugin dependencies are also compiled as dylibs.

Unfortunately, the manifest guide states, for crate-type

"The available options are dylib, rlib, and staticlib. You should only use this option in a project. Cargo will always compile packages (dependencies) based on the requirements of the project that includes them."

This automation stops me from achieving the result needed. Some solutions:

  1. Have Cargo allow defining of crate-type for each dependency.
  2. Have Cargo allow defining of crate-type for all dependencies in the package.
  3. Write my own project-specific package manager from hell.

1 or 2 seem the most preferable options. Would one of these be suitable for the Cargo project?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the manifest guide's crate-type section and the issue's description of how Cargo compiles dependencies as rlibs. Investigate how dependency crate types are selected and determine whether per-dependency or package-wide configuration is feasible. Done means Cargo supports the requested dylib dependency configuration for plugin use without breaking existing dependency builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.