Skip to content
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

Equality requirement in project ignored by sub-dependency requirement #6876

Closed
little-arhat opened this issue Apr 25, 2019 · 3 comments
Closed
Labels
A-dependency-resolution Area: dependency resolution and the resolver C-bug Category: bug

Comments

@little-arhat
Copy link
Contributor

Hi,

Problem
Both application and its sub-dependency depend on library: application has equality requirements "= X.Y.Z", while sub-dependency can work with range: ">= X.Y.Z, < F.V"`.

I expect Cargo to only pull "X.Y.Z" version of a dependency, while both are pulled. Since library defines unmangled symbols (or will use links feature in the near future), this is an error.

Steps

Application dependencies:


[dependencies]
cortex-m = "=0.5.8"
cortex-m-log = {version = "0.4.0", features = ["semihosting"]}
panic-abort = "0.3.1"
stm32f30x = {version = "0.8.0", features = ["rt"]}
cortex-m-rt = "0.6.8"

Dependency in question is cortex-m-log, which depends on cortex-m-semihosting:

[dependencies]
cortex-m = "0.5"

[dependencies.cortex-m-semihosting]
version = "0.3"
optional = true

[features]
semihosting = ["cortex-m-semihosting"]

And [cortex-m-semihosting/(https://github.com/rust-embedded/cortex-m-semihosting) depends on cortex-m as well:

[dependencies]
cortex-m = ">= 0.5.8, < 0.7"

Application code (not important, but for completeness):

#![no_main]
#![no_std]
#![allow(unused)]

use cortex_m_rt::entry;
use panic_abort;
use stm32f30x;
use cortex_m_log::printer::semihosting::Semihosting;
use cortex_m_log::printer::Printer;
use cortex_m_log::modes::InterruptOk;
use core::fmt::Write;

#[entry]
fn main() -> ! {
    let prphs = stm32f30x::Peripherals::take().unwrap();
    let core = cortex_m::Peripherals::take().unwrap();
    let mut d = Semihosting::<InterruptOk, _>::stdout().unwrap();
    loop {
        write!(d.destination(), ";");
        cortex_m::asm::wfi()
    }
}

Compilation error:

  = note: rust-lld: error: duplicate symbol: CORE_PERIPHERALS
          >>> defined at mod.rs:153 (/Users/r/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/cortex-m-0.6.0/src/peripheral/mod.rs:153)
          >>>            cortex_m-774979bd87405991.cortex_m.b30jt41x-cgu.0.rcgu.o:(CORE_PERIPHERALS) in archive /Users/r/stuff/coco-test/target/thumbv7m-none-eabi/debug/deps/libcortex_m-774979bd87405991.rlib
          >>> defined at mod.rs:153 (/Users/r/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/cortex-m-0.5.8/src/peripheral/mod.rs:153)
          >>>            cortex_m-769a472e04c23d44.cortex_m.9qln9imh-cgu.0.rcgu.o:(.bss.CORE_PERIPHERALS+0x0) in archive /Users/r/stuff/coco-test/target/thumbv7m-none-eabi/debug/deps/libcortex_m-769a472e04c23d44.rlib

Excerpt from Cargo.lock:


[[package]]
name = "cortex-m-semihosting"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

cargo --version
cargo 1.36.0-nightly (6be12653d 2019-04-19)
rustc --version
rustc 1.36.0-nightly (e305df184 2019-04-24)

Am I missing something? It seems that in this scenario I should only have one cortex-m dependency, and it should be the one specified by equality, 0.5.8.

@Eh2406
Copy link
Contributor

Eh2406 commented May 2, 2019

cargo thinks cortex-m 0.7 is compatible with cortex-m 0.5, so it gives you the most recent one you can use for each part of the project. If there is only supposed to be one version of cortex-m in the dependency tree, for example as it links to a native dependency, then it should specify the links atribut in it cargo.toml.

@little-arhat
Copy link
Contributor Author

@Eh2406 I don't think that's the case. Reading docs it seems semver compatibility will come into play only if caret dependencies are used. In this example both application and sub-dependency define (in)equality versions.

As for the links attribute, linked issue from cortex-m addresses that, I believe.

@epage
Copy link
Contributor

epage commented Oct 31, 2023

This looks to be another variant of #9029, closing in favor of that one. If there is something I overlooked, let us know!

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants