# Dependencies for other (unused) platforms

**URL:** <https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676>\
**Category:** help\
**Created:** [September 28, 2026, 1:22pm UTC](https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676 "2026-09-28T13:22:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdelmas](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/tdelmas/32/34345_2.png) [@tdelmas](https://users.rust-lang.org/u/tdelmas)\
**Post date:** [September 28, 2026, 1:22pm UTC](https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676/1 "2026-09-28T13:22:58Z")

</div>

When building an app for Linux (for example), I try to ignore/exclude dependencies that are specify to other targets (android, windows, wasm, ...).

The goals are multiples:

- Reduce the risk of supply chain attacks
- Reduce the number of review with cargo-vet
- Reduce the diff when updating

For that, I use the following set-up:

In Cargo.coml :

```toml
[patch.crates-io]
android_system_properties = { path = "noop/android_system_properties" }

```

And in `noop/android_system_properties` I add the following file:

```rust
name = "android_system_properties"
version = "0.1.6"
edition = "2024"
publish = false

[lib]
path = "../lib.rs"

[features]
call = []

```

(`../lib.rs` is an existing empty file)

- The `version` must be the same as in `Cargo.lock`
- The `[features]` section is necessary to declare the features declared in the crate using it as a dependency

This works well with most crates (`android_system_properties`, `libredox`, `wasm-bindgen`, `windows-sys`, ...)

- Any sub-dependency of those crates will be ignored (thus, not in `Cargo.lock`)
- It prevent supply-chain attacks from those crates and all their dependencies
- `cargo vet` will not ask for useless review

However, there is some drawbacks :

- Some crates with a lot of features requires (a little) more work
- When multiples versions are in the dependency tree, I need to declare all of them. For exemple: `windows-sys-0-52 = { path = "noop/windows-sys-0.52", package = "windows-sys" }`

And for some crates, I couldn't find a proper way to do it:

The crate `cc` declare `find-msvc-tools` but if that crate is an empty shell, the build will fail, because the code in `cc` use it even in for `x86_64-unknown-linux-gnu`.

Is there a more simple way to do it?

Ideally I would like to specify in a config file the build target(s), and that all dependencies that aren't for it will be ignored (no event be in `Cargo.lock`)

---

<div class="post-metadata">

**Author:** ![jofas](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/jofas/32/30690_2.png) [@jofas](https://users.rust-lang.org/u/jofas)\
**Post date:** [September 28, 2026, 1:38pm UTC](https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676/2 "2026-09-28T13:38:57Z")

</div>

> [@tdelmas](#):
>
> Is there a more simple way to do it?

What about target-specific dependencies?

> **[Platform specific dependencies - Specifying Dependencies - The Cargo Book](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)**
>
> Your crates can depend on other libraries from crates.io or other registries, git repositories, or subdirectories on your local file system. You can also temporarily override the location of a dependency — for example, to be able to test out a bug...

---

<div class="post-metadata">

**Author:** ![tdelmas](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/tdelmas/32/34345_2.png) [@tdelmas](https://users.rust-lang.org/u/tdelmas)\
**Post date:** [September 28, 2026, 2:07pm UTC](https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676/3 "2026-09-28T14:07:24Z")

</div>

> [@jofas](#):
>
> What about target-specific dependencies?

Well, they already are: [socket2/Cargo.toml at v0.6.5 · rust-lang/socket2 · GitHub](https://github.com/rust-lang/socket2/blob/v0.6.5/Cargo.toml#L55)  
(not `find-msvc-tools` but I'm thinking about opening a PR for that. Edit: [Why find-msvc-tools is not behind a cfg(windows) guard? · Issue #1963 · rust-lang/cc-rs · GitHub](https://github.com/rust-lang/cc-rs/issues/1963))

But target-specific dependencies (and their dependent) always appear in `Cargo.lock`, and `cargo vet` still requires an audit for them and their dependent.

---

<div class="post-metadata">

**Author:** ![Spark1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Spark1](https://users.rust-lang.org/u/Spark1)\
**Post date:** [September 28, 2026, 4:49pm UTC](https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676/4 "2026-09-28T16:49:12Z")

</div>

Why do you believe this will help against supply chain attacks?

---

<div class="post-metadata">

**Author:** ![tdelmas](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/tdelmas/32/34345_2.png) [@tdelmas](https://users.rust-lang.org/u/tdelmas)\
**Post date:** [September 28, 2026, 5:12pm UTC](https://users.rust-lang.org/t/dependencies-for-other-unused-platforms/142676/5 "2026-09-28T17:12:16Z")

</div>

For two reason:

- If a platform-specific crate not under a config-guard (`[target.'cfg(windows)'.dependencies]`) or one of its dependency is infected, then this system help to prevent the installation of the malicious version.
- With less crate to review with `cargo vet`, there is more time to review the crates really used and installed

It is not perfect, but I think it does improve the situation.
