Skip to content

Don't require existence of dependencies not needed for the current --target #5896

@infinity0

Description

@infinity0

I've been experimenting with converting platform-specific cargo dependencies into platform-specific Debian dependencies. At the moment this is very crude but works in most Real World cases, allowing us to avoid installing winapi etc (and core-foundation, redox-*, fuchsia-*) as build-dependencies when building various crates in Debian. However cargo itself complains about it and fails:

Source: rust-backtrace
Section: rust
Priority: optional
Build-Depends: debhelper (>= 11),
 dh-cargo (>= 8),
 cargo:native <!nocheck>,
 rustc:native <!nocheck>,
 libstd-rust-dev <!nocheck>,
 librust-backtrace-sys-0.1+default-dev (>= 0.1.17~~) <!nocheck>,
 librust-cfg-if-0.1+default-dev <!nocheck>,
 librust-libc-0.2+default-dev <!nocheck>,
 librust-rustc-demangle-0.1+default-dev (>= 0.1.4~~) <!nocheck>,
 librust-winapi-0.3+dbghelp-dev (>= 0.3.3~~) [windows-any] <!nocheck>,
 librust-winapi-0.3+default-dev (>= 0.3.3~~) [windows-any] <!nocheck>,
 librust-winapi-0.3+minwindef-dev (>= 0.3.3~~) [windows-any] <!nocheck>,
 librust-winapi-0.3+processthreadsapi-dev (>= 0.3.3~~) [windows-any] <!nocheck>,
 librust-winapi-0.3+std-dev (>= 0.3.3~~) [windows-any] <!nocheck>,
 librust-winapi-0.3+winnt-dev (>= 0.3.3~~) [windows-any] <!nocheck>
Maintainer: Debian Rust Maintainers <[email protected]>
[..]

The [windows-any] annotation tells most Debian tools that those dependencies can be ignored. When I build it on x86-64 Debian, the Debian build tool does indeed omit installing these build-dependencies. But cargo doesn't like the fact that they're absent:

[..]
   dh_auto_build -O--buildsystem=cargo
   dh_auto_test -O--buildsystem=cargo
error: no matching package named `winapi` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
required by package `backtrace v0.3.9 (file:///<<PKGBUILDDIR>>)`
dh_auto_test: cargo build --verbose --verbose -j4 --target x86_64-unknown-linux-gnu -Zavoid-dev-deps returned exit code 101
make: *** [debian/rules:3: build] Error 101
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

This seems related to #5655 and #5133, but according to alexcrichton/cargo-vendor#70 seems pretty hard to achieve. We have the necessary infrastructure in place to start taking advantage of it in Debian however, in case this encourages anyone to work on it. Then we won't have to ping everyone to upgrade from winapi 0.2 to 0.3 any more :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverA-lockfileArea: Cargo.lock issuesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions