rust-lang / rust-lang/cargo

feature flag overwrites using crates.io do not work, local overwrites with patch do

Open
#5,963 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-features A-patch S-triage
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

With the juice project there is an issue regarding the diamond structured dependency tree.

juice needs coaster-nn and coaster-blas, where coaster-blas and coaster-nn each require coaster for the generic API.
All features flags (in this case, backends which is one of native, cuda, opencl) are passed through from coaster-nn coaster-blas and coaster up to juice. The default set is to incude all 3 features native,cuda,opencl (for all 4 libraries).

If someone now wants to create a binary just linking juice itself with non-default features, the linker still pulls in ALL of the linker flags, -lOpenCL -lcuda -lopenblas.

This only fails if all dependencies are pulled in from crates.io, as soon as local overwrites via [replace] or [patch] are used, the linker flags are as expected - no linkage of -lOpenCL or -lcuda is attempted.

See the below thread for more details:

https://github.com/spearow/juice/issues/38#issuecomment-417949764

Sidenote: I am well aware that in a perfect world coaster would not need to know anything about the backends, but we are not quite there yet :)

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

Reproduce the diamond dependency case described for juice, coaster-nn, coaster-blas, and coaster using crates.io dependencies, comparing default and selected backend features. Compare linker flags with crates.io resolution versus local [replace] or [patch] overrides; done means non-default builds no longer attempt to link OpenCL, CUDA, or OpenBLAS.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.