#984627 debcargo: should ignore build-dependencies that are marked cfg(target_env = "msvc")

Package:
debcargo
Source:
rust-debcargo
Description:
Create a Debian package from a Cargo crate
Submitter:
Daniel Kahn Gillmor
Date:
2026-07-22 13:47:02 UTC
Severity:
normal
#984627#5
Date:
2021-03-06 00:00:19 UTC
From:
To:
in Cargo.toml from nettle-sys 2.0.5, we see:

[target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg]
version = "0.2.9"


But debcargo 2.4.4 translates that into actual Build-Depends: and
Depends: fields, despite the target environment not being the MSVC
compiler.  It generates:
-----
Source: rust-nettle-sys
Section: rust
Priority: optional
Build-Depends: debhelper (>= 12),
 dh-cargo (>= 24),
 cargo:native <!nocheck>,
 rustc:native <!nocheck>,
 libstd-rust-dev <!nocheck>,
 librust-bindgen-0.55-dev <!nocheck> | librust-bindgen-0.54-dev <!nocheck> | librust-bindgen-0.53-dev (>= 0.53.1-~~) <!nocheck>,
 librust-pkg-config-0.3+default-dev <!nocheck>,
 librust-vcpkg-0.2+default-dev (>= 0.2.9-~~) <!nocheck>,
 nettle-dev (>= 3.5.1~~) <!nocheck>,
 llvm
Maintainer: Debian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Uploaders:
 Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
 kpcyrd <git@rxv.cc>
Standards-Version: 4.5.1
Vcs-Git: https://salsa.debian.org/rust-team/debcargo-conf.git [src/nettle-sys]
Vcs-Browser: https://salsa.debian.org/rust-team/debcargo-conf/tree/master/src/nettle-sys
Rules-Requires-Root: no

Package: librust-nettle-sys-dev
Architecture: any
Multi-Arch: same
Depends:
 ${misc:Depends},
 librust-bindgen-0.55-dev | librust-bindgen-0.54-dev | librust-bindgen-0.53-dev (>= 0.53.1-~~),
 librust-pkg-config-0.3+default-dev,
 librust-vcpkg-0.2+default-dev (>= 0.2.9-~~),
 nettle-dev (>= 3.5.1~~)
Provides:
----- So, i'll probably patch this out of the upstream sources for now, but debcargo should have handled this more cleanly.
#984627#12
Date:
2026-02-15 14:41:21 UTC
From:
To:
just a short update on this - I've had a chat with decathorpe,
the Fedora rust packaging maintainer, who has written a tool
that does exactly this:

https://codeberg.org/rust2rpm/rust2rpm-helper/src/branch/main/Cargo.toml

the current plan is to restructure and rename this crate to
make it usable by debcargo, and then extend it to also support
some of the other low-hanging fruit that fall into the "generate
patch for Cargo.toml" category.

in the end, we will have a (default true) flag in debcargo.toml
along the lines of "disable_foreign_targets", and debcargo
will then synthesize a patch for Cargo.toml removing all
dependencies conditionalized for certain targets, as well as
feature entries that reference them.

since Cargo.toml post patching will then no longer have those
dependencies, neither will d/control or d/test/control.

#984627#17
Date:
2026-07-22 13:39:04 UTC
From:
To:
debcargo.toml can now contain `filter_targets` which allows to
automatically generate a patch to remove all dependencies
conditionalized with `target.cfg`. It is opt-in at the moment and allows
to keep everything mapping to Debian architectures (including ports)
and/or WASM. I plan to switch the default at a later point to make it
opt-out.